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 AUDIO_RAW_H 24 #define AUDIO_RAW_H 25 26 #include "common/scummsys.h" 27 #include "common/types.h" 28 29 #include "common/list.h" 30 31 32 namespace Common { 33 class SeekableReadStream; 34 } 35 36 namespace Audio { 37 38 class PacketizedAudioStream; 39 class SeekableAudioStream; 40 41 /** 42 * Various flags which can be bit-ORed and then passed to 43 * makeRawStream and some other AudioStream factories 44 * to control their behavior. 45 * 46 * Engine authors are advised not to rely on a certain value or 47 * order of these flags (in particular, do not store them verbatim 48 * in savestates). 49 */ 50 enum RawFlags { 51 /** unsigned samples (default: signed) */ 52 FLAG_UNSIGNED = 1 << 0, 53 54 /** sound is 16 bits wide (default: 8bit) */ 55 FLAG_16BITS = 1 << 1, 56 57 /** sound is 24 bits wide (default: 8bit) */ 58 FLAG_24BITS = 1 << 2, 59 60 /** samples are little endian (default: big endian) */ 61 FLAG_LITTLE_ENDIAN = 1 << 3, 62 63 /** sound is in stereo (default: mono) */ 64 FLAG_STEREO = 1 << 4 65 }; 66 67 /** 68 * Creates an audio stream, which plays from the given buffer. 69 * 70 * @param buffer Buffer to play from. 71 * @param size Size of the buffer in bytes. 72 * @param rate Rate of the sound data. 73 * @param flags Audio flags combination. 74 * @see RawFlags 75 * @param disposeAfterUse Whether to free the buffer after use (with free!). 76 * @return The new SeekableAudioStream (or 0 on failure). 77 */ 78 SeekableAudioStream *makeRawStream(const byte *buffer, uint32 size, 79 int rate, byte flags, 80 DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); 81 82 /** 83 * Creates an audio stream, which plays from the given stream. 84 * 85 * @param stream Stream object to play from. 86 * @param rate Rate of the sound data. 87 * @param flags Audio flags combination. 88 * @see RawFlags 89 * @param disposeAfterUse Whether to delete the stream after use. 90 * @return The new SeekableAudioStream (or 0 on failure). 91 */ 92 SeekableAudioStream *makeRawStream(Common::SeekableReadStream *stream, 93 int rate, byte flags, 94 DisposeAfterUse::Flag disposeAfterUse = DisposeAfterUse::YES); 95 96 /** 97 * Creates a PacketizedAudioStream that will automatically queue 98 * packets as individual AudioStreams like returned by makeRawStream. 99 * 100 * @param rate Rate of the sound data. 101 * @param flags Audio flags combination. 102 * @see RawFlags 103 * @return The new PacketizedAudioStream. 104 */ 105 PacketizedAudioStream *makePacketizedRawStream(int rate, byte flags); 106 107 } // End of namespace Audio 108 109 #endif 110