mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-31 07:53:36 +00:00
AUDIO: Add complementary functions for getting channel volume and balance
This commit is contained in:
parent
eea48434f5
commit
eb13803709
@ -93,6 +93,13 @@ public:
|
||||
*/
|
||||
void setVolume(const byte volume);
|
||||
|
||||
/**
|
||||
* Gets the channel's own volume.
|
||||
*
|
||||
* @return volume
|
||||
*/
|
||||
byte getVolume();
|
||||
|
||||
/**
|
||||
* Sets the channel's balance setting.
|
||||
*
|
||||
@ -100,6 +107,13 @@ public:
|
||||
*/
|
||||
void setBalance(const int8 balance);
|
||||
|
||||
/**
|
||||
* Gets the channel's balance setting.
|
||||
*
|
||||
* @return balance
|
||||
*/
|
||||
int8 getBalance();
|
||||
|
||||
/**
|
||||
* Notifies the channel that the global sound type
|
||||
* volume settings changed.
|
||||
@ -342,6 +356,14 @@ void MixerImpl::setChannelVolume(SoundHandle handle, byte volume) {
|
||||
_channels[index]->setVolume(volume);
|
||||
}
|
||||
|
||||
byte MixerImpl::getChannelVolume(SoundHandle handle) {
|
||||
const int index = handle._val % NUM_CHANNELS;
|
||||
if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
|
||||
return 0;
|
||||
|
||||
return _channels[index]->getVolume();
|
||||
}
|
||||
|
||||
void MixerImpl::setChannelBalance(SoundHandle handle, int8 balance) {
|
||||
Common::StackLock lock(_mutex);
|
||||
|
||||
@ -352,6 +374,14 @@ void MixerImpl::setChannelBalance(SoundHandle handle, int8 balance) {
|
||||
_channels[index]->setBalance(balance);
|
||||
}
|
||||
|
||||
int8 MixerImpl::getChannelBalance(SoundHandle handle) {
|
||||
const int index = handle._val % NUM_CHANNELS;
|
||||
if (!_channels[index] || _channels[index]->getHandle()._val != handle._val)
|
||||
return 0;
|
||||
|
||||
return _channels[index]->getBalance();
|
||||
}
|
||||
|
||||
uint32 MixerImpl::getSoundElapsedTime(SoundHandle handle) {
|
||||
return getElapsedTime(handle).msecs();
|
||||
}
|
||||
@ -482,11 +512,19 @@ void Channel::setVolume(const byte volume) {
|
||||
updateChannelVolumes();
|
||||
}
|
||||
|
||||
byte Channel::getVolume() {
|
||||
return _volume;
|
||||
}
|
||||
|
||||
void Channel::setBalance(const int8 balance) {
|
||||
_balance = balance;
|
||||
updateChannelVolumes();
|
||||
}
|
||||
|
||||
int8 Channel::getBalance() {
|
||||
return _balance;
|
||||
}
|
||||
|
||||
void Channel::updateChannelVolumes() {
|
||||
// From the channel balance/volume and the global volume, we compute
|
||||
// the effective volume for the left and right channel. Note the
|
||||
|
@ -210,6 +210,14 @@ public:
|
||||
*/
|
||||
virtual void setChannelVolume(SoundHandle handle, byte volume) = 0;
|
||||
|
||||
/**
|
||||
* Get the channel volume for the given handle.
|
||||
*
|
||||
* @param handle the sound to affect
|
||||
* @return channel volume
|
||||
*/
|
||||
virtual byte getChannelVolume(SoundHandle handle) = 0;
|
||||
|
||||
/**
|
||||
* Set the channel balance for the given handle.
|
||||
*
|
||||
@ -219,6 +227,14 @@ public:
|
||||
*/
|
||||
virtual void setChannelBalance(SoundHandle handle, int8 balance) = 0;
|
||||
|
||||
/**
|
||||
* Get the channel balance for the given handle.
|
||||
*
|
||||
* @param handle the sound to affect
|
||||
* @return channel balance
|
||||
*/
|
||||
virtual int8 getChannelBalance(SoundHandle handle) = 0;
|
||||
|
||||
/**
|
||||
* Get approximation of for how long the channel has been playing.
|
||||
*/
|
||||
|
@ -105,7 +105,9 @@ public:
|
||||
virtual bool isSoundTypeMuted(SoundType type) const;
|
||||
|
||||
virtual void setChannelVolume(SoundHandle handle, byte volume);
|
||||
virtual byte getChannelVolume(SoundHandle handle);
|
||||
virtual void setChannelBalance(SoundHandle handle, int8 balance);
|
||||
virtual int8 getChannelBalance(SoundHandle handle);
|
||||
|
||||
virtual uint32 getSoundElapsedTime(SoundHandle handle);
|
||||
virtual Timestamp getElapsedTime(SoundHandle handle);
|
||||
|
Loading…
x
Reference in New Issue
Block a user