/** * @brief Sets the volume. */ int music_al_volume( double vol ) { soundLock(); music_vol = vol; /* only needed if playing */ if (music_al_isPlaying()) { alSourcef( music_source, AL_GAIN, vol ); /* Check for errors. */ al_checkErr(); } soundUnlock(); return 0; }
/** * @brief Sets the volume. */ int music_al_volume( double vol ) { soundLock(); music_vol_lin = vol; if (vol > 0.) /* Floor of -48 dB (0.00390625 amplitude) */ music_vol = 1 / pow(2, (1 - vol) * 8 ); else music_vol = 0.; /* only needed if playing */ if (music_al_isPlaying()) { alSourcef( music_source, AL_GAIN, music_vol ); /* Check for errors. */ al_checkErr(); } soundUnlock(); return 0; }