Audio.hxx

Go to the documentation of this file.
00001 /*
00002  * Copyright (c) 2001-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 _AUDIO_HXX
00023 #define _AUDIO_HXX
00024 
00025 
00026 //
00027 // Finally, we have decided to use a single buffer of TDatas, all
00028 // previously existing data formats have proven useless and have
00029 // been removed.
00030 //
00031 
00032 
00033 #include "DynamicType.hxx"
00034 #include "Array.hxx"
00035 #include "ProcessingData.hxx"
00036 #include "ProcessingDataConfig.hxx"
00037 #include "DataTypes.hxx"
00038 
00039 namespace CLAM {
00040 
00041 
00047         class Audio: public ProcessingData {
00048         public:
00049                 DYNAMIC_TYPE_USING_INTERFACE (Audio, 3, ProcessingData);
00050 
00052                 DYN_ATTRIBUTE (0, public, TData, SampleRate);
00054                 DYN_ATTRIBUTE (1, public, TTime, BeginTime);
00056                 DYN_ATTRIBUTE (2, public, DataArray, Buffer);
00057 
00058         protected:
00059 
00060                 void DefaultInit(); // To be used from the dynamic-type-generated constructor.
00061 
00062         public:
00063 
00064         
00066                 int GetSize() const {return GetBuffer().Size();}
00067 
00070                 TTime GetEndTime() const {return GetBeginTime()+GetTimeFromIndex(GetSize());}
00071 
00074                 TTime GetDuration() const {return GetTimeFromIndex(GetSize());}
00075 
00081                 void SetSize(int s);
00082 
00086                 void SetEndTime(TTime time);
00087 
00094                 void ResizeToEndTime(TTime time);
00095 
00099                 void SetDuration(TTime duration);
00100                 
00108                 void ResizeToDuration(TTime duration);
00109 
00116                 void GetAudioChunk(TTime beginTime, TTime endTime,Audio& chunk,bool configureChunk=true) const;
00117 
00124                 void GetAudioChunk(TIndex beginIndex,TIndex endIndex,Audio& chunk, bool configureChunk=true) const;
00125 
00134                 void GetAudioSlice(TTime beginTime, TTime endTime,Audio& slice,bool configureSlice=true) const;
00135 
00136 
00144                 void GetAudioSlice( TIndex beginIndex, TIndex endIndex, Audio& slice, bool configureSlice=true) const;
00145 
00150                 void SetAudioChunk(TTime beginTime,const Audio& chunk);
00151 
00156                 void SetAudioChunk(TIndex beginIndex,const Audio& chunk);
00157 
00158         private:
00163                 TTime GetTimeFromIndex(TIndex index) const;
00164 
00169                 TIndex GetIndexFromTime(TTime time) const;
00170         };
00171 };//namespace
00172 
00173 #endif
00174 

Generated on Tue Jun 19 20:34:52 2007 for CLAM-Development by  doxygen 1.5.2