1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 #ifndef TINSEL_ADPCM_H 24 #define TINSEL_ADPCM_H 25 26 #include "audio/decoders/adpcm_intern.h" 27 28 namespace Tinsel { 29 30 class Tinsel_ADPCMStream : public Audio::ADPCMStream { 31 protected: 32 struct { 33 // Tinsel 34 double predictor; 35 double K0, K1; 36 double d0, d1; 37 } _status; 38 reset()39 void reset() { 40 ADPCMStream::reset(); 41 memset(&_status, 0, sizeof(_status)); 42 } 43 44 int16 decodeTinsel(int16, double); 45 void readBufferTinselHeader(); 46 47 public: Tinsel_ADPCMStream(Common::SeekableReadStream * stream,DisposeAfterUse::Flag disposeAfterUse,uint32 size,int rate,int channels,uint32 blockAlign)48 Tinsel_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) 49 : ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { 50 51 if (blockAlign == 0) 52 error("Tinsel_ADPCMStream(): blockAlign isn't specified"); 53 54 if (channels != 1) 55 error("Tinsel_ADPCMStream(): Tinsel ADPCM only supports mono"); 56 57 memset(&_status, 0, sizeof(_status)); 58 } 59 60 }; 61 62 class Tinsel4_ADPCMStream : public Tinsel_ADPCMStream { 63 public: Tinsel4_ADPCMStream(Common::SeekableReadStream * stream,DisposeAfterUse::Flag disposeAfterUse,uint32 size,int rate,int channels,uint32 blockAlign)64 Tinsel4_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) 65 : Tinsel_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {} 66 67 virtual int readBuffer(int16 *buffer, const int numSamples); 68 }; 69 70 class Tinsel6_ADPCMStream : public Tinsel_ADPCMStream { 71 protected: 72 uint8 _chunkPos; 73 uint16 _chunkData; 74 reset()75 void reset() { 76 ADPCMStream::reset(); 77 _chunkPos = 0; 78 _chunkData = 0; 79 } 80 81 public: Tinsel6_ADPCMStream(Common::SeekableReadStream * stream,DisposeAfterUse::Flag disposeAfterUse,uint32 size,int rate,int channels,uint32 blockAlign)82 Tinsel6_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) 83 : Tinsel_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) { 84 _chunkPos = 0; 85 _chunkData = 0; 86 } 87 88 virtual int readBuffer(int16 *buffer, const int numSamples); 89 }; 90 91 class Tinsel8_ADPCMStream : public Tinsel_ADPCMStream { 92 public: Tinsel8_ADPCMStream(Common::SeekableReadStream * stream,DisposeAfterUse::Flag disposeAfterUse,uint32 size,int rate,int channels,uint32 blockAlign)93 Tinsel8_ADPCMStream(Common::SeekableReadStream *stream, DisposeAfterUse::Flag disposeAfterUse, uint32 size, int rate, int channels, uint32 blockAlign) 94 : Tinsel_ADPCMStream(stream, disposeAfterUse, size, rate, channels, blockAlign) {} 95 96 virtual int readBuffer(int16 *buffer, const int numSamples); 97 }; 98 99 100 } // End of namespace Tinsel 101 102 #endif 103