mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-14 21:59:17 +00:00
PINK: implement sound balance
This commit is contained in:
parent
30b5c30ab2
commit
f11d331129
@ -74,24 +74,28 @@ void ActionPlayWithSfx::updateSound() {
|
||||
|
||||
for (uint i = 0; i < _sfxArray.size(); ++i) {
|
||||
if (_sfxArray[i]->getFrame() == _decoder->getCurFrame())
|
||||
_sfxArray[i]->play(_actor->getPage());
|
||||
_sfxArray[i]->play();
|
||||
}
|
||||
}
|
||||
|
||||
void ActionSfx::deserialize(Pink::Archive &archive) {
|
||||
_frame = archive.readDWORD();
|
||||
_volume = archive.readDWORD();
|
||||
assert(_volume <= 100);
|
||||
_sfxName = archive.readString();
|
||||
archive.readObject(); // pointer of ActionPlayWithSfx
|
||||
_sprite = (ActionPlayWithSfx*) archive.readObject();
|
||||
}
|
||||
|
||||
void ActionSfx::toConsole() {
|
||||
debug("\t\tActionSfx: _sfx = %s, _volume = %u, _frame = %u", _sfxName.c_str(), _volume, _frame);
|
||||
}
|
||||
|
||||
void ActionSfx::play(Page *page) {
|
||||
if (!_sound.isPlaying())
|
||||
_sound.play(page->getResourceStream(_sfxName), Audio::Mixer::kSFXSoundType, _volume);
|
||||
void ActionSfx::play() {
|
||||
Page *page = _sprite->getActor()->getPage();
|
||||
if (!_sound.isPlaying()) {
|
||||
int8 balance = (_sprite->getDecoder()->getX() * 396875 / 1000000) - 127;
|
||||
_sound.play(page->getResourceStream(_sfxName), Audio::Mixer::kSFXSoundType, _volume, balance);
|
||||
}
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -58,11 +58,12 @@ public:
|
||||
|
||||
void toConsole() override;
|
||||
|
||||
void play(Page *page);
|
||||
void play();
|
||||
|
||||
uint32 getFrame() { return _frame; }
|
||||
|
||||
private:
|
||||
ActionPlayWithSfx *_sprite;
|
||||
Common::String _sfxName;
|
||||
Sound _sound;
|
||||
uint32 _volume;
|
||||
|
@ -39,6 +39,7 @@ void ActionSound::deserialize(Archive &archive) {
|
||||
Action::deserialize(archive);
|
||||
_fileName = archive.readString();
|
||||
_volume = archive.readDWORD();
|
||||
assert(_volume <= 100);
|
||||
_isLoop = (bool) archive.readDWORD();
|
||||
_isBackground = (bool) archive.readDWORD();
|
||||
}
|
||||
|
@ -60,7 +60,10 @@ void ActionTalk::pause(bool paused) {
|
||||
|
||||
void ActionTalk::onStart() {
|
||||
ActionPlay::onStart();
|
||||
_sound.play(_actor->getPage()->getResourceStream(_vox), Audio::Mixer::kSpeechSoundType);
|
||||
//sound balance is calculated different than in ActionSfx(probably a bug in original)
|
||||
// 30.0 - x * -0.0625 disasm (0 - 100)
|
||||
int8 balance = (_decoder->getX() * 396875 / 1000000) - 127;
|
||||
_sound.play(_actor->getPage()->getResourceStream(_vox), Audio::Mixer::kSpeechSoundType, 100, balance);
|
||||
}
|
||||
|
||||
} // End of namespace Pink
|
||||
|
@ -45,8 +45,8 @@ protected:
|
||||
void onStart() override;
|
||||
|
||||
private:
|
||||
Sound _sound;
|
||||
Common::String _vox;
|
||||
Sound _sound;
|
||||
};
|
||||
|
||||
} // End of namespace Pink
|
||||
|
Loading…
Reference in New Issue
Block a user