Marsyas  0.6.0-alpha
/usr/src/RPM/BUILD/marsyas-0.6.0/src/marsyas/marsystems/WavFileSource.h
Go to the documentation of this file.
00001 /*
00002 ** Copyright (C) 1998-2010 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_WAVFILESOURCE_H
00020 #define MARSYAS_WAVFILESOURCE_H
00021 
00022 #include <marsyas/common_header.h>
00023 #include "AbsSoundFileSource.h"
00024 
00025 #include <string>
00026 #include <cstdio>
00027 #include <cstring>
00028 
00029 namespace Marsyas
00030 {
00037 class WavFileSource: public AbsSoundFileSource
00038 {
00039 private:
00040   int *idata_;
00041   short *sdata_;
00042   unsigned char *cdata_;
00043 
00044   FILE *sfp_;
00045   long sfp_begin_;
00046 
00047   mrs_natural sampleSize_; //in bytes
00048   mrs_natural csize_;
00049   mrs_natural size_;
00050   int ival_;
00051   short sval_;
00052   unsigned short bits_;
00053   MarControlPtr ctrl_pos_;
00054 
00055   void addControls();
00056   void myUpdate(MarControlPtr sender);
00057   unsigned long ByteSwapLong(unsigned long nLongNumber);
00058   unsigned int ByteSwapInt(unsigned int nInt);
00059   unsigned short ByteSwapShort (unsigned short nValue);
00060 
00061   mrs_natural nChannels_;
00062   mrs_natural inSamples_;
00063   mrs_natural samplesToRead_;
00064   mrs_natural samplesRead_;
00065   mrs_natural samplesToWrite_;
00066 
00067   mrs_natural nt_;
00068 
00069   mrs_natural samplesOut_;
00070 
00071   mrs_real repetitions_;
00072   mrs_real duration_;
00073 
00074   mrs_natural getLinear32(realvec& win);
00075   mrs_natural getLinear16(realvec& win);
00076   mrs_natural getLinear8(realvec& win);
00077 
00078 
00079 public:
00080   WavFileSource(std::string name);
00081   WavFileSource(const WavFileSource& a);
00082 
00083   ~WavFileSource();
00084   MarSystem* clone() const;
00085 
00086 
00087   void getHeader(std::string filename);
00088   void myProcess(realvec& in, realvec &out);
00089 };
00090 
00091 }//namespace Marsyas
00092 
00093 
00094 #endif     /* !MARSYAS_WAVFILESOURCE_H */