diff options
-rw-r--r-- | engines/cge/general.cpp | 20 | ||||
-rw-r--r-- | engines/cge/snddrv.h | 6 | ||||
-rw-r--r-- | engines/cge/sound.cpp | 18 | ||||
-rw-r--r-- | engines/cge/sound.h | 9 | ||||
-rw-r--r-- | engines/cge/wav.h | 13 |
5 files changed, 44 insertions, 22 deletions
diff --git a/engines/cge/general.cpp b/engines/cge/general.cpp index b9c10a7029..67068a9673 100644 --- a/engines/cge/general.cpp +++ b/engines/cge/general.cpp @@ -282,14 +282,6 @@ void sndSetVolume() { warning("STUB: SNDSetVolume"); } -void sndDigiStart(SmpInfo *PSmpInfo) { - warning("STUB: SNDDigitStart"); -} - -void sndDigiStop(SmpInfo *PSmpInfo) { - warning("STUB: SNDDigiStop"); -} - void sndMidiStart(uint8 *MIDFile) { warning("STUB: SNDMIDIStart"); } @@ -299,8 +291,10 @@ void sndMidiStop() { } DataCk *loadWave(XFile *file) { - warning("STUB: LoadWave"); - return NULL; + byte *data = (byte *)malloc(file->size()); + file->read(data, file->size()); + + return new DataCk(data, file->size()); } int takeEnum(const char **tab, const char *text) { @@ -331,9 +325,15 @@ int newRandom(int range) { return ((CGEEngine *)g_engine)->_randomSource.getRandomNumber(range - 1); } +DataCk::DataCk(byte *buf, int size) { + _buf = buf; + _ckSize = size; +} + DataCk::~DataCk() { if (_buf) free(_buf); } + } // End of namespace CGE diff --git a/engines/cge/snddrv.h b/engines/cge/snddrv.h index 07c4ccd0dd..44ccf47f94 100644 --- a/engines/cge/snddrv.h +++ b/engines/cge/snddrv.h @@ -73,12 +73,6 @@ void sndDone(); // Set Volume void sndSetVolume(); -// Start Digi -void sndDigiStart(SmpInfo *PSmpInfo); - -// Stop Digi -void sndDigiStop(SmpInfo *PSmpInfo); - // Start MIDI File void sndMidiStart(uint8 *MIDFile); diff --git a/engines/cge/sound.cpp b/engines/cge/sound.cpp index 56db1a6482..2cb24df5ba 100644 --- a/engines/cge/sound.cpp +++ b/engines/cge/sound.cpp @@ -31,11 +31,13 @@ #include "cge/cfile.h" #include "cge/vol.h" #include "cge/cge_main.h" - +#include "common/memstream.h" +#include "audio/decoders/raw.h" namespace CGE { Sound::Sound(CGEEngine *vm) : _vm(vm) { + _audioStream = NULL; open(); } @@ -68,11 +70,25 @@ void Sound::play(DataCk *wav, int pan, int cnt) { } } +void Sound::sndDigiStart(SmpInfo *PSmpInfo) { + // Create an audio stream wrapper for sound + Common::MemoryReadStream *stream = new Common::MemoryReadStream(PSmpInfo->_saddr, + PSmpInfo->_slen, DisposeAfterUse::NO); + _audioStream = Audio::makeWAVStream(stream, DisposeAfterUse::YES); + + // Start the new sound + _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, _audioStream); +} void Sound::stop() { sndDigiStop(&_smpinf); } +void Sound::sndDigiStop(SmpInfo *PSmpInfo) { + if (_vm->_mixer->isSoundHandleActive(_soundHandle)) + _vm->_mixer->stopHandle(_soundHandle); + _audioStream = NULL; +} Fx::Fx(int size) : _current(NULL) { _cache = new Han[size]; diff --git a/engines/cge/sound.h b/engines/cge/sound.h index 292cb30e76..67b16fc888 100644 --- a/engines/cge/sound.h +++ b/engines/cge/sound.h @@ -31,6 +31,10 @@ #include "cge/wav.h" #include "cge/snddrv.h" #include "cge/cge.h" +#include "audio/audiostream.h" +#include "audio/decoders/wave.h" +#include "audio/fmopl.h" +#include "audio/mixer.h" namespace CGE { @@ -45,6 +49,11 @@ public: void stop(); private: CGEEngine *_vm; + Audio::SoundHandle _soundHandle; + Audio::RewindableAudioStream *_audioStream; + + void sndDigiStart(SmpInfo *PSmpInfo); + void sndDigiStop(SmpInfo *PSmpInfo); }; diff --git a/engines/cge/wav.h b/engines/cge/wav.h index bd9fc96b0a..824f40f96f 100644 --- a/engines/cge/wav.h +++ b/engines/cge/wav.h @@ -115,16 +115,19 @@ public: }; -class DataCk : public CkHea { +class DataCk { bool _ef; - uint8 *_buf; + byte *_buf; + int _ckSize; public: - DataCk(CkHea &hea); - DataCk(int first, int last); + DataCk(byte *buf, int size); ~DataCk(); - inline uint8 *addr() { + inline const byte *addr() { return _buf; } + inline int size() { + return _ckSize; + } }; |