00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00027
00029 #ifndef __AUDIOFILEREADER_H__
00030 #define __AUDIOFILEREADER_H__
00031
00032 #include "H3DSoundFileNode.h"
00033
00034 #ifdef HAVE_LIBAUDIOFILE
00035 #ifdef _MSC_VER
00036 #pragma comment( lib, "audiofile.lib" )
00037 #endif
00038 #include <audiofile.h>
00039
00040 namespace H3D {
00041
00050 class H3DAPI_API AudioFileReader : public H3DSoundFileNode {
00051 public:
00052
00054 AudioFileReader() {}
00055
00057 ~AudioFileReader() {
00058 afCloseFile( file );
00059 }
00060
00063 unsigned int load( const string &_url );
00064
00066 virtual void reset() {
00067 afSeekFrame( file, AF_DEFAULT_TRACK, 0 );
00068 }
00069
00071 virtual unsigned int totalDataSize() {
00072 return afGetTrackBytes( file, AF_DEFAULT_TRACK );
00073 }
00074
00077 virtual unsigned int nrChannels() {
00078 return afGetChannels( file, AF_DEFAULT_TRACK );
00079 }
00080
00083 virtual unsigned int samplesPerSecond() {
00084 return (unsigned int) afGetRate( file, AF_DEFAULT_TRACK );
00085 }
00086
00088 virtual unsigned int bitsPerSample() {
00089 int sample_format, sample_width;
00090 afGetVirtualSampleFormat( file, AF_DEFAULT_TRACK,
00091 &sample_format, &sample_width );
00092 return sample_width;
00093 }
00094
00096 virtual H3DTime duration() {
00097 return afGetFrameCount(file, AF_DEFAULT_TRACK) /
00098 afGetRate(file, AF_DEFAULT_TRACK);
00099 }
00100
00105 virtual unsigned int read( char *buffer, unsigned int size );
00106
00109 static bool supportsFileType( const string &url );
00110
00112 static H3DNodeDatabase database;
00113
00115 static FileReaderRegistration reader_registration;
00116
00117 protected:
00118 AFfilehandle file;
00119 string url;
00120 };
00121 }
00122
00123 #endif
00124 #endif