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 MADE_SOUND_H 24 #define MADE_SOUND_H 25 26 #include "common/array.h" 27 28 namespace Made { 29 30 class ManholeEgaSoundDecompressor { 31 public: 32 void decompress(byte *source, byte *dest, uint32 size); 33 protected: 34 byte *_source, *_dest; 35 uint32 _size; 36 uint16 _bitBuffer; 37 int _bitsLeft; 38 int32 _sample1, _sample2, _sample3, _sample4; 39 bool _writeFlag; 40 bool _eof; 41 int _mode; 42 int getBit(); 43 void update0(); 44 void update1(); 45 void update2(); 46 void update3(); 47 }; 48 49 struct SoundEnergyItem { 50 uint32 position; 51 byte energy; 52 }; 53 54 typedef Common::Array<SoundEnergyItem> SoundEnergyArray; 55 56 57 // Persistent data for decompressSound(). When calling decompressSound() 58 // repeatedly (for the same stream), pass the same SoundDecoderData object to 59 // ensure decoding properly resumes. 60 class SoundDecoderData { 61 public: SoundDecoderData()62 SoundDecoderData() { 63 memset(_soundBuffer, 0x80, sizeof(_soundBuffer)); 64 _prevSample = 0; 65 } 66 67 byte _soundBuffer[1025]; 68 int16 _prevSample; 69 }; 70 71 void decompressSound(byte *source, byte *dest, uint16 chunkSize, uint16 chunkCount, SoundEnergyArray *soundEnergyArray = NULL, SoundDecoderData *decoderData = NULL); 72 73 } // End of namespace Made 74 75 #endif /* MADE_H */ 76