diff options
Diffstat (limited to 'sound')
| -rw-r--r-- | sound/adpcm.cpp | 41 | ||||
| -rw-r--r-- | sound/adpcm.h | 34 | ||||
| -rw-r--r-- | sound/wave.cpp | 2 |
3 files changed, 42 insertions, 35 deletions
diff --git a/sound/adpcm.cpp b/sound/adpcm.cpp index 32ea6dc6eb..b1270d9220 100644 --- a/sound/adpcm.cpp +++ b/sound/adpcm.cpp @@ -23,7 +23,42 @@ #include "common/stdafx.h" #include "sound/adpcm.h" - +#include "sound/audiostream.h" + + +// TODO: Switch from a SeekableReadStream to a plain ReadStream. This requires +// some internal refactoring but is definitely possible and will increase the +// flexibility of this code. +class ADPCMInputStream : public AudioStream { +private: + Common::SeekableReadStream *_stream; + uint32 _endpos; + int _channels; + typesADPCM _type; + uint32 _blockAlign; + + struct adpcmStatus { + int32 last; + int32 stepIndex; + } _status; + + int16 stepAdjust(byte); + int16 decodeOKI(byte); + int16 decodeMSIMA(byte); + +public: + ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0); + ~ADPCMInputStream() {}; + + int readBuffer(int16 *buffer, const int numSamples); + int readBufferOKI(int16 *buffer, const int numSamples); + int readBufferMSIMA1(int16 *buffer, const int numSamples); + int readBufferMSIMA2(int16 *buffer, const int numSamples); + + bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); } + bool isStereo() const { return false; } + int getRate() const { return 22050; } +}; // Routines to convert 12 bit linear samples to the // Dialogic or Oki ADPCM coding format aka VOX. @@ -205,3 +240,7 @@ int16 ADPCMInputStream::decodeMSIMA(byte code) { return samp; } + +AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels, uint32 blockAlign) { + return new ADPCMInputStream(stream, size, type, channels, blockAlign); +} diff --git a/sound/adpcm.h b/sound/adpcm.h index ac24805eff..aea1beaf60 100644 --- a/sound/adpcm.h +++ b/sound/adpcm.h @@ -26,7 +26,6 @@ #include "common/stdafx.h" #include "common/scummsys.h" #include "common/stream.h" -#include "sound/audiostream.h" class AudioStream; @@ -35,38 +34,7 @@ enum typesADPCM { kADPCMIma }; -// TODO: Switch from a SeekableReadStream to a plain ReadStream. This requires -// some internal refactoring but is definitely possible and will increase the -// flexibility of this code. -class ADPCMInputStream : public AudioStream { -private: - Common::SeekableReadStream *_stream; - uint32 _endpos; - int _channels; - typesADPCM _type; - uint32 _blockAlign; +AudioStream *makeADPCMStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0); - struct adpcmStatus { - int32 last; - int32 stepIndex; - } _status; - - int16 stepAdjust(byte); - int16 decodeOKI(byte); - int16 decodeMSIMA(byte); - -public: - ADPCMInputStream(Common::SeekableReadStream *stream, uint32 size, typesADPCM type, int channels = 2, uint32 blockAlign = 0); - ~ADPCMInputStream() {}; - - int readBuffer(int16 *buffer, const int numSamples); - int readBufferOKI(int16 *buffer, const int numSamples); - int readBufferMSIMA1(int16 *buffer, const int numSamples); - int readBufferMSIMA2(int16 *buffer, const int numSamples); - - bool endOfData() const { return (_stream->eos() || _stream->pos() >= _endpos); } - bool isStereo() const { return false; } - int getRate() const { return 22050; } -}; #endif diff --git a/sound/wave.cpp b/sound/wave.cpp index 0923c60c47..f6ba3fed27 100644 --- a/sound/wave.cpp +++ b/sound/wave.cpp @@ -165,7 +165,7 @@ AudioStream *makeWAVStream(Common::SeekableReadStream &stream) { return 0; if (type == 17) // IMA ADPCM - return new ADPCMInputStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1); + return makeADPCMStream(&stream, size, kADPCMIma, (flags & Audio::Mixer::FLAG_STEREO) ? 2 : 1); byte *data = (byte *)malloc(size); assert(data); |
