File indexing completed on 2024-05-12 16:23:35
0001 /*************************************************************************** 0002 * Copyright (C) 2005-2008 by Bjoern Erik Nilsen & Fredrik Berg Kjoelstad* 0003 * bjoern.nilsen@bjoernen.com & fredrikbk@hotmail.com * 0004 * * 0005 * This program is free software; you can redistribute it and/or modify * 0006 * it under the terms of the GNU General Public License as published by * 0007 * the Free Software Foundation; either version 2 of the License, or * 0008 * (at your option) any later version. * 0009 * * 0010 * This program is distributed in the hope that it will be useful, * 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 0013 * GNU General Public License for more details. * 0014 * * 0015 * You should have received a copy of the GNU General Public License * 0016 * along with this program; if not, write to the * 0017 * Free Software Foundation, Inc., * 0018 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 0019 ***************************************************************************/ 0020 #ifndef AUDIOFORMAT_H 0021 #define AUDIOFORMAT_H 0022 0023 #include <stdint.h> 0024 0025 /** 0026 * Interface to be used by the implemented audio formats. They 0027 * will be responsible for decoding from their own format to raw PCM. 0028 * 0029 * @author Bjoern Erik Nilsen & Fredrik Berg Kjoelstad 0030 */ 0031 class AudioFormat { 0032 public: 0033 virtual ~AudioFormat(); 0034 0035 /** 0036 * Abstract function for opening the file registered with setFilename. 0037 * @return 0 on success, -1 on failure 0038 */ 0039 virtual int open() = 0; 0040 0041 /** 0042 * Abstract function for closing the file registered with setFilename. 0043 * @return 0 on success, -1 on failure 0044 */ 0045 virtual int close() = 0; 0046 0047 /** 0048 * Abstract function for resetting to the beginning of the sound. 0049 */ 0050 virtual void reset() = 0; 0051 0052 /** 0053 * Abstract function for filling the buffer with raw PCM data. It 0054 * fills the buffer with up to 'numBytes' bytes. 0055 * @param audioBuffer the buffer to be filled 0056 * @param numBytes number of bytes available in the buffer 0057 * @return number of bytes written to buffer 0058 */ 0059 virtual int fillBuffer(char *audioBuffer, int numBytes) = 0; 0060 0061 /** 0062 * Adds PCM data to the buffer. 0063 * @param audioBuffer The start of the buffer to be added to 0064 * @param count The number of values to be added to 0065 * @return Number of values actually written. This must be 0066 * no more than count and non-negative, and can only be 0 0067 * if the sound is exhausted. 0068 */ 0069 virtual int add16bit(int16_t* audioBuffer, int count) = 0; 0070 0071 /** 0072 * Abstract function for retrieving the sound path. 0073 * @return the sound path 0074 */ 0075 virtual const char* getSoundPath() const = 0; 0076 0077 /** 0078 * Retrieves the basename of the sound file. 0079 * @return The filename with extension and without any path. 0080 */ 0081 virtual const char* getBasename() const = 0; 0082 }; 0083 0084 #endif