Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/root/src/subsynth/syn/Stream/WavAudioIStream.h

Go to the documentation of this file.
00001 
00002 /****************** <SYN heading BEGIN do not edit this line> *****************
00003  *
00004  * subsynth - modular audio synthesizer
00005  * subsynth is (C) Copyright 2001-2002 by Kevin Meinert
00006  *
00007  * Original Author: Kevin Meinert
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022  * Boston, MA 02111-1307, USA.
00023  *
00024  * -----------------------------------------------------------------
00025  * File:          $RCSfile: WavAudioIStream.h,v $
00026  * Date modified: $Date: 2002/02/16 19:24:16 $
00027  * Version:       $Revision: 1.19 $
00028  * -----------------------------------------------------------------
00029  *
00030  ****************** <SYN heading END do not edit this line> ******************/
00031 #ifndef SUBSYNTH_WAV_INPUT_STREAM
00032 #define SUBSYNTH_WAV_INPUT_STREAM
00033 
00034 #include <iostream>
00035 #include <fstream>
00036 #include <vector>
00037 #include <string>
00038 
00039 #include "syn/Util/Endian.h"
00040 #include "syn/Stream/WavHeader.h"
00041 #include "syn/Stream/AudioIStream.h"
00042 #include "syn/Stream/WavHeader.h"
00043 
00044 namespace syn
00045 {
00049    class WavAudioIStream : public AudioIStream
00050    {
00051    public:
00052       WavAudioIStream();
00053       virtual ~WavAudioIStream(){}
00054 
00058       void setName( const std::string& filename );
00059    
00065       virtual bool open( const syn::AudioFormat& fmt, Operation op = COPY );
00066 
00067       virtual bool isOpen() const;
00068       virtual bool good() const;
00069       virtual bool bad() const;
00070       virtual bool eof() const;
00071       
00077       virtual void read( void* data, unsigned int samples );
00078 
00079       virtual int gcount() const;
00080       virtual const AudioFormat& format() const { return mDestFormat; }
00084       bool close();
00085       
00091       int numsamps();
00092      
00096       void seek( int sampleNum );
00097 
00101       int numbytes();
00102   
00103       virtual void setAmp( float amplitude ) { mAmplitude = amplitude; }
00104       virtual void setDcOffset( float off ) { mDcOffset = off; }
00105       
00106    private: 
00110       void seek_data( int numBytes );
00111    
00115       syn::AudioFormat mSourceFormat, mDestFormat;
00116       std::vector<unsigned char> actual_data;
00117       std::vector<float> float_data;
00118       mutable std::fstream mFile; // mutable cause irix's is_open() is non-const.
00119       std::string mFilename;
00120       std::streamoff mDataPosition;
00121       int mNumBytes;
00122       int actual_samples_read;
00123       float mAmplitude, mDcOffset;
00124 
00126       /*#  WavHeader lnkWavHeader; */
00127    };
00128 }
00129 
00130 #endif

Generated at Mon Apr 15 09:26:08 2002 for subsynth by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001