DsVolume OpenALAudio::get_loop_wav_volume(int id) { StreamContext *sc; StreamMap::const_iterator itr; float position[3]; float gain; if (!this->wav_init_flag) return DsVolume(0, 0); itr = this->streams.find(id); if (itr == this->streams.end()) return DsVolume(0, 0); sc = itr->second; alGetSourcef(sc->source, AL_GAIN, &gain); alGetSourcefv(sc->source, AL_POSITION, position); if (sc->fade_frames != 0) gain *= 1.f - float(sc->fade_frames_played) / sc->fade_frames; return DsVolume(ratio_to_millibels(gain), (long)((position[0] / PANNING_MAX_X) * 10000.f + .5f)); // (long) cast fixes warning. }
// -------- begin of function Music::change_volume --------// void Music::change_volume(int vol) { if( !init_flag ) return; if( is_playing() ) { AbsVolume absv(vol,0); audio.volume_long_wav(music_channel, DsVolume(absv)); } }
// -------- begin of function Music::change_volume --------// void Music::change_volume(int vol) { if( !init_flag ) return; if( is_playing() ) { if( play_type & MUSIC_PLAY_CD ) { audio.set_cd_volume(vol); } else { AbsVolume absv(vol,0); audio.volume_long_wav(music_channel, DsVolume(absv)); } } }