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 /**
24  * @file
25  * Sound decoder used in engines:
26  *  - agos
27  *  - lastexpress
28  *  - mohawk
29  *  - saga
30  *  - scumm
31  *  - tinsel
32  */
33 
34 #ifndef AUDIO_ADPCM_H
35 #define AUDIO_ADPCM_H
36 
37 #include "common/scummsys.h"
38 #include "common/types.h"
39 
40 namespace Common {
41 class SeekableReadStream;
42 }
43 
44 
45 namespace Audio {
46 
47 class PacketizedAudioStream;
48 class SeekableAudioStream;
49 
50 // There are several types of ADPCM encoding, only some are supported here
51 // For all the different encodings, refer to:
52 // http://wiki.multimedia.cx/index.php?title=Category:ADPCM_Audio_Codecs
53 // Usually, if the audio stream we're trying to play has the FourCC header
54 // string intact, it's easy to discern which encoding is used
55 enum ADPCMType {
56 	kADPCMOki,                 // Dialogic/Oki ADPCM (aka VOX)
57 	kADPCMMSIma,               // Microsoft IMA ADPCM
58 	kADPCMMS,                  // Microsoft ADPCM
59 	kADPCMDVI,                 // Intel DVI IMA ADPCM
60 	kADPCMApple,               // Apple QuickTime IMA ADPCM
61 	kADPCMDK3                  // Duck DK3 IMA ADPCM
62 };
63 
64 /**
65  * Takes an input stream containing ADPCM compressed sound data and creates
66  * an RewindableAudioStream from that.
67  *
68  * @param stream            the SeekableReadStream from which to read the ADPCM data
69  * @param disposeAfterUse   whether to delete the stream after use
70  * @param size              how many bytes to read from the stream (0 = all)
71  * @param type              the compression type used
72  * @param rate              the sampling rate
73  * @param channels          the number of channels
74  * @param blockAlign        block alignment ???
75  * @return   a new RewindableAudioStream, or NULL, if an error occurred
76  */
77 SeekableAudioStream *makeADPCMStream(
78     Common::SeekableReadStream *stream,
79     DisposeAfterUse::Flag disposeAfterUse,
80     uint32 size, ADPCMType type,
81     int rate,
82     int channels,
83     uint32 blockAlign = 0);
84 
85 /**
86  * Creates a PacketizedAudioStream that will automatically queue
87  * packets as individual AudioStreams like returned by makeADPCMStream.
88  *
89  * Due to the ADPCM types not necessarily supporting stateless
90  * streaming, OKI and DVI are not supported by this function
91  * and will return NULL.
92  *
93  * @param type              the compression type used
94  * @param rate              the sampling rate
95  * @param channels          the number of channels
96  * @param blockAlign        block alignment ???
97  * @return The new PacketizedAudioStream or NULL, if the type isn't supported.
98  */
99 PacketizedAudioStream *makePacketizedADPCMStream(
100 	ADPCMType type,
101 	int rate,
102 	int channels,
103 	uint32 blockAlign = 0);
104 
105 } // End of namespace Audio
106 
107 #endif
108