From c57e8f14a7aad289c18bd879182e468c78570321 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Sun, 24 Nov 2019 20:30:37 -0800 Subject: GLK: Implement glk_schannel_create_ext --- engines/glk/sound.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'engines/glk/sound.cpp') diff --git a/engines/glk/sound.cpp b/engines/glk/sound.cpp index 4f56ee2add..2c8bf319fa 100644 --- a/engines/glk/sound.cpp +++ b/engines/glk/sound.cpp @@ -46,8 +46,8 @@ void Sounds::removeSound(schanid_t snd) { } } -schanid_t Sounds::create(uint rock) { - schanid_t snd = new SoundChannel(this); +schanid_t Sounds::create(uint rock, uint volume) { + schanid_t snd = new SoundChannel(this, volume); _sounds.push_back(snd); return snd; } @@ -73,8 +73,10 @@ void Sounds::poll() { /*--------------------------------------------------------------------------*/ -SoundChannel::SoundChannel(Sounds *owner) : _owner(owner), _soundNum(0), - _rock(0), _notify(0) { +SoundChannel::SoundChannel(Sounds *owner, uint volume) : _owner(owner), + _soundNum(0), _rock(0), _notify(0) { + _defaultVolume = MIN(volume, (uint)GLK_MAXVOLUME); + if (g_vm->gli_register_obj) _dispRock = (*g_vm->gli_register_obj)(this, gidisp_Class_Schannel); } @@ -145,7 +147,8 @@ uint SoundChannel::play(uint soundNum, uint repeats, uint notify) { } // Start playing the audio - g_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream); + g_vm->_mixer->playStream(Audio::Mixer::kPlainSoundType, &_handle, stream, -1, + _defaultVolume * 255 / GLK_MAXVOLUME); return 0; } @@ -162,7 +165,7 @@ void SoundChannel::poll() { } void SoundChannel::setVolume(uint volume, uint duration, uint notify) { - uint newVol = volume * 255 / 0x10000; + uint newVol = volume * 255 / GLK_MAXVOLUME; g_vm->_mixer->setChannelVolume(_handle, newVol); if (notify) { -- cgit v1.2.3