Rainmeter Plugin
v1.1.4
Overview:
AudioLevel lets you monitor the amplitude of the post-mixer signal at a Windows audio endpoint. (i.e. sound card speaker output, USB audio interface, headphone port, microphone input) It does this by creating a WASAPI capture client in loopback mode. (see http://msdn.microsoft.com/en-us/library/windows/desktop/dd316551%28v=vs.85%29.aspx)
The capture client streams audio data to the plugin where it gets measured and filtered - the resulting volume level is returned by the plugin for use in Rainmeter measures/meters.
TL;DR:
AudioLevel lets you make meters that respond to your music.
Usage:
AudioLevel follows the WebParser paradigm and uses a parent-child setup. The parent AudioLevel measure does the actual calculations on the audio data - you only want one of these per sound card input/output. The child measures request data from the parent so that you can get individual values. Example:
Code: Select all
; This parent measure processes the default audio output.
[measureAudioRaw]
Measure=Plugin
Plugin=AudioLevel
; This child measure gets the current approx RMS (http://en.wikipedia.org/wiki/Root_mean_square) value of the left channel (0.0 to 1.0).
[measureAudioRMS_L]
Measure=Plugin
Plugin=AudioLevel
Parent=measureAudioRaw
Channel=L
Type=RMS
There are a few parameters - some go on the parent, some go on the children. These are described here:
Parent Parameters:
Port:
values: Input, Output
default: Output
This specifies whether you want to measure the input or output for the given device.
ID:
values: (see notes)
default: (none)
This specifies the audio device to which you want to connect. If unspecified, it will use
the default device for the specified port, that is, if you specify Port=Output and no ID,
the plugin will try to connect to your default audio output device. (you can control this
with "Manage Audio Devices" from the start menu.) To specify a device, you'll need to find
the Windows device ID. See the DeviceList parameter for more info.
RMSAttack:
values: time in ms
default: 300
RMSDecay:
values: time in ms
default: 300
RMSGain:
values: gain factor (number)
default: 1.0
During measurement, the signal is filtered so that you don't see the tiny spikes of each sample value and it responds more like a traditional VU meter. You can control this filtering with these parameters. RMSAttack specifies the time in milliseconds over which to interpolate as the signal level increases (how quick the needle jumps up for a new peak). RMSDecay specifies the time in ms over which the level decays when the signal gets lower. RMS measurement squares the value of each sample, filters the squared values, then returns the square root of the filtered value. The RMSGain value is multiplied to the final value before it is returned. To disable all filtering, just specify 0 for the attack/decay constants and 1.0 for the gain.
PeakAttack:RMS is the square root of the mean of the square. It is a meaningful way of calculating the average of values over a period of time. With audio, the signal value (amplitude) is squared, averaged over a period of time, then the square root of the result is calculated. The result is a value, that when squared, is related (proportional) to the effective power of the signal.
values: time in ms
default: 50
PeakDecay:
values: time in ms
default: 2500
PeakGain:
values: gain factor (number)
default: 1.0
The peak values work just like the RMS values, except peak measurements are made by taking the absolute value of each sample, rather than squaring. To disable all filtering, just specify 0 for the attack/decay constants and 1.0 for the gain.
FFTSize:
values: size of FFT to process (even integer >= 0, usually power of 2)
default: 0
Optionally, you can have the plugin run an FFT analysis on the audio to transform it to the frequency domain. The returned values are accessed with the child param FFTIdx. FFT's are a big topic, you can start here: http://en.wikipedia.org/wiki/Discrete_Fourier_transform. Typical values for this are 256, 512, 1024. The higher the value, the better the frequency resolution of the output data, but the worse the CPU impact and the delay between the audio and the measure's response.
FFTOverlap:
values: # of samples to overlap per FFT window (integer between 0 and FFTSize-1)
default: 0
Optionally, the FFT can be windowed to overlap successive sections. A Hann function is used to shape the data pre-FFT. Typical values are half the FFTSize. Increasing this value will lower the latency between the audio and the measure's response, at the cost of extra CPU.
Bands:
values: number of frequency bands to generate (integer >= 0)
default: 0
Optionally, the FFT data can be smoothed into a number of log-spaced frequency bands, similar to a typical spectrum analyzer. This parameter specifies the number of bands.
FreqMin:
FreqMax:
values: min and max frequencies of frequency band calculations, in Hz
defaults: 20 and 20000, respectively
If band processing is enabled (see above), these parameters specify the frequency range over which the bands should be calculated.
Sensitivity
values: dynamic range, in dB
default: 35.0
This value specifies over what dB range the measure will return FFT and Band data. Increasing this value will cause the measure to respond on quieter sounds, decreasing it will make only loud sounds trigger the measure.
Child Parameters:
Parent:
values: parent measure name
default: (none)
This specifies the parent measure from which you want to extract data.
Channel:
values: L/FL/0, R/FR/1, C/2, LFE/Sub/3, BL/4, BR/5, SL/6, SR/7, Sum/Avg
default: Sum
This specifies which channel's level you'd like to extract from the parent. Channels can be
identified by name or number, e.g. Channel=0 is the same as Channel=L or Channel=FL.
FFTIdx: (only if FFTSize enabled on parent)
values: FFT frequency bin number, from 0 to FFTSize/2
default: 0
This specifies which FFT bin you want to extract from the parent.
BandIdx: (only if FFTSize and Bands enabled on parent)
values: Frequency band number, from 0 to (Bands-1)
default: 0
This specifies which frequency band you want to extract from the parent.
Type:
values: RMS, Peak, FFT, Band, FFTFreq, BandFreq, Format, DeviceStatus, DeviceName, DeviceID, DeviceList
default: (none)
This specifies the particular data you want from the parent:
RMS:
Get the current RMS level for the specified channel as a numerical value.
Peak:
Get the current Peak level for the specified channel as a numerical value.
FFT:
Get the raw FFT bin value specified by the FFTIdx param.
Band:
Get the frequency band value specified by the BandIdx param.
FFTFreq:
Get the frequency corresponding to the particular FFTIdx.
BandFreq:
Get the frequency corresponding to the particular BandIdx.
Format:
Get a string describing the device audio format.
DeviceStatus:
1 if the parent is connected to the specified device, else 0.
DeviceName:
(string value) Get the display name of the parent's connected device, if any.
DeviceID:
(string value) Get the ID of the parent's connected device (for use with specifying ID in a parent).
DeviceList:
(string value) Get the list of all available devices for the specified Port. Each item in the list is an ID:name pair. You can copy the ID from your Rainmeter->About Skins window into the ID field of your parent measure to specify a particular device. Should look something like this: {0.0.0.00000000}.{83b88ba1-6140-482e-adbf-fb729d9b1839} Note: this may be an expensive call - you probably want to disable this measure once you've figured out the ID you need.
Example Skin: Note, this requires the latest (at least 3.2.0 r2317) 3.2 beta of Rainmeter. The AudioLevel plugin is now included in the Rainmeter build, and all future changes to the plugin will be supported in beta and final releases of Rainmeter.