Game Development Community

Problem with Audio

by Anthony Rosenbaum · in Torque Game Engine · 07/20/2003 (6:28 pm) · 4 replies

In common/clients/audio.cs

we were doing some tests on the channels to make sure things get set we put into OpenAlInit()
for (%channel=1; %channel <= 8; %channel++)
         {
           %volume = $pref::Audio::channelVolume[%channel];
           alxSetChannelVolume(%channel, %volume);
           echo("Audio Volume Init. Channel " @ %channel @ " set to " @ %volume);
           echo("Actual channel volume is now: " @ alxGetChannelVolume(%channel));
         }
but the console reads
Quote:
Audio Volume Init. Channel 1 set to 0.8
Actual channel volume is now: 0
Audio Volume Init. Channel 2 set to 0.8
Actual channel volume is now: 0
Audio Volume Init. Channel 3 set to 0.8
Actual channel volume is now: 0
Audio Volume Init. Channel 4 set to 0.8
Actual channel volume is now: 0
Audio Volume Init. Channel 5 set to 0.8
Actual channel volume is now: 0
Audio Volume Init. Channel 6 set to 0.8
Actual channel volume is now: 0
Audio Volume Init. Channel 7 set to 0.8
Actual channel volume is now: 0
Audio Volume Init. Channel 8 set to 0.8
Actual channel volume is now: 0

so I checked the hard code and noticed this in audioFunctions.cc

//--------------------------------------------------------------------------
// Channel Volumes
//--------------------------------------------------------------------------
ConsoleFunction(alxGetChannelVolume, S32, 2, 2, "alxGetChannelVolume(channel_id)")
{
   U32 type = dAtoi(argv[1]);
   if(type >= Audio::NumAudioTypes)
   {
      Con::errorf(ConsoleLogEntry::General, "alxGetChannelVolume: invalid channel '%d'", dAtoi(argv[1]));
      return(0.f);
   }

   return(mAudioTypeVolume[type]);
}

//-----------------------------------------------
ConsoleFunction(alxSetChannelVolume, bool, 3, 3, "alxGetChannelVolume(channel_id, volume 0.0-1.0)")
{
   U32 type = dAtoi(argv[1]);
   F32 volume = mClampF(dAtof(argv[2]), 0.f, 1.f);

   if(type >= Audio::NumAudioTypes)
   {
      Con::errorf(ConsoleLogEntry::General, "alxSetChannelVolume: channel '%d' out of range [0, %d]", dAtoi(argv[1]), Audio::NumAudioTypes);
      return false;
   }

   mAudioTypeVolume[type] = volume;
   alxUpdateTypeGain(type);
   return true;
}
this second Console function , alxSetChannelVolume() seems to have a typo, but if I correct it (by changing the alxGetChannelVolume to alxSetChannelVolume) nothing happens. If I try in it's origial state and call the alxSetChannelVolume() by actually calling alxGetChannelVolume() with 2 augments I get and error. Needless to say the console functions confuse me can anyone help? IS THIS A BUG?

#1
11/01/2005 (11:49 am)
Apparently this function isn't valid....i looked for the function that the optionsDlg uses when setting channel volumes and they use :

OptAudioUpdateChannelVolume(%channel, %volume);

valid channels are 1-8.

the starter mods use 1,2, and 3 for gui,sim, and message channel volumes.
#2
11/02/2005 (2:24 pm)
Its more like a bug
change the S32 to F32 in the ConsoleFunction then you get the right value.
#3
11/02/2005 (3:59 pm)
Good call, Billy. Thanks for bringing this issue up, guys! I've put the fix into trunk. #685.
#4
11/02/2005 (4:07 pm)
Good eye Billy!