Added looping background noise to the IHNM intro. I don't know if it's the

correct sound or the correct volume, but the small extension to allow the
engine to start looping sounds is worthwhile enough in itself, I think.

svn-id: r15895
This commit is contained in:
Torbjörn Andersson 2004-11-26 13:28:00 +00:00
parent 41d1be2ea8
commit 66b8bcd7eb
7 changed files with 36 additions and 8 deletions

View File

@ -309,6 +309,11 @@ int Events::handleOneShot(EVENT *event) {
}
break;
case SOUND_EVENT:
_vm->_sound->stopSound();
if (event->op == EVENT_PLAY)
_vm->_sndRes->playSound(event->param, event->param2, event->param3 != 0);
break;
case VOICE_EVENT:
_vm->_sndRes->playVoice(event->param);
break;

View File

@ -339,11 +339,30 @@ int Scene::IHNMHateProc(int param, SCENE_INFO *scene_info) {
q_event = _vm->_events->queue(&event);
// Background sound
event.type = ONESHOT_EVENT;
event.code = SOUND_EVENT;
event.op = EVENT_PLAY;
event.param = 260; // FIXME: Verify sound
event.param2 = 255; // FIXME: Verify volume
event.param3 = SOUND_LOOP;
event.time = 0;
q_event = _vm->_events->queue(&event);
// End background sound after the voice has finished
event.type = ONESHOT_EVENT;
event.code = SOUND_EVENT;
event.op = EVENT_STOP;
event.time = _vm->_sndRes->getVoiceLength(0);
q_event = _vm->_events->chain(q_event, &event);
// End scene after the voice has finished
event.type = ONESHOT_EVENT;
event.code = SCENE_EVENT;
event.op = EVENT_END;
event.time = _vm->_sndRes->getVoiceLength(0);
event.time = 0;
q_event = _vm->_events->chain(q_event, &event);
break;

View File

@ -1156,7 +1156,7 @@ int Script::SF_playSound(SCRIPTFUNC_PARAMS) {
SDataWord_T param = thread->pop() - 13;
if (/* param >= 0 && */ param < ARRAYSIZE(sfxTable))
_vm->_sndRes->playSound(sfxTable[param].res, sfxTable[param].vol);
_vm->_sndRes->playSound(sfxTable[param].res, sfxTable[param].vol, false);
else
_vm->_sound->stopSound();

View File

@ -53,7 +53,7 @@ SndRes::SndRes(SagaEngine *vm) : _vm(vm) {
_init = 1;
}
int SndRes::playSound(uint32 sound_rn, int volume) {
int SndRes::playSound(uint32 sound_rn, int volume, bool loop) {
SOUNDBUFFER snd_buffer;
debug(0, "SndRes::playSound(%ld)", sound_rn);
@ -63,7 +63,7 @@ int SndRes::playSound(uint32 sound_rn, int volume) {
return FAILURE;
}
_vm->_sound->playSound(&snd_buffer, volume);
_vm->_sound->playSound(&snd_buffer, volume, loop);
return SUCCESS;
}

View File

@ -67,7 +67,7 @@ public:
SndRes(SagaEngine *vm);
int loadSound(uint32 sound_rn);
int playSound(uint32 sound_rn, int volume);
int playSound(uint32 sound_rn, int volume, bool loop);
int playVoice(uint32 voice_rn);
int getVoiceLength(uint32 voice_rn);

View File

@ -190,8 +190,8 @@ int Sound::playSoundBuffer(PlayingSoundHandle *handle, SOUNDBUFFER *buf, int vol
return SUCCESS;
}
int Sound::playSound(SOUNDBUFFER *buf, int volume) {
return playSoundBuffer(&_effectHandle, buf, 2 * volume, false);
int Sound::playSound(SOUNDBUFFER *buf, int volume, bool loop) {
return playSoundBuffer(&_effectHandle, buf, 2 * volume, loop);
}
int Sound::pauseSound() {

View File

@ -32,6 +32,10 @@
namespace Saga {
enum SOUND_FLAGS {
SOUND_LOOP = 1
};
struct SOUNDBUFFER {
uint16 s_freq;
int s_samplebits;
@ -48,7 +52,7 @@ public:
Sound(SagaEngine *vm, SoundMixer *mixer, int enabled);
~Sound();
int playSound(SOUNDBUFFER *buf, int volume);
int playSound(SOUNDBUFFER *buf, int volume, bool loop);
int pauseSound();
int resumeSound();
int stopSound();