00001
00002
00003
00004
00005 #ifndef _WAV_H_
00006 #define _WAV_H_
00007
00008 #include <fstream.h>
00009 #include "VideoFile.h"
00010
00011
00012 class WavAtr;
00013
00014
00015 class WavIO:public VideoFile {
00016 friend class WavAtr;
00017 public:
00018 WavIO( const char *datei=NULL, IO_Mode mode=write );
00019 ~WavIO();
00020
00021
00022
00023 A_Track *initAudioCodec( int Sample_rate,
00024 int Bits,
00025 int Channels,
00026 const char *Codec = NULL );
00027 protected:
00028
00029 A_Track *openAudioTrack( int track );
00030
00031 private:
00032 struct riff_header {
00033 unsigned char id[4];
00034 unsigned long len;
00035 unsigned char wave_id[4];
00036 };
00037
00038 int write_riff_header( void );
00039 int read_riff_header( void );
00040
00041 fstream *wav_datei;
00042 istream *wav_istream;
00043 ostream *wav_ostream;
00044 };
00045
00046
00047
00048
00049
00050
00051 class WavAtr:public A_Track {
00052 public:
00053
00054 WavAtr( WavIO *File );
00055 WavAtr( WavIO *File,
00056 int Sample_rate,
00057 int Bits,
00058 int Channels,
00059 const char *Codec );
00060
00061
00062 ~WavAtr();
00063
00064
00065
00066 int Seek( long block );
00067
00068 private:
00069 WavIO *file;
00070
00071
00072 struct chunk_struct {
00073 unsigned char id[4];
00074 unsigned long len;
00075 };
00076
00077 struct common_struct {
00078 unsigned short wFormatTag;
00079 unsigned short wChannels;
00080 unsigned long dwSamplesPerSec;
00081 unsigned long dwAvgBytesPerSec;
00082 unsigned short wBlockAlign;
00083 unsigned short wBitsPerSample;
00084 };
00085
00086 struct wav_header {
00087 struct chunk_struct format;
00088 struct common_struct common;
00089 struct chunk_struct data;
00090 };
00091
00092 struct wav_header *wav_info;
00093
00094 int write_wav_header( void );
00095 int read_wav_header( void );
00096
00097 short format;
00098
00099 unsigned char *puffer;
00100 long puffer_gr;
00101
00102 protected:
00103 int readRaw( unsigned char *&data, long &bytes );
00104 int writeRaw( unsigned char *data, long bytes, int samp );
00105 };
00106
00107 #endif