1 /*------------ Telecommunications & Signal Processing Lab -------------- 2 McGill University 3 4 Routine: 5 AO.h 6 7 Description: 8 Declarations for audio utility program options routines 9 10 Author / revision: 11 P. Kabal Copyright (C) 2003 12 $Revision: 1.36 $ $Date: 2003/11/04 12:51:30 $ 13 14 ----------------------------------------------------------------------*/ 15 16 #ifndef AO_h_ 17 #define AO_h_ 18 19 #include <limits.h> 20 #include <stdio.h> /* FILENAME_MAX */ 21 22 #include <libtsp/AFpar.h> /* struct AF_NHpar, AFILE */ 23 #include <libtsp/sysOS.h> /* SY_OS */ 24 25 #include <AObase.h> /* Basic AO (no audio files) definitions */ 26 27 #define AFNH_ENV "$AF_NOHEADER" 28 #define AFFTYPE_ENV "$AF_FILETYPE" 29 30 #define AO_LIM_UNDEF LONG_MIN /* Undefined Limits */ 31 32 struct AO_dformat { 33 int Format; 34 int NbS; 35 }; 36 struct AO_FIpar { 37 char Fname[FILENAME_MAX]; 38 double Gain; 39 long int Lim[2]; 40 int Ftype; 41 struct AF_NHpar NHpar; 42 }; 43 struct AO_FOpar { 44 char Fname[FILENAME_MAX]; 45 long int Nframe; 46 int Ftype; 47 double Sfreq; 48 struct AO_dformat DFormat; 49 unsigned char *SpkrConfig; 50 const char *Info; 51 }; 52 53 /* Initialization macros */ 54 #define FIpar_INIT(fi) { \ 55 if (AFsetNHpar (AFNH_ENV)) \ 56 UTwarn ("%s - %s \"%s\"", PROGRAM, AOM_BadEnv, &(AFNH_ENV)[1]); \ 57 if (AFsetFileType (AFFTYPE_ENV)) \ 58 UTwarn ("%s - %s \"%s\"", PROGRAM, AOM_BadEnv, &(AFFTYPE_ENV)[1]); \ 59 (fi)->Fname[0] = '\0'; \ 60 (fi)->Gain = 1.0; \ 61 (fi)->Lim[0] = 0L; \ 62 (fi)->Lim[1] = AO_LIM_UNDEF; \ 63 (fi)->Ftype = (AFoptions ())->FtypeI; \ 64 (fi)->NHpar = (AFoptions ())->NHpar; } 65 66 #define FOpar_INIT(fo) { \ 67 (fo)->Fname[0] = '\0'; \ 68 (fo)->Nframe = AF_NFRAME_UNDEF; \ 69 (fo)->Sfreq = 0.0; \ 70 (fo)->DFormat.Format = FD_UNDEF; \ 71 (fo)->DFormat.NbS = 0; \ 72 (fo)->Ftype = FTW_UNDEF; \ 73 (fo)->SpkrConfig = NULL; \ 74 (fo)->Info = NULL; } 75 76 /* Default output file type */ 77 #if (SY_OS == SY_OS_UNIX) 78 # define AO_FTYPEO_DEFAULT FTW_AU 79 #else 80 # define AO_FTYPEO_DEFAULT FTW_WAVE 81 #endif 82 83 /* Default output data type */ 84 #define AO_DFORMATO_DEFAULT FD_INT16 85 86 /* Warning messages */ 87 #define AOM_BadEnv "Invalid value for environment variable" 88 #define AOM_DiffLim "Input file sample limits differ, using maximum" 89 #define AOM_DiffNSamp "Different numbers of samples, using maximum" 90 #define AOM_NotAllLim "Not all sample limits defined" 91 #define AOM_NotAllNSamp "Number of samples not defined for all files" 92 93 /* Error messages */ 94 #define AOM_BadData "Invalid data format specification" 95 #define AOM_BadFType "Invalid file type specification" 96 #define AOM_BadGain "Invalid gain value" 97 #define AOM_BadLimits "Invalid limits specification" 98 #define AOM_BadNFrame "Invalid number of samples" 99 #define AOM_BadNHPar "Error setting headerless file parameters" 100 #define AOM_BadOption "Option error, use -h for a list of options" 101 #define AOM_BadSFreq "Invalid sampling frequency" 102 #define AOM_BadSpkr "Invalid speaker configuration" 103 #define AOM_InvFTypeC "Invalid output file type code" 104 #define AOM_InvNbS "Invalid no. bits/sample" 105 #define AOM_stdin1 "Error, standard input can be used only once" 106 #define AOMF_DataFType "%s: Invalid data format (%s) for %s" 107 108 #ifdef __cplusplus 109 extern "C" { 110 #endif 111 112 /* Prototypes */ 113 struct AO_CmdArg * 114 AOArgs (void); 115 int 116 AOdecFI (struct AO_FIpar *FI); 117 int 118 AOdecFO (struct AO_FOpar *FO); 119 void 120 AOinitOpt (const int argc, const char *argv[]); 121 long int 122 AOnFrame (AFILE *AFp[], const struct AO_FIpar FI[], int Nifiles, 123 long int Nframe); 124 int 125 AOsetDformat (const struct AO_FOpar *FO, AFILE *AFp[], int Nf); 126 void 127 AOsetFIopt (const struct AO_FIpar *FI, int NsampND, int RAccess); 128 void 129 AOsetFOopt (const struct AO_FOpar *FO); 130 int 131 AOsetFormat (const struct AO_FOpar *FO, AFILE *AFp[], int Nf); 132 int 133 AOsetFtype (const struct AO_FOpar *FO); 134 void 135 AOstdin (const struct AO_FIpar FI[], int N); 136 137 #ifdef __cplusplus 138 } 139 #endif 140 141 #endif /* AO_h_ */ 142