AudioFileReader.h

Go to the documentation of this file.
00001 
00002 //    Copyright 2004, SenseGraphics AB
00003 //
00004 //    This file is part of H3D API.
00005 //
00006 //    H3D API is free software; you can redistribute it and/or modify
00007 //    it under the terms of the GNU General Public License as published by
00008 //    the Free Software Foundation; either version 2 of the License, or
00009 //    (at your option) any later version.
00010 //
00011 //    H3D API is distributed in the hope that it will be useful,
00012 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //    GNU General Public License for more details.
00015 //
00016 //    You should have received a copy of the GNU General Public License
00017 //    along with H3D API; if not, write to the Free Software
00018 //    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019 //
00020 //    A commercial license is also available. Please contact us at 
00021 //    www.sensegraphics.com for more information.
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

Generated on Thu Aug 24 12:38:32 2006 for H3D API by  doxygen 1.4.5