Skip to content

Commit

Permalink
Fixed (dsdirectsound): Linear to logarithmic sound effect volume tran…
Browse files Browse the repository at this point in the history
…slation which resulted in no audible sound if both 3D sound positioning was enabled and the Doomsday sound effects volume control was lower than maximum volume.
  • Loading branch information
danij committed Feb 1, 2009
1 parent 165cf97 commit ab02ea0
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions doomsday/plugins/directsound/src/driver_directsound.cpp
Expand Up @@ -757,7 +757,8 @@ static int volLinearToLog(float vol)
return DSBVOLUME_MAX;

// Straighten the volume curve.
return MIN_OF(DSBVOLUME_MIN, (int) (100 * 20 * log10(vol)));
return MINMAX_OF(DSBVOLUME_MIN, (int) (100 * 20 * log10(vol)),
DSBVOLUME_MAX);
}

/**
Expand Down Expand Up @@ -799,12 +800,17 @@ Con_Error("dsDS9::DS_DSoundSet: Unknown prop %i.", prop);
break;

case SFXBP_VOLUME:
{
LONG volume;

if(value <= 0) // Use logarithmic attenuation.
DSBUF(buf)->SetVolume((LONG) ((-1 - value) * 10000));
volume = (LONG) ((-1 - value) * 10000);
else // Linear volume.
DSBUF(buf)->SetVolume(volLinearToLog(value));
break;
volume = (LONG) volLinearToLog(value);

DSBUF(buf)->SetVolume(volume);
break;
}
case SFXBP_FREQUENCY:
{
unsigned int freq = (unsigned int) (buf->rate * value);
Expand Down

0 comments on commit ab02ea0

Please sign in to comment.