22 May '13 - 10:02 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: How to monitor the real output signal of a device?  (Read 491 times)
Louk
Posts: 1


« on: 26 May '12 - 01:17 »
Reply with quoteQuote

Hi,

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();
                                    }
                                }
                            }

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?
« Last Edit: 26 May '12 - 01:49 by Louk » Logged
Ian @ un4seen
Administrator
Posts: 15259


« Reply #1 on: 28 May '12 - 16:02 »
Reply with quoteQuote

A "loopback" recording device is a little different to a "Stereo Mix" recording device/input. It captures the mix of sounds that Windows is sending to the device, rather than the device's mix, so it won't include the effect of the device's own volume controls. If you would like it do so for you VU meter, you could try getting the device's volume setting and applying that to the loopback level, eg. initialize the corresponding output device and then do something like this:

BASS_WASAPI_SetDevice(outputdevice); // set device context to the output device
float devicevol=BASS_WASAPI_GetVolume(TRUE); // get its volume setting
finallevel=loopbacklevel*devicevol; // apply that to the loopback level
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines