00001 #ifndef AUFILE_H
00002 #define AUFILE_H
00003
00004 #include <vector>
00005
00006 using namespace std;
00007
00008 #include <inttypes.h>
00009
00010 #define AUDIO_AU_FILE_MAGIC (0x2e736e64)
00011 #define AUDIO_AU_UNKNOWN_SIZE (~0)
00012 #define AUDIO_AU_ENCODING_ULAW 0x00000001
00013
00014 #define AUDIO_AU_FILE2HOST(x) \
00015 ((((unsigned char *) (&(x)))[0] << 24) | \
00016 (((unsigned char *) (&(x)))[1] << 16) | \
00017 (((unsigned char *) (&(x)))[2] << 8) | \
00018 (((unsigned char *) (&(x)))[3]))
00019 #define AUDIO_AU_HOST2FILE(x) AUDIO_AU_FILE2HOST(x)
00020
00021
00028 struct au_filehdr {
00029 #ifdef OLD_GCC_PRAGMAS
00030 #pragma pack(1)
00031 uint32_t magic;
00032 uint32_t offset;
00033 uint32_t data_size;
00034 uint32_t encoding;
00035 uint32_t sample_rate;
00036 uint32_t channels;
00037 #else
00038
00039 uint32_t magic __attribute__ ((packed));
00041 uint32_t offset __attribute__ ((packed));
00043 uint32_t data_size __attribute__ ((packed));
00045 uint32_t encoding __attribute__ ((packed));
00047 uint32_t sample_rate __attribute__ ((packed));
00049 uint32_t channels __attribute__ ((packed));
00050 #endif
00051 };
00052
00053 typedef struct au_filehdr au_filehdr_t;
00054
00057 struct AU_info_data {
00059 unsigned char * data;
00061 unsigned int size;
00062 };
00063
00067 class AUFile {
00068 friend class GUIMainImpl;
00069
00070 public:
00073 AUFile (void);
00074
00077 ~AUFile (void);
00078
00081 AUFile (AUFile& source);
00082
00089 bool open (const char *filename);
00090
00097 bool write (const char *filename);
00098
00107 bool record (const char *filename, unsigned int duration);
00108
00113 bool play (void) const;
00114
00117 void normalize (void);
00118
00124 bool cutSampleRange (unsigned int length);
00125
00128 vector<double>& getData (void);
00129
00132 unsigned int getSize (void);
00133
00136 AU_info_data * getInformation (void);
00137
00146 bool setInformation (unsigned int size, unsigned char *data);
00147
00152 void setSize (unsigned int size);
00153
00158 const char * getFilename (void);
00159
00160
00161 private:
00164 char * filename;
00165
00168 au_filehdr au_header;
00169
00172 vector<double> au_data;
00173
00176 AU_info_data i_data;
00177
00181 bool if_open;
00182 };
00183
00184 #endif