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 #include <typeinfo>
00026 
00027 //
00028 // Finally, we have decided to use a single buffer of TDatas, all
00029 // previously existing data formats have proven useless and have
00030 // been removed.
00031 //
00032 
00033 
00034 #include "DynamicType.hxx"
00035 #include "Array.hxx"
00036 #include "ProcessingData.hxx"
00037 #include "ProcessingDataConfig.hxx"
00038 #include "DataTypes.hxx"
00039 
00040 namespace CLAM {
00041 
00042 
00048         class Audio: public ProcessingData {
00049         public:
00050                 DYNAMIC_TYPE_USING_INTERFACE (Audio, 3, ProcessingData);
00051 
00053                 DYN_ATTRIBUTE (0, public, TData, SampleRate);
00055                 DYN_ATTRIBUTE (1, public, TTime, BeginTime);
00057                 DYN_ATTRIBUTE (2, public, DataArray, Buffer);
00058 
00059         protected:
00060 
00061                 void DefaultInit(); // To be used from the dynamic-type-generated constructor.
00062 
00063         public:
00064                 ~Audio();
00065         
00067                 int GetSize() const {return GetBuffer().Size();}
00068 
00071                 TTime GetEndTime() const {return GetBeginTime()+GetTimeFromIndex(GetSize());}
00072 
00075                 TTime GetDuration() const {return GetTimeFromIndex(GetSize());}
00076 
00082                 void SetSize(int s);
00083 
00087                 void SetEndTime(TTime time);
00088 
00095                 void ResizeToEndTime(TTime time);
00096 
00100                 void SetDuration(TTime duration);
00101                 
00109                 void ResizeToDuration(TTime duration);
00110 
00117                 void GetAudioChunk(TTime beginTime, TTime endTime,Audio& chunk,bool configureChunk=true) const;
00118 
00125                 void GetAudioChunk(TIndex beginIndex,TIndex endIndex,Audio& chunk, bool configureChunk=true) const;
00126 
00135                 void GetAudioSlice(TTime beginTime, TTime endTime,Audio& slice,bool configureSlice=true) const;
00136 
00137 
00145                 void GetAudioSlice( TIndex beginIndex, TIndex endIndex, Audio& slice, bool configureSlice=true) const;
00146 
00151                 void SetAudioChunk(TTime beginTime,const Audio& chunk);
00152 
00157                 void SetAudioChunk(TIndex beginIndex,const Audio& chunk);
00158 
00159         private:
00164                 TTime GetTimeFromIndex(TIndex index) const;
00165 
00170                 TIndex GetIndexFromTime(TTime time) const;
00171         };
00172 };//namespace
00173 
00174 #endif
00175 
Generated by  doxygen 1.6.3