diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/draci/sound.cpp | 5 | ||||
-rw-r--r-- | engines/m4/sound.cpp | 17 | ||||
-rw-r--r-- | engines/scumm/sound.cpp | 23 | ||||
-rw-r--r-- | engines/sky/sound.cpp | 9 | ||||
-rw-r--r-- | engines/sword1/sound.cpp | 4 |
5 files changed, 37 insertions, 21 deletions
diff --git a/engines/draci/sound.cpp b/engines/draci/sound.cpp index d593437cf6..4617cd5c6f 100644 --- a/engines/draci/sound.cpp +++ b/engines/draci/sound.cpp @@ -35,6 +35,7 @@ #include "sound/audiostream.h" #include "sound/mixer.h" +#include "sound/raw.h" namespace Draci { @@ -203,8 +204,8 @@ void Sound::playSoundBuffer(Audio::SoundHandle *handle, const SoundSample &buffe Audio::Mixer::kSpeechSoundType : Audio::Mixer::kSFXSoundType; // Don't use DisposeAfterUse::YES, because our caching system deletes samples by itself. - _mixer->playRaw(soundType, handle, buffer._data, - buffer._length, DisposeAfterUse::NO, buffer._frequency, flags, -1, volume); + Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer._data, buffer._length, DisposeAfterUse::NO, buffer._frequency, flags, 0, 0); + _mixer->playInputStream(soundType, handle, stream, -1, volume); } void Sound::playSound(const SoundSample *buffer, int volume, bool loop) { diff --git a/engines/m4/sound.cpp b/engines/m4/sound.cpp index ecc3ff6567..e9e1726dc3 100644 --- a/engines/m4/sound.cpp +++ b/engines/m4/sound.cpp @@ -27,9 +27,11 @@ #include "m4/sound.h" #include "m4/compression.h" +#include "common/stream.h" + #include "sound/audiostream.h" #include "sound/mixer.h" -#include "common/stream.h" +#include "sound/raw.h" namespace M4 { @@ -96,7 +98,8 @@ void Sound::playSound(const char *soundName, int volume, bool loop, int channel) _vm->res()->toss(soundName); // Sound format is 8bit mono, unsigned, 11025kHz - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, bufferSize, DisposeAfterUse::YES, 11025, flags, -1, volume); + Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, bufferSize, DisposeAfterUse::YES, 11025, flags, 0, 0); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume); } void Sound::pauseSound() { @@ -139,7 +142,7 @@ void Sound::playVoice(const char *soundName, int volume) { SndHandle *handle = getHandle(); byte *buffer; - buffer = new byte[soundStream->size()]; + buffer = (byte *)malloc(soundStream->size()); soundStream->read(buffer, soundStream->size()); handle->type = kEffectHandle; @@ -148,7 +151,8 @@ void Sound::playVoice(const char *soundName, int volume) { _vm->res()->toss(soundName); // Voice format is 8bit mono, unsigned, 11025kHz - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, soundStream->size(), DisposeAfterUse::YES, 11025, flags, -1, volume); + Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, soundStream->size(), DisposeAfterUse::YES, 11025, flags); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume); } void Sound::pauseVoice() { @@ -264,9 +268,10 @@ void Sound::playDSRSound(int soundIndex, int volume, bool loop) { buffer, _dsrFile.dsrEntries[soundIndex]->uncompSize); // Play sound - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &handle->handle, buffer, + Audio::AudioStream *stream = Audio::makeRawMemoryStream(buffer, _dsrFile.dsrEntries[soundIndex]->uncompSize, DisposeAfterUse::YES, - _dsrFile.dsrEntries[soundIndex]->frequency, flags, -1, volume); + _dsrFile.dsrEntries[soundIndex]->frequency, flags, 0, 0); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &handle->handle, stream, -1, volume); /* // Dump the sound file diff --git a/engines/scumm/sound.cpp b/engines/scumm/sound.cpp index 7b6975b818..4206ff80d9 100644 --- a/engines/scumm/sound.cpp +++ b/engines/scumm/sound.cpp @@ -41,6 +41,7 @@ #include "sound/mididrv.h" #include "sound/mixer.h" #include "sound/mp3.h" +#include "sound/raw.h" #include "sound/voc.h" #include "sound/vorbis.h" #include "sound/wave.h" @@ -159,7 +160,8 @@ void Sound::processSoundQueues() { void Sound::playSound(int soundID) { byte *ptr; - char *sound; + byte *sound; + Audio::AudioStream *stream; int size = -1; int rate; byte flags = Audio::Mixer::FLAG_UNSIGNED; @@ -199,7 +201,7 @@ void Sound::playSound(int soundID) { ptr += 0x72; // Allocate a sound buffer, copy the data into it, and play - sound = (char *)malloc(size); + sound = (byte *)malloc(size); memcpy(sound, ptr, size); _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID); } @@ -221,7 +223,7 @@ void Sound::playSound(int soundID) { ptr += 0x26; // Allocate a sound buffer, copy the data into it, and play - sound = (char *)malloc(size); + sound = (byte *)malloc(size); memcpy(sound, ptr, size); _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID); } @@ -292,7 +294,7 @@ void Sound::playSound(int soundID) { assert(voc_block_hdr.pack == 0); // Allocate a sound buffer, copy the data into it, and play - sound = (char *)malloc(size); + sound = (byte *)malloc(size); memcpy(sound, ptr + 6, size); _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, flags, soundID); } @@ -334,9 +336,9 @@ void Sound::playSound(int soundID) { warning("Wrong wave size in sound #%i: %i", soundID, waveSize); waveSize = size; } - sound = (char *)malloc(waveSize); + sound = (byte *)malloc(waveSize); for (int x = 0; x < waveSize; x++) { - int b = *ptr++; + byte b = *ptr++; if (b < 0x80) sound[x] = 0x7F - b; else @@ -347,7 +349,8 @@ void Sound::playSound(int soundID) { if (loopEnd > 0) flags |= Audio::Mixer::FLAG_LOOP; - _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, waveSize, DisposeAfterUse::YES, rate, flags, soundID, 255, 0, loopStart, loopEnd); + stream = Audio::makeRawMemoryStream(sound, waveSize, DisposeAfterUse::YES, rate, flags, loopStart, loopEnd); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, 255, 0); } break; case 1: @@ -424,7 +427,7 @@ void Sound::playSound(int soundID) { assert(size); rate = 3579545 / READ_BE_UINT16(ptr + 20); - sound = (char *)malloc(size); + sound = (byte *)malloc(size); int vol = ptr[24] * 4; int loopStart = 0, loopEnd = 0; int loopcount = ptr[27]; @@ -439,8 +442,8 @@ void Sound::playSound(int soundID) { } memcpy(sound, ptr + READ_BE_UINT16(ptr + 8), size); - _mixer->playRaw(Audio::Mixer::kSFXSoundType, NULL, sound, size, DisposeAfterUse::YES, rate, - flags, soundID, vol, 0, loopStart, loopEnd); + stream = Audio::makeRawMemoryStream(sound, size, DisposeAfterUse::YES, rate, flags, loopStart, loopEnd); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, NULL, stream, soundID, vol, 0); } else { diff --git a/engines/sky/sound.cpp b/engines/sky/sound.cpp index f46b40be86..cf5dc78c21 100644 --- a/engines/sky/sound.cpp +++ b/engines/sky/sound.cpp @@ -33,6 +33,8 @@ #include "sky/sound.h" #include "sky/struc.h" +#include "sound/raw.h" + namespace Sky { #define SOUND_FILE_BASE 60203 @@ -1115,10 +1117,13 @@ void Sound::playSound(uint16 sound, uint16 volume, uint8 channel) { flags |= Audio::Mixer::FLAG_LOOP; } + + Audio::AudioStream *stream = Audio::makeRawMemoryStream(_soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, loopSta, loopEnd); + if (channel == 0) - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound0, _soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, SOUND_CH0, volume, 0, loopSta, loopEnd); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_ingameSound0, stream, SOUND_CH0, volume, 0); else - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &_ingameSound1, _soundData + dataOfs, dataSize, DisposeAfterUse::NO, sampleRate, flags, SOUND_CH1, volume, 0, loopSta, loopEnd); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &_ingameSound1, stream, SOUND_CH1, volume, 0); } void Sound::fnStartFx(uint32 sound, uint8 channel) { diff --git a/engines/sword1/sound.cpp b/engines/sword1/sound.cpp index e253483429..1c471a8de1 100644 --- a/engines/sword1/sound.cpp +++ b/engines/sword1/sound.cpp @@ -38,6 +38,7 @@ #include "sound/flac.h" #include "sound/mp3.h" +#include "sound/raw.h" #include "sound/vorbis.h" #include "sound/wave.h" #include "sound/vag.h" @@ -271,7 +272,8 @@ void Sound::playSample(QueueElement *elem) { flags |= Audio::Mixer::FLAG_STEREO; if (_fxList[elem->id].type == FX_LOOP) flags |= Audio::Mixer::FLAG_LOOP; - _mixer->playRaw(Audio::Mixer::kSFXSoundType, &elem->handle, sampleData + 0x2C, size, DisposeAfterUse::NO, 11025, flags, elem->id, volume, pan, 0, 0); + Audio::AudioStream *stream = Audio::makeRawMemoryStream(sampleData + 0x2C, size, DisposeAfterUse::NO, 11025, flags, 0, 0); + _mixer->playInputStream(Audio::Mixer::kSFXSoundType, &elem->handle, stream, elem->id, volume, pan); } } } else |