|
Wave Arts VQE
1.00
Voice Quality Enhancement
|
00001 /* 00002 * This file is part of the Wave Arts VQE library. 00003 * Copyright (C) 2011 Wave Arts, Inc. (http://wavearts.com) 00004 * 00005 * VQE is free software; you can redistribute it and/or modify 00006 * it under the terms of the GNU General Public License as published by 00007 * the Free Software Foundation; either version 2 of the License, or 00008 * (at your option) any later version. 00009 * 00010 * VQE is distributed in the hope that it will be useful, 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00013 * GNU General Public License for more details. 00014 * 00015 * A copy of the GNU General Public License is included with VQE, 00016 * and can be found online at <http://www.gnu.org/licenses/>. 00017 * 00018 * If you'd like to distribute a closed-source product which uses VQE, 00019 * you must obtain a commercial VQE license from Wave Arts. 00020 */ 00050 #ifndef _WAAIFF_H 00051 #define _WAAIFF_H 00052 00053 #include <stdio.h> 00054 #include "convert.h" 00055 00056 #ifndef TRUE 00057 #define FALSE 0 00058 #define TRUE (!FALSE) 00059 #endif 00060 00061 #ifndef BOOL 00062 typedef int BOOL; 00063 #endif 00064 00065 // 00066 // MacOS specific file type 00067 // 00068 #if macintosh 00069 #define AIFF_MACOS_TYPE 'AIFF' 00070 #define AIFF_MACOS_CREATOR 'Sd2a' 00071 #endif 00072 00073 // 00074 // Types for AIFF structure elements. All types are mapped to 00075 // character arrays, to guarantee (?) proper structure size and simplify 00076 // conversion. If the compiler forces character arrays to be longword 00077 // aligned, then the structures below will not work, but word alignment 00078 // is OK, because all elements in the AIFF spec are word aligned. 00079 // 00080 typedef char AiffExtended[10]; 00081 typedef char AiffLong[4]; 00082 typedef char AiffShort[2]; 00083 typedef char AiffId[4]; 00084 00085 // 00086 // AIFF IDs as strings that can be passed to functions to compare 00087 // and copy IDs. This is the only truly portable way to do it. 00088 // 00089 #define AIFF_TYPE "AIFF" 00090 #define AIFC_TYPE "AIFC" 00091 #define FORM_ID "FORM" 00092 #define FVER_ID "FVER" 00093 #define COMM_ID "COMM" 00094 #define SSND_ID "SSND" 00095 #define MARK_ID "MARK" 00096 #define INST_ID "INST" 00097 #define APPL_ID "APPL" 00098 #define NAME_ID "NAME" 00099 #define AUTH_ID "AUTH" 00100 #define COPY_ID "(c) " 00101 #define ANNO_ID "ANNO" 00102 #define COMT_ID "COMT" 00103 #define NONE_ID "NONE" 00104 #define SAXL_ID "SAXL" 00105 #define MIDI_ID "MIDI" 00106 #define AESD_ID "AESD" 00107 00108 // 00109 // These structures model the actual chunk and form headers 00110 // that are written to the file. 00111 // 00112 typedef struct { 00113 AiffId id; 00114 AiffLong size; 00115 } CkHdr; /* 8 bytes */ 00116 00117 typedef struct { 00118 CkHdr ck; 00119 AiffId formType; 00120 } FormHdr; /* 12 bytes */ 00121 00122 // 00123 // Chunk data structures *do not* contain leading chunk header, 00124 // unlike previous versions of this code. All type names ending 00125 // in "Data" are stored within a chunk. 00126 // 00127 typedef struct { 00128 AiffShort numChannels; 00129 AiffLong numSampleFrames; 00130 AiffShort sampleSize; 00131 AiffExtended sampleRate; 00132 } CommonData; /* 18 bytes */ 00133 00134 //#define numSampleFramesOffset sizeof(AiffShort) // offset to numSampleFrames 00135 00136 // 00137 // Universal form of non-portable structure above. 00138 // 00139 typedef struct { 00140 short numChannels; 00141 int numSampleFrames; 00142 short sampleSize; 00143 double sampleRate; 00144 } UnivCommonData; 00145 00146 typedef struct { 00147 AiffLong offset; 00148 AiffLong blockSize; 00149 } SoundData; 00150 00151 typedef struct { 00152 int offset; 00153 int blockSize; 00154 } UnivSoundData; 00155 00156 typedef struct { 00157 AiffLong timestamp; 00158 } FormatVersionData; 00159 00160 typedef AiffShort MarkerId; 00161 00162 typedef struct { 00163 MarkerId id; 00164 AiffLong position; 00165 } WaMarker; 00166 00167 typedef struct { 00168 AiffShort numMarkers; 00169 } WaMarkerData; 00170 00171 typedef struct { 00172 AiffLong timeStamp; 00173 MarkerId marker; 00174 AiffShort count; 00175 } WaComment; 00176 00177 typedef struct { 00178 AiffShort numComments; 00179 } CommentsData; 00180 00181 #ifndef macintosh 00182 #define NoLooping 0 00183 #define ForwardLooping 1 00184 #define ForwardBackwardLooping 2 00185 #endif 00186 00187 typedef struct { 00188 AiffShort playMode; 00189 AiffShort beginMark; 00190 AiffShort endMark; 00191 } Loop; /* 6 bytes */ 00192 00193 typedef struct { 00194 char baseNote; 00195 char detune; 00196 char lowNote; 00197 char highNote; 00198 char lowVelocity; 00199 char highVelocity; 00200 AiffShort gain; 00201 Loop sustainLoop; 00202 Loop releaseLoop; 00203 } InstrumentData; 00204 00205 typedef struct { 00206 AiffId appSig; 00207 } ApplData; 00208 00209 00210 //=============================================================== 00211 // AIFF interface, modeled directly after Windows MMIO interface. 00212 // 00213 00214 // 00215 // Error type 00216 // 00217 typedef int AIFFRESULT; 00218 00219 // 00220 // Error codes 00221 // 00222 #define AIFFERR_NOERROR 0 00223 #define AIFFERR_BASE 256 00224 #define AIFFERR_FILENOTFOUND (AIFFERR_BASE + 1) /* file not found */ 00225 #define AIFFERR_OUTOFMEMORY (AIFFERR_BASE + 2) /* out of memory */ 00226 #define AIFFERR_CANNOTOPEN (AIFFERR_BASE + 3) /* cannot open */ 00227 #define AIFFERR_CANNOTCLOSE (AIFFERR_BASE + 4) /* cannot close */ 00228 #define AIFFERR_CANNOTREAD (AIFFERR_BASE + 5) /* cannot read */ 00229 #define AIFFERR_CANNOTWRITE (AIFFERR_BASE + 6) /* cannot write */ 00230 #define AIFFERR_CANNOTSEEK (AIFFERR_BASE + 7) /* cannot seek */ 00231 #define AIFFERR_CANNOTEXPAND (AIFFERR_BASE + 8) /* cannot expand file */ 00232 #define AIFFERR_CHUNKNOTFOUND (AIFFERR_BASE + 9) /* chunk not found */ 00233 #define AIFFERR_UNBUFFERED (AIFFERR_BASE + 10) /* */ 00234 #define AIFFERR_PATHNOTFOUND (AIFFERR_BASE + 11) /* path incorrect */ 00235 #define AIFFERR_ACCESSDENIED (AIFFERR_BASE + 12) /* file was protected */ 00236 #define AIFFERR_SHARINGVIOLATION (AIFFERR_BASE + 13) /* file in use */ 00237 #define AIFFERR_NETWORKERROR (AIFFERR_BASE + 14) /* network not responding */ 00238 #define AIFFERR_TOOMANYOPENFILES (AIFFERR_BASE + 15) /* no more file handles */ 00239 #define AIFFERR_INVALIDFILE (AIFFERR_BASE + 16) /* default error file error */ 00240 00241 // 00242 // The HAiff pointer corresponds to the HMMIO Windows Multimedia file I/O 00243 // handle. This API is modeled after MMIO API. 00244 // 00245 typedef struct { 00246 FILE *fp; // file pointer 00247 int openFlags; // flags set up with aiffOpen 00248 ConvertTab *cvt; // conversion function table 00249 } Aiff, *HAiff; 00250 00251 // flags for aiffOpen() 00252 #define AIFF_OPEN_READ 0x01 00253 #define AIFF_OPEN_WRITE 0x02 00254 00255 // 00256 // This structure refers to a chunk or form header, and is used 00257 // by Descend() and Ascend(). The structure remembers the offset of 00258 // the chunk length field so it can be set later, after data is written. 00259 // 00260 typedef struct { 00261 AiffId id; 00262 long size; 00263 AiffId formType; 00264 long dataOffset; 00265 long flags; 00266 } CkInfo; 00267 00268 // ckInfo flags 00269 #define CKINFO_DIRTY 0x01 // chunk length needs to be updated 00270 #define CKINFO_FORM 0x02 // chunk is a FORM type 00271 00272 // aiffCreateChunk flags 00273 #define AIFF_CREATE_FORM 0x01 // create FORM chunk 00274 00275 // aiffDescend flags 00276 #define AIFF_FIND_CHUNK 0x01 // find specified chunk 00277 #define AIFF_FIND_FORM 0x02 // find FORM chunk 00278 00279 // 00280 // Silly thing analogous to MMIOINFO struct, here used only 00281 // to return an error from aiffOpen(). 00282 // 00283 typedef struct { 00284 AIFFRESULT error; 00285 } AiffInfo; 00286 00287 #ifdef __cplusplus 00288 extern "C" { 00289 #endif 00290 00291 // 00292 // Function prototypes 00293 // 00294 AIFFRESULT aiffAscend(HAiff haiff, CkInfo *pCkInfo, int flags); 00295 AIFFRESULT aiffClose(HAiff haiff); 00296 AIFFRESULT aiffCreateChunk(HAiff haiff, CkInfo *pCkInfo, int flags); 00297 AIFFRESULT aiffDescend(HAiff haiff, CkInfo *pCkInfo, CkInfo *pCkParentInfo, int flags); 00298 AIFFRESULT aiffFlush(HAiff haiff); 00299 HAiff aiffOpen(char *fileName, AiffInfo *info, int flags); 00300 long aiffRead(HAiff haiff, char *buf, long numBytes); 00301 long aiffTell(HAiff haiff); 00302 AIFFRESULT aiffSeek(HAiff haiff, long offset, int origin); 00303 long aiffWrite(HAiff haiff, char *buf, long numBytes); 00304 00305 // 00306 // Shortcut for writing a simple chunk header and data. Can't be 00307 // used for FORM type. Data must already be in proper format. 00308 // 00309 AIFFRESULT aiffWriteChunk(HAiff haiff, AiffId id, char *data, long numBytes); 00310 00311 void aiffCopyId(AiffId src, AiffId dest); 00312 BOOL aiffIdEqual(AiffId a, AiffId b); 00313 char *aiffErrorStr(AIFFRESULT aiffError); 00314 00315 #ifdef __cplusplus 00316 } 00317 #endif 00318 00319 #endif
1.7.5.1