views:

1047

answers:

2

When I run this code:

MIXERLINE MixerLine;
memset( &MixerLine, 0, sizeof(MIXERLINE) );
MixerLine.cbStruct = sizeof(MIXERLINE);
MixerLine.dwComponentType = MIXERLINE_COMPONENTTYPE_SRC_WAVEOUT;
mmResult = mixerGetLineInfo( (HMIXEROBJ)m_dwMixerHandle, &MixerLine, MIXER_GETLINEINFOF_COMPONENTTYPE );

Under XP MixerLine.cChannels comes back as the number of channels that the sound card supports. Often 2, these days often many more.

Under Vista MixerLine.cChannels comes back as one.

I have been then getting a MIXERCONTROL_CONTROLTYPE_VOLUME control and setting the volume for each channel that is supported, and setting the volumne control to different levels on different channels so as to pan music back and forth between the speakers (left to right).

Obviously under Vista this approach isn't working since there is only one channel. I can set the volume and it is for both channels at the same time.

I tried to get a MIXERCONTROL_CONTROLTYPE_PAN for this device, but that was not a valid control.

So, the question for all you MMSystem experts is this: what type of control do I need to get to adjust the left/right balance? Alternately, is there a better way? I would like a solution that works with both XP and Vista.

Computer Details: Running Vista Ultimta 32 bit SP1 and all latest patches. Audio is provided by a Creative Audigy 2 ZS card with 4 speakers attached which can all be properly addressed (controlled) through Vista's sound panel. Driver is latest on Creative's site (SBAX_PCDRV_LB_2_18_0001). The Vista sound is not set to mono, and all channels are visable and controlable from the sound panel.

Running the program in "XP Compatibility Mode" does not change the behaviour of this problem.

A: 

Long time Microsoftie Larry Osterman has a blog where he discusses issues like this because he was on the team that redid all the audio stuff in Vista.

In the comments to this blog post he seems to indicate that application controlled balance is not something they see the need for:

CN, actually we're not aware of ANY situations in which it's appropriate for an application to control its balance. Having said that, we do support individual channel volumes for applications, but it is STRONGLY recommended that apps don't use it.

He also indicates that panning the sound from one side to the other can be done, but it is dependent on whether the hardware supports it:

Joku, we're exposing the volume controls that the audio solution implements. If it can do pan, we do pan (we actually expose separate sliders for the left and right channels).

So that explains why the MIXERCONTROL_CONTROLTYPE_PAN thing failed -- the audio hardware on your system does not support it.

Tim Farley
+1  A: 

If you run your application in "XP compatibility" mode, the mixer APIs should work much closer to the way they did in XP.

If you're not running in XP mode, then the mixer APIs reflect the mix format - if your PC's audio solution is configured for mono, then you'll see only one channel, but if you're machine is configured for multichannel output the mixer APIs should reflect that.

You can run the speaker tuning wizard to determine the # of channels configured for your audio solution.

Larry Osterman