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 OGGVORBIS_H 0021 #define OGGVORBIS_H 0022 0023 #include <stdint.h> 0024 0025 #include <vorbis/vorbisfile.h> 0026 0027 #include "audioformat.h" 0028 #include "src/domain/animation/workspacefile.h" 0029 0030 class ErrorHandler; 0031 0032 /** 0033 * Class for decoding of oggvorbis data to raw PCM data. 0034 * 0035 * @author Bjoern Erik Nilsen & Fredrik B. Kjoelstad 0036 */ 0037 class OggVorbis : public AudioFormat { 0038 public: 0039 OggVorbis(); 0040 ~OggVorbis(); 0041 0042 /** 0043 * Function for registering the given filename to be an ogg file. This 0044 * function checks that the file can be opened and that it is a valid 0045 * ogg file. 0046 * @param file the filename to register 0047 */ 0048 void setFilename(WorkspaceFile& file, ErrorHandler& e); 0049 0050 int open(); 0051 int close(); 0052 void reset(); 0053 int fillBuffer(char *audioBuffer, int numBytes); 0054 int add16bit(int16_t* audioBuffer, int count); 0055 const char* getSoundPath() const; 0056 const char* getBasename() const; 0057 0058 private: 0059 /** The ogg representation of the file registered in this class. */ 0060 OggVorbis_File *oggFile; 0061 0062 /** The filename registered in this class. Hopefully a valid ogg file. */ 0063 WorkspaceFile filename; 0064 enum { 0065 littleEndian = 0, 0066 bigEndian = 1, 0067 wordsAreUnsigned = 0, 0068 wordsAreSigned = 1, 0069 wordsAre8Bit = 1, 0070 wordsAre16Bit = 2, 0071 wordsAre32Bit = 4 0072 }; 0073 }; 0074 0075 #endif