• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 220
  • Last Modified:

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...
0
VBDesigns
Asked:
VBDesigns
  • 3
  • 2
1 Solution
 
chensuCommented:
The best way is to use the Win32 Audio Mixer functions. See my article at CodeGuru.

Audio Mixer Functions Demo
http://www.codeguru.com/multimedia/ADMixer.shtml
0
 
chensuCommented:
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.
0
 
seanpalmerCommented:
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);
      }
  }
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
chensuCommented:
Then you have to use Audio Mixer functions because some audio device drivers may not support aux*.
0
 
VBDesignsAuthor Commented:
Trying the aux before the mixer worked great -- thanks!
0
 
seanpalmerCommented:
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!
0

Featured Post

The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now