mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-27 05:32:45 +00:00
WINTERMUTE: Limit the range of the panning-variable to stay within [-1,1].
Also, store the panning state, so that the next playback starts with the same pan.
This commit is contained in:
parent
0c570712f1
commit
0c0ed9fdd8
@ -58,6 +58,7 @@ BaseSoundBuffer::BaseSoundBuffer(BaseGame *inGame) : BaseClass(inGame) {
|
||||
_file = nullptr;
|
||||
_privateVolume = 255;
|
||||
_volume = 255;
|
||||
_pan = 0;
|
||||
|
||||
_looping = false;
|
||||
_loopStart = 0;
|
||||
@ -143,9 +144,9 @@ bool BaseSoundBuffer::play(bool looping, uint32 startSample) {
|
||||
_handle = new Audio::SoundHandle;
|
||||
if (_looping) {
|
||||
Audio::AudioStream *loopStream = new Audio::LoopingAudioStream(_stream, 0, DisposeAfterUse::NO);
|
||||
g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, 0, DisposeAfterUse::YES);
|
||||
g_system->getMixer()->playStream(_type, _handle, loopStream, -1, _volume, _pan, DisposeAfterUse::YES);
|
||||
} else {
|
||||
g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, 0, DisposeAfterUse::NO);
|
||||
g_system->getMixer()->playStream(_type, _handle, _stream, -1, _volume, _pan, DisposeAfterUse::NO);
|
||||
}
|
||||
}
|
||||
|
||||
@ -268,8 +269,11 @@ bool BaseSoundBuffer::setLoopStart(uint32 pos) {
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
bool BaseSoundBuffer::setPan(float pan) {
|
||||
pan = MAX(pan, -1.0f);
|
||||
pan = MIN(pan, 1.0f);
|
||||
_pan = (int8)(pan * 127);
|
||||
if (_handle) {
|
||||
g_system->getMixer()->setChannelBalance(*_handle, (int8)(pan * 127));
|
||||
g_system->getMixer()->setChannelBalance(*_handle, _pan);
|
||||
}
|
||||
return STATUS_OK;
|
||||
}
|
||||
|
@ -93,6 +93,7 @@ private:
|
||||
bool _streamed;
|
||||
Common::SeekableReadStream *_file;
|
||||
int32 _volume;
|
||||
int8 _pan;
|
||||
};
|
||||
|
||||
} // End of namespace Wintermute
|
||||
|
Loading…
x
Reference in New Issue
Block a user