Link to home
Start Free TrialLog in
Avatar of VBDesigns
VBDesigns

asked on

Best way to change CD Volume?

What is the best way to change the CD Audio volume via API?

Right now, we're using the MCI mixer and setting the CD Audio -- however, it changes the WAV volume and not the CD volume on many cards, so it's not the best solution...
ASKER CERTIFIED SOLUTION
Avatar of chensu
chensu
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Another simple way is to use auxGetNumDevs and auxGetDevCaps to find out the CD Audio device (wTechnology of AUXCAPS == AUXCAPS_CDAUDIO and (dwSupport of AUXCAPS & AUXCAPS_VOLUME) != 0). Then use auxSetVolume.
Avatar of seanpalmer
seanpalmer

Ok, I tried that, and now auxGetNumDevs is returning 0.

I don't think that's supposed to happen (I have a Sound Blaster Live Value installed, otherwise working properly) but it does seem to be par for the course in this wacky maze of audio api's.  ;)

Any other ideas?

Here's the code I have so far:

  DWORD dwReturn=MMSYSERR_BADDEVICEID;
  int i=auxGetNumDevs();
  AUXCAPS caps;
  for (; --i>=0; ) {
    if (MMSYSERR_NOERROR==auxGetDevCaps(i,&caps,sizeof(caps)))
      if (caps.wTechnology==AUXCAPS_CDAUDIO && 
          (caps.dwSupport&AUXCAPS_VOLUME)!=0) {
        uint v16=(vol<<9)|(vol<<2)|(vol>>5); // (vol*65535)/127
        dwReturn=auxSetVolume(i,(v16<<16)|v16);
      }
  }
Then you have to use Audio Mixer functions because some audio device drivers may not support aux*.
Avatar of VBDesigns

ASKER

Trying the aux before the mixer worked great -- thanks!
Also I think I was misusing the MIXERLINECONTROLS.dwLineID field by putting the wrong kind of index into it.  I believe that may solve the other problem (of mixer method adjusting wave volume instead of cd volume)

This stuff is not documented very well... looking at your examples proved to be fruitful.  Thanks alot!