1 /** 2 * Copyright (c) 2006-2012 LOVE Development Team 3 * 4 * This software is provided 'as-is', without any express or implied 5 * warranty. In no event will the authors be held liable for any damages 6 * arising from the use of this software. 7 * 8 * Permission is granted to anyone to use this software for any purpose, 9 * including commercial applications, and to alter it and redistribute it 10 * freely, subject to the following restrictions: 11 * 12 * 1. The origin of this software must not be misrepresented; you must not 13 * claim that you wrote the original software. If you use this software 14 * in a product, an acknowledgment in the product documentation would be 15 * appreciated but is not required. 16 * 2. Altered source versions must be plainly marked as such, and must not be 17 * misrepresented as being the original software. 18 * 3. This notice may not be removed or altered from any source distribution. 19 **/ 20 21 #ifndef LOVE_SOUND_SOUND_H 22 #define LOVE_SOUND_SOUND_H 23 24 // LOVE 25 #include <common/Module.h> 26 #include <filesystem/File.h> 27 28 #include "SoundData.h" 29 #include "Decoder.h" 30 31 namespace love 32 { 33 namespace sound 34 { 35 36 /** 37 * The Sound module is responsible for decoding sound data. It is 38 * not responsible for playing it. 39 **/ 40 class Sound : public Module 41 { 42 43 public: 44 45 /** 46 * Destructor. 47 **/ 48 virtual ~Sound(); 49 50 /** 51 * Creates new SoundData from a decoder. Fully expands the 52 * encoded sound data into raw sound data. Not recommended 53 * on large (long-duration) files. 54 * @param decoder The file to decode the data from. 55 * @return A SoundData object, or zero if the file type couldn't be handled. 56 **/ 57 SoundData * newSoundData(Decoder * decoder); 58 59 /** 60 * Creates a new SoundData with the specified number of samples and format. 61 * @param duration In seconds. 62 * @param sampleRate Number of samples per second. 63 * @param bits Bits per sample (8 or 16). 64 * @param channels Either 1 for mono, or 2 for stereo. 65 * @return A new SoundData object, or zero in case of errors. 66 **/ 67 SoundData * newSoundData(int samples, int sampleRate, int bits, int channels); 68 69 /** 70 * Attempts to find a decoder for the encoded sound data in the 71 * specified file. 72 * @param file The file with encoded sound data. 73 * @param bufferSize The size of each decoded chunk. 74 * @param sampleRate Samples per second, or quality of the audio. 44100 is a good value. 75 * @return A Decoder object on success, or zero if no decoder could be found. 76 **/ 77 virtual Decoder * newDecoder(filesystem::File * file, int bufferSize) = 0; 78 79 }; // Sound 80 81 } // sound 82 } // love 83 84 #endif // LOVE_SOUND_SOUND_H