I'm building a mixer that should help the user to find a good balance between volume settings of in- and output channels. So I want to couple some VU-meters with mixer faders.
I already did this for Windows XP by selecting the output device and the "Stereo Mix" or "What you hear" input and start a recording using BASS_RecordInit.BASS_RecordSetInput and BASS_RecordStart and finally add a DSP_PeakLevelMeter to it.
Within the limited capabilities of Windows XP, this works fine: I can see the volume levels increasing and decreasing when changing the master volume of the output device with the Windows XP standard mixer.
The next step: Windows 7 and Wasapi...
I finally got this working using the following code:
// deviceId is the device ID of the [b]loop back device[/b], corresponding to the output device to be monitored
vuMeter.WasapiHandler = new BassWasapiHandler(deviceId, false, 4410, 2, 0, 0);
if (vuMeter.WasapiHandler.Init())
{
if (vuMeter.WasapiHandler.Start())
{
int inputChannel = vuMeter.WasapiHandler.InputChannel;
WriteLog(0, "Wasapi inputChannel = " + inputChannel);
if (inputChannel >= 0)
{
if (!Bass.BASS_RecordSetInput(inputChannel, BASSInput.BASS_INPUT_ON, -1))
{
... Handle exception ...
}
}
if (inputChannel != 0)
{
vuMeter.plMeter = new DSP_PeakLevelMeter(inputChannel, 1000);
vuMeter.plMeter.CalcRMS = true;
vuMeter.plMeter.Notification += new EventHandler(eventHandler);
vuMeter.plMeter.Start();
}
}
}
vuMeter.WasapiHandler = new BassWasapiHandler(deviceId, false, 4410, 2, 0, 0);
if (vuMeter.WasapiHandler.Init())
{
if (vuMeter.WasapiHandler.Start())
{
int inputChannel = vuMeter.WasapiHandler.InputChannel;
WriteLog(0, "Wasapi inputChannel = " + inputChannel);
if (inputChannel >= 0)
{
if (!Bass.BASS_RecordSetInput(inputChannel, BASSInput.BASS_INPUT_ON, -1))
{
... Handle exception ...
}
}
if (inputChannel != 0)
{
vuMeter.plMeter = new DSP_PeakLevelMeter(inputChannel, 1000);
vuMeter.plMeter.CalcRMS = true;
vuMeter.plMeter.Notification += new EventHandler(eventHandler);
vuMeter.plMeter.Start();
}
}
}
This works, but the problem is that signal shown by the VU-meter is the unprocessed input signal of the device, not the output signal that is controlled by the master fader.
But this is not what I need: I need the VU-meters to follow the real output signal (including the influence of the master volume fader).
What I actually mean is the difference between the gray and green VU-meter lines in the Windows 7 standard mixer.
Any suggestions?

Reply
Quote