Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/WavFileSource2.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2006 George Tzanetakis <gtzan@cs.uvic.ca>
00003 **
00004 ** This program is free software; you can redistribute it and/or modify
00005 ** it under the terms of the GNU General Public License as published by
00006 ** the Free Software Foundation; either version 2 of the License, or
00007 ** (at your option) any later version.
00008 **
00009 ** This program is distributed in the hope that it will be useful,
00010 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 ** GNU General Public License for more details.
00013 **
00014 ** You should have received a copy of the GNU General Public License
00015 ** along with this program; if not, write to the Free Software
00016 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
00017 */
00018 
00019 #ifndef MARSYAS_WAVFILESOURCE2_H
00020 #define MARSYAS_WAVFILESOURCE2_H
00021 
00022 #include <marsyas/common_header.h>
00023 #include "AbsSoundFileSource2.h"
00024 
00025 #include <string>
00026 #include <cstring>
00027 #include <cstdio>
00028 
00029 namespace Marsyas
00030 {
00037 class WavFileSource2: public AbsSoundFileSource2
00038 {
00039 private:
00040   short *sdata_;
00041   unsigned char *cdata_;
00042 
00043   FILE *sfp_;
00044   long sfp_begin_;
00045 
00046   mrs_natural sampleSize_; //in bytes
00047   short sval_;
00048   unsigned short bits_;
00049 
00050   mrs_natural samplesToRead_;
00051   mrs_natural samplesRead_;
00052   mrs_natural samplesToWrite_;
00053 
00054   void addControls();
00055   void myUpdate(MarControlPtr sender);
00056 
00057   unsigned long ByteSwapLong(unsigned long nLongNumber);
00058   unsigned short ByteSwapShort (unsigned short nValue);
00059 
00060   //mrs_natural getLinear8(mrs_natural c, realvec& win);
00061   mrs_natural getLinear16(realvec& win);
00062 
00063   void hdrError();
00064   bool getHeader();
00065 
00066 public:
00067   WavFileSource2(std::string name);
00068   WavFileSource2(const WavFileSource2& a); //[!][?]
00069   ~WavFileSource2();
00070   MarSystem* clone() const;
00071 
00072   realvec& getAudioRegion(mrs_natural startSample, mrs_natural endSample);
00073 
00074   void myProcess(realvec& in, realvec &out);
00075 };
00076 
00077 }//namespace Marsyas
00078 
00079 
00080 #endif     /* MARSYAS_WAVFILESOURCE2_H */
00081 
00082