AudioFileFormats.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program is free software; you can redistribute it and/or modify
00007  * it under the terms of the GNU General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or
00009  * (at your option) any later version.
00010  *
00011  * This program is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014  * GNU General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU General Public License
00017  * along with this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef __AUDIOFILEFORMATS__
00023 #define __AUDIOFILEFORMATS__
00024 
00025 #if USE_SNDFILE != 1
00026 #error USE_SNDFILE was not set to 1 in your settings.cfg file, but you are including files that require this. Please fix your settings.cfg
00027 #endif
00028 
00029 #include <sndfile.h>
00030 #include "Enum.hxx"
00031 #include <string>
00032 #include <list>
00033 #include <utility>
00034 
00035 namespace CLAM
00036 {
00037 
00039         class EAudioFileCodec : public Enum
00040         {
00041         public:
00042                 EAudioFileCodec() : Enum(EnumValues(), DefaultValue()) {}
00043                 EAudioFileCodec( tValue val ) : Enum(EnumValues(), val) {}
00044                 EAudioFileCodec( std::string s ) : Enum(EnumValues(), s) {}
00045                 virtual Component* Species() const { return new EAudioFileCodec; }
00046 
00047                 enum {
00048                         ePCM,  /* String value: "PCM". Some variant of good ol' Pulse Code Modulation */
00049                         eOggVorbis, /* String value: "Ogg/Vorbis". Compressed with OggVorbis scheme */
00050                         eMpeg,        /* String value: "Mpeg Audio". Compressed with MPEG-1 Layer 3 scheme */
00051                         eUnknown /* For error handling */
00052                 } tEnum;
00053 
00054                 static tValue     DefaultValue() { return ePCM; }
00055                 static tEnumValue * EnumValues() 
00056                 {
00057                         static tEnumValue sEnumValues[] = {
00058                                 { ePCM,         "PCM" },
00059                                 { eOggVorbis,   "Ogg/Vorbis" },
00060                                 { eMpeg,        "Mpeg Audio" },
00061                                 { eUnknown,     "Unknown" },
00062                                 { 0,            NULL }
00063                         };
00064                         return sEnumValues;
00065                 }
00066 
00067         };
00068 
00070         class EAudioFileFormat : public Enum
00071         {
00072         public:
00073                 EAudioFileFormat() : Enum(EnumValues(), DefaultValue()) {}
00074                 EAudioFileFormat( tValue val ) : Enum(EnumValues(), val) {}
00075                 EAudioFileFormat( std::string s ) : Enum(EnumValues(), s) {}
00076                 virtual Component* Species() const { return new EAudioFileFormat; }
00077 
00078                 enum
00079                 {
00080                         eWAV = SF_FORMAT_WAV,   /* Microsoft WAV  (little endian)*/
00081                         eAIFF = SF_FORMAT_AIFF,  /* Apple/SGI AIFF (big endian)*/
00082                         eAU = SF_FORMAT_AU,    /* Sun/NeXT AU (big endian)*/
00083                         eRAW = SF_FORMAT_RAW,   /* RAW PCM */
00084                         ePAF = SF_FORMAT_PAF,   /* Ensoniq PARIS File format */
00085                         eSVX = SF_FORMAT_SVX,   /* Amiga IFF / SVX8 / SV16 */
00086                         eNIST = SF_FORMAT_NIST,  /* Sphere NIST */
00087                         eVOC = SF_FORMAT_VOC,   /* VOC */
00088                         eIRCAM = SF_FORMAT_IRCAM, /* Berkeley / IRCAM / CARL */
00089                         eW64 = SF_FORMAT_W64,   /* Sonic Foundry's 64 RIFF/WAV */
00090                         eMAT4 = SF_FORMAT_MAT4,  /* MATLAB 4.2 - GNU Octave 2.0 */
00091                         eMAT5 = SF_FORMAT_MAT5,   /* MATLAB 5.2 - GNU Octave 2.1 */
00092                         eVorbisMk1 = 1000 + SF_FORMAT_MAT5,
00093                         eMpegLayer1 = 1001 + SF_FORMAT_MAT5,
00094                         eMpegLayer2 = 1002 + SF_FORMAT_MAT5,
00095                         eMpegLayer3 = 1003 + SF_FORMAT_MAT5
00096                 };
00097 
00098                 static tValue     DefaultValue() { return eWAV; }
00099                 static tEnumValue * EnumValues()
00100                 {
00101                         static tEnumValue sEnumValues[] = {
00102                                 { eWAV,       "WAV" },
00103                                 { eAIFF,      "AIFF" },
00104                                 { eAU,        "AU"   },
00105                                 { eRAW,       "RAW"  },
00106                                 { ePAF,       "PAF"  },
00107                                 { eSVX,       "SVX"  },
00108                                 { eNIST,      "NIST" },
00109                                 { eVOC,       "VOC"  },
00110                                 { eIRCAM,     "IRCAM" },
00111                                 { eW64,       "W64"  },
00112                                 { eMAT4,      "MAT4" },
00113                                 { eMAT5,      "MAT5" },
00114                                 { eVorbisMk1, "VorbisMk1"},
00115                                 { eMpegLayer1, "Mpeg Audio Layer 1"},
00116                                 { eMpegLayer2, "Mpeg Audio Layer 2"},
00117                                 { eMpegLayer3, "Mpeg Audio Layer 3"},
00118                                 { 0, 0 }
00119                         };
00120                         return sEnumValues;
00121                 }
00122 
00123         public:
00124 
00125                 static  EAudioFileFormat FormatFromFilename( std::string filename );
00126 
00127         };
00128 
00130         class EAudioFileEncoding : public Enum
00131         {
00132         public:
00133                 EAudioFileEncoding() : Enum(EnumValues(), DefaultValue()) {}
00134                 EAudioFileEncoding( tValue val ) : Enum(EnumValues(), val) {}
00135                 EAudioFileEncoding( std::string s ) : Enum(EnumValues(), s) {}
00136                 virtual Component* Species() const { return new EAudioFileEncoding; }
00137 
00138                 enum
00139                 {
00140                         ePCM_S8 = SF_FORMAT_PCM_S8,  /* Signed 8-bit PCM */
00141                         ePCM_16 = SF_FORMAT_PCM_16,  /* Signed 16-bit PCM */
00142                         ePCM_24 = SF_FORMAT_PCM_24,  /* Signed 24-bit PCM */
00143                         ePCM_32 = SF_FORMAT_PCM_32,  /* Signed 32-bit PCM */
00144                         ePCM_U8 = SF_FORMAT_PCM_U8,  /* Unsigned 8-bit PCM */
00145                         eFLOAT = SF_FORMAT_FLOAT,   /* IEEE-7354 32-bit floating point */
00146                         eDOUBLE = SF_FORMAT_DOUBLE,  /* IEEE-7354 64-bit floating point */
00147                         eU_LAW = SF_FORMAT_ULAW,   /* u-Law */
00148                         eA_LAW = SF_FORMAT_ALAW,   /* a-Law */
00149                         eIMA_ADPCM = SF_FORMAT_IMA_ADPCM,  /* IMA ADPCM */
00150                         eMS_ADPCM = SF_FORMAT_MS_ADPCM,   /* Microsoft ADPCM */
00151                         eGSM610 = SF_FORMAT_GSM610,     /* GSM 6.10 */
00152                         eVOX_ADPCM = SF_FORMAT_VOX_ADPCM,  /* Oki ADPCM */
00153                         eG721_32 = SF_FORMAT_G721_32,    /* 32kbs G721 ADPCM */
00154                         eG723_24 = SF_FORMAT_G723_24,    /* 24kbs G723 ADPCM */
00155                         eG723_40 = SF_FORMAT_G723_40,    /* 40kbs G723 ADPCM */
00156                         eDWVW_12 = SF_FORMAT_DWVW_12,    /* 12-bit Delta Width Variable Word */
00157                         eDWVW_16 = SF_FORMAT_DWVW_16,    /* 16-bit Delta Width Variable Word */
00158                         eDWVW_24 = SF_FORMAT_DWVW_24,    /* 24-bit Delta Width Variable Word */
00159                         eDWVW_N  = SF_FORMAT_DWVW_N,    /* N-bit Delta Width Variable Word */
00160                         eDefault = 1000 + SF_FORMAT_DWVW_N,  /*Format's default encoding*/
00161                         e5015US = 1001 + SF_FORMAT_DWVW_N,
00162                         eCCITTJ17 = 1002 + SF_FORMAT_DWVW_N                     
00163                 };
00164                 static tValue      DefaultValue() { return ePCM_16; }
00165                 static tEnumValue * EnumValues()
00166                 {
00167                         static tEnumValue sEnumValues[] = {
00168                                 { ePCM_S8, "signed 8-bit" },
00169                                 { ePCM_16, "signed 16-bit" },
00170                                 { ePCM_24, "signed 24-bit" },
00171                                 { ePCM_32, "signed 32-bit" },
00172                                 { ePCM_U8, "unsigned 8-bit" },
00173                                 { eFLOAT, "float 32-bit"},
00174                                 { eDOUBLE, "float 64-bit"},
00175                                 { eU_LAW, "u-law"},
00176                                 { eA_LAW, "a-law"},
00177                                 { eIMA_ADPCM, "IMA ADPCM" },
00178                                 { eMS_ADPCM, "MS ADPCM "},
00179                                 { eGSM610, "GSM 6.10"},
00180                                 { eVOX_ADPCM, "Oki ADPCM"},
00181                                 { eG721_32, "32k G721 ADPCM"},
00182                                 { eG723_24, "24k G723 ADPCM"},
00183                                 { eG723_40, "40k G723 ADPCM"},
00184                                 { eDWVW_12, "DWVW 12-bit"},
00185                                 { eDWVW_16, "DWVW 16-bit"},
00186                                 { eDWVW_24, "DWVW 24-bit"},
00187                                 { eDWVW_N,  "DWVW N-bit"},
00188                                 { eDefault, "Format Default"},
00189                                 { e5015US, "Emphasis 50/15 US"},
00190                                 { eCCITTJ17, "Emphasis CCITT J.17"},
00191                                 { 0, NULL }
00192                         };
00193                         return sEnumValues;
00194                 }
00195         };
00196 
00198         class EAudioFileEndianess : public Enum
00199         {
00200         public:
00201                 EAudioFileEndianess() : Enum(EnumValues(), DefaultValue()) {}
00202                 EAudioFileEndianess( tValue val ) : Enum(EnumValues(), val) {}
00203                 EAudioFileEndianess( std::string s ) : Enum(EnumValues(), s) {}
00204                 virtual Component* Species() const { return new EAudioFileEndianess; }
00205 
00206                 enum
00207                 {
00208                         eDefault = SF_ENDIAN_FILE, /* Default format endianess */
00209                         eLittle = SF_ENDIAN_LITTLE,  /* Force little endianess (if supported by format)*/
00210                         eBig = SF_ENDIAN_BIG,     /* Force big endianess (if supported by format)*/
00211                         eHost = SF_ENDIAN_CPU     /* Force host CPU endianess (if supported by format)*/
00212                 };
00213                 static tValue      DefaultValue() { return eDefault; }
00214                 static tEnumValue * EnumValues()
00215                 {
00216                         static tEnumValue sEnumValues[] = {
00217                                 { eDefault, "Format Default" },
00218                                 { eLittle,  "Little Endian"},
00219                                 { eBig,     "Big Endian"},
00220                                 { eHost,    "Host CPU Endianess"},
00221                                 { 0, NULL }
00222                         };
00223                         return sEnumValues;
00224                 }
00225         };
00226 
00227 }
00228 
00229 #endif // AudioFileFormats.hxx
00230 
Generated by  doxygen 1.6.3