AudioCodecs_Stream.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2004 MUSIC TECHNOLOGY GROUP (MTG)
00003  *                         UNIVERSITAT POMPEU FABRA
00004  *
00005  *
00006  * This program 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  * This program 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 this program; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  *
00020  */
00021 
00022 #ifndef __AUDIOCODECS_STREAM__
00023 #define __AUDIOCODECS_STREAM__
00024 
00025 #include "DataTypes.hxx"
00026 #include "DataTypes.hxx"
00027 #include <vector>
00028 
00029 namespace CLAM
00030 {
00031 
00032         class AudioFile;
00033 
00034 namespace AudioCodecs
00035 {
00043         class Stream
00044         {
00045         public:
00046                 Stream();
00047                 virtual ~Stream();
00049                 virtual void PrepareReading()   = 0;
00051                 virtual void PrepareWriting()   = 0;
00053                 virtual void Dispose()          = 0;
00056                 virtual void SeekTo(unsigned long framePosition) {}
00058                 virtual unsigned long GetFramePosition() const {return mFramePosition;}
00059         protected:
00061                 virtual void DiskToMemoryTransfer() = 0;
00063                 virtual void MemoryToDiskTransfer() = 0;
00064 
00065         public:
00067                 bool ReadData( int channel, TData* buffer, unsigned nFrames );
00069                 bool ReadData( TData** buffers, unsigned nFrames );
00071                 bool ReadData( int* channels, int nchannels,
00072                                TData** buffers, unsigned nFrames );
00073 
00075                 void WriteData( int channel, const TData* buffer, unsigned nFrames );
00077                 void WriteData( TData** const buffers, unsigned nFrames );
00079                 void WriteData( int* channels, int nchannels,
00080                                 TData** const buffers, unsigned nFrames );
00081 
00082         protected:
00083                 void SetChannels( unsigned nChannels );
00084 
00085         protected:
00086                 unsigned            mChannels;
00087                 std::vector<TData>  mInterleavedData;
00088                 bool                mEOFReached;
00089                 unsigned            mFramesLastRead;
00090                 unsigned long       mFramePosition;
00091 
00092         private:
00093                 void AdjustInterleavedBuffer( unsigned nFrames );
00094         };
00095 }
00096 
00097 }
00098 
00099 #endif // AudioCodecs_Stream.hxx
00100 
Generated by  doxygen 1.6.3