[wdmaudiodev] Re: Audio Mixer control applet

  • From: "Bogdan Sataric" <bogdan.sataric@xxxxxxxxx>
  • To: <wdmaudiodev@xxxxxxxxxxxxx>
  • Date: Wed, 27 Jan 2010 11:58:49 +0100

Frank thanks for the answer. It has helped a lot!

 

I have implemented application according to the examples that you have given
me:  Device <http://msdn.microsoft.com/en-us/library/dd370825(VS.85).aspx>
Topology and Using the
<http://msdn.microsoft.com/en-us/library/dd316787(VS.85).aspx>  IKsControl
Interface to Access Audio Properties . Using these examples I was able to
read (GET) Equalizer properties such as KSPROPERT_AUDIO_NUM_EQ_BANDS,
KSPROPERTY_AUDIO_EQ_BANDS and KSPROPERTY_AUDIO_EQ_LEVEL. The number of
Equalizer bands reported in device firmware is 5, while the bands are in
range of: 125, 500, 2000, 8000, 16000 Hz. All the values read by functions
made according to previously mentioned examples are correct. Audio equalizer
level reported in firmware for all 5 bands is 1dB, and the function
returning Eq levels returns LONG [5] array of 65536, which is also correct
(since Eq level scale is 1/65536 dB as stated in MSDN documentation). 

 

The problem is however, when I try to SET new equalizer levels. Basically I
use the same functionality described in example: Using the
<http://msdn.microsoft.com/en-us/library/dd316787(VS.85).aspx>  IKsControl
Interface to Access Audio Properties while instead of KSPROPERTY_TYPE_GET, I
use KSPROPERTY_TYPE_SET, while keeping the rest of the code unchanged. The
code is given below:

 

            LONG  FreqAttenuationVal[5];

 

            for (int i=0; i<5 ; i++) {

                        FreqAttenuationVal[i] = 65536;

            }

 

            //now send the set request to KS node

            KSNODEPROPERTY_AUDIO_CHANNEL ksprop;

            ZeroMemory(&ksprop, sizeof(ksprop));

            ksprop.NodeProperty.Property.Set = KSPROPSETID_Audio;

            ksprop.NodeProperty.Property.Id = KSPROPERTY_AUDIO_EQ_LEVEL;

            ksprop.NodeProperty.Property.Flags = KSPROPERTY_TYPE_SET |
KSPROPERTY_TYPE_TOPOLOGY;

            ksprop.NodeProperty.NodeId = localId & PARTID_MASK;

            ksprop.Channel = 0;                             // 0 = Master
channel

 

            // Send the property request.to the device driver.

            ULONG valueSize = 0;

            hr = pKsControl->KsProperty( &ksprop.NodeProperty.Property,
sizeof(ksprop),

                                                        &FreqAttenuationVal,
sizeof(FreqAttenuationVal), &valueSize);

 

 

This in turn causes PC to completely stop responding and restart! If I put
zeros instead of 65536 in array FreqAttenuationVal, the application
continues to work, and PC doesn't restart. By analyzing the USB transactions
on Catalyst Analyzer, I found out that when setting the new Equalizer level
to zeroes, the SET request is sent from the PC, and it contains 5 data
stages, for (I guess) all 30 frequency bands. The problem is however, that
SET request has incorrect data header in it. All header fields are zero,
while they should contain nonzero values of fields such as wLength, and
bmBandsPresent (according to USB Audio Class specification). This basically
renders the SET request obsolete, and it has no effect on the device.

 

I don't understand why this happens. The data received by device is
obviously sent by driver, so I guess the problem is somewhere inside my
application - yet I cannot find the answer where. Hopefully the code above
might give a clue, of what has to be changed in order to achieve the correct
SET Eq level functionality in my application (without PC crashing - in case
of non zero values, or wrong header setting in case of zero values).

 

Thanks in advance for the answers.

 

Bogdan Sataric

  _____  

From: wdmaudiodev-bounce@xxxxxxxxxxxxx
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Frank Yerrace
Sent: 16 December 2009 23:45
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Re: Audio Mixer control applet

 

I'm assuming you are concerned with Windows Vista and 7. If we had created a
Device <http://msdn.microsoft.com/en-us/library/dd370825(VS.85).aspx>
Topology interface for accessing the equalizer then this would have been
easier, but we didn't. So you may be interested in reading this MSDN article
Using <http://msdn.microsoft.com/en-us/library/dd316787(VS.85).aspx>  the
IKsControl Interface to Access Audio Properties. 

 

Frank Yerrace

Microsoft

 

This posting is provided "AS IS" with no warranties, and confers no rights.

 

From: wdmaudiodev-bounce@xxxxxxxxxxxxx
[mailto:wdmaudiodev-bounce@xxxxxxxxxxxxx] On Behalf Of Bogdan Sataric
Sent: Tuesday, December 15, 2009 6:07 AM
To: wdmaudiodev@xxxxxxxxxxxxx
Subject: [wdmaudiodev] Audio Mixer control applet

 

I want to develop an Audio Mixer control applet similar to sndvol32.exe that
Windows XP exposes for my USB Audio device. The device will use the generic
USB audio driver provided by Windows so the idea is to create a GUI for some
advanced settings controlled by standard USB Audio Class 1.0. For example,
my device supports equalizer building block of a feature unit and I would
like to control it via this GUI. I have noticed that USB Audio driver on
Win7 sends the requests for Equalizer but there is no GUI allowing to
control it in Win7 mixer.

Is this possible? Which Windows APIs should I look into? Are there any
examples with similar functionality available? Would it be possible to
register such application so it is loaded instead of sndvol32.exe or the
equivalent on the later OS'?

 

Thanks in advance for the answers.

 

Bogdan Sataric

Other related posts: