pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
plonk_AudioFileMetaData.h
00001 /*
00002  -------------------------------------------------------------------------------
00003  This file is part of the Plink, Plonk, Plank libraries
00004   by Martin Robinson
00005  
00006  http://code.google.com/p/pl-nk/
00007  
00008  Copyright University of the West of England, Bristol 2011-14
00009  All rights reserved.
00010  
00011  Redistribution and use in source and binary forms, with or without
00012  modification, are permitted provided that the following conditions are met:
00013  
00014  * Redistributions of source code must retain the above copyright
00015    notice, this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright
00017    notice, this list of conditions and the following disclaimer in the
00018    documentation and/or other materials provided with the distribution.
00019  * Neither the name of University of the West of England, Bristol nor 
00020    the names of its contributors may be used to endorse or promote products
00021    derived from this software without specific prior written permission.
00022  
00023  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00026  DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF THE WEST OF ENGLAND, BRISTOL BE 
00027  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00028  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
00029  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00030  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00031  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
00032  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00033  
00034  This software makes use of third party libraries. For more information see:
00035  doc/license.txt included in the distribution.
00036  -------------------------------------------------------------------------------
00037  */
00038 
00039 #ifndef PLONK_AUDIOFILEMETADATA_H
00040 #define PLONK_AUDIOFILEMETADATA_H
00041 
00042 #include "plonk_AudioFile.h"
00043 #include "../../containers/plonk_Text.h"
00044 
00045 class AudioFileCuePoint : public PlankSharedPtrContainer<PlankAudioFileCuePointRef>
00046 {
00047 public:
00048     typedef PlankAudioFileCuePointExtra Extra;
00049     typedef PlankSharedPtrContainer<PlankAudioFileCuePointRef> Base;
00050     typedef Base::Weak Weak;
00051     static AudioFileCuePoint getNull() throw();
00052     AudioFileCuePoint() throw();
00053     AudioFileCuePoint (PlankAudioFileCuePointRef p) throw();
00054     AudioFileCuePoint (AudioFileCuePoint const& copy) throw();
00055     AudioFileCuePoint (Base const& base) throw();
00056     AudioFileCuePoint (Weak const& weak) throw();
00057     AudioFileCuePoint& operator= (AudioFileCuePoint const &other) throw();
00058     
00059     AudioFileCuePoint (const UnsignedInt cueID, const double position,
00060                        Text const& label = Text::getEmpty(),
00061                        AudioFile::CuePointTypes type = AudioFile::CuePointCuePoint,
00062                        Text const& comment = Text::getEmpty()) throw();
00063     
00064     AudioFileCuePoint& setCopy (AudioFileCuePoint source) throw();
00065     AudioFileCuePoint& setPosition (const double position) throw();
00066     AudioFileCuePoint& setID (const UnsignedInt cueID) throw();
00067     AudioFileCuePoint& setLabel (const char* label) throw();
00068     AudioFileCuePoint& setComment (const char* comment) throw();
00069     AudioFileCuePoint& setType (const AudioFile::CuePointTypes type) throw();
00070     AudioFileCuePoint& setExtra (UnsignedInt purpose, UnsignedShort country, UnsignedShort language, UnsignedShort dialect, UnsignedShort codePage) throw();
00071     
00072     double getPosition() const throw();
00073     LongLong getFramePosition (const double sampleRate) const throw();
00074     UnsignedInt getID() const throw();
00075     const char* getLabel() const throw();
00076     const char* getComment() const throw();
00077     AudioFile::CuePointTypes getType() const throw();
00078     AudioFileCuePoint::Extra* getExtra() throw();
00079     const AudioFileCuePoint::Extra* getExtra() const throw();
00080     
00081     AudioFileCuePoint& offsetPosition (const double offset) throw();
00082 
00083 private:
00084     PlankAudioFileCuePointRef incrementRefCountAndGetPeer() throw();
00085 };
00086 
00087 class AudioFileRegion : public PlankSharedPtrContainer<PlankAudioFileRegionRef>
00088 {
00089 public:
00090     typedef PlankSharedPtrContainer<PlankAudioFileRegionRef> Base;
00091     typedef Base::Weak Weak;
00092     static AudioFileRegion getNull() throw();
00093     AudioFileRegion() throw();
00094     AudioFileRegion (PlankAudioFileRegionRef p) throw();
00095     AudioFileRegion (AudioFileRegion const& copy) throw();
00096     AudioFileRegion (Base const& base) throw();
00097     AudioFileRegion (Weak const& weak) throw();
00098     AudioFileRegion& operator= (AudioFileRegion const &other) throw();
00099 
00100     AudioFileRegion (const UnsignedInt cueID, const double start, const double end, const double anchor,
00101                      Text const& label = Text::getEmpty(),
00102                      AudioFile::RegionTypes type = AudioFile::RegionRegion,
00103                      Text const& comment = Text::getEmpty()) throw();
00104     
00105     AudioFileCuePoint getAnchorCuePoint() const throw();
00106     AudioFileCuePoint getStartCuePoint() const throw();
00107     AudioFileCuePoint getEndCuePoint() const throw();
00108     double getAnchorPosition() const throw();
00109     double getStartPosition() const throw();
00110     double getEndPosition() const throw();
00111     double getLength() const throw();
00112     AudioFile::RegionTypes getType() const throw();
00113     UnsignedInt getOptions() const throw();
00114     UnsignedInt getFraction() const throw();
00115     UnsignedInt getPlayCount() const throw();
00116     const char* getLabel() const throw();
00117     const char* getComment() const throw();
00118     AudioFileRegion& setAnchorPosition (const double position) throw();
00119     AudioFileRegion& setStartPosition (const double position) throw();
00120     AudioFileRegion& setEndPosition (const double position) throw();
00121     AudioFileRegion& setLength (const double length) throw();
00122     AudioFileRegion& setType (const AudioFile::RegionTypes type) throw();
00123     AudioFileRegion& setOptions (const UnsignedInt options) throw();
00124     AudioFileRegion& setFraction (const double fraction) throw();
00125     AudioFileRegion& setPlayCount (const UnsignedInt playCount) throw();
00126     AudioFileRegion& setLabel (const char* label) throw();
00127     AudioFileRegion& setComment (const char* comment) throw();
00128     void getRegion (double& start, double& end, double& anchor) throw();
00129     AudioFileRegion& setRegion (const double start, const double end) throw();
00130     AudioFileRegion& setRegionWithAnchor (const double start, const double end, const double anchor) throw();
00131     AudioFileRegion& offsetPosition (const double offset) throw();
00132 
00133 private:
00134     PlankAudioFileRegionRef incrementRefCountAndGetPeer() throw();
00135 };
00136 
00137 typedef PlankSharedPtrArrayContainer<AudioFileCuePoint> AudioFileCuePointArray;
00138 typedef PlankSharedPtrArrayContainer<AudioFileRegion>   AudioFileRegionArray;
00139 
00140 class AudioFileMetaData : public PlankSharedPtrContainer<PlankAudioFileMetaDataRef>
00141 {
00142 public:
00143     typedef PlankSharedPtrContainer<PlankAudioFileMetaDataRef> Base;
00144     typedef Base::Weak Weak;
00145     static AudioFileMetaData getNull() throw();
00146     AudioFileMetaData() throw();
00147     AudioFileMetaData (PlankAudioFileMetaDataRef p) throw();
00148     AudioFileMetaData (AudioFileMetaData const& copy) throw();
00149     AudioFileMetaData (Base const& base) throw();
00150     AudioFileMetaData (Weak const& weak) throw();
00151     AudioFileMetaData& operator= (AudioFileMetaData const &other) throw();
00152 
00153     AudioFileMetaData& setEditCount (const UnsignedInt count) throw();
00154     UnsignedInt getEditCount() throw();
00155     
00156     AudioFileMetaData& setInstrumentData (const int baseNote, const int detune, const int gain, const int lowNote, const int highNote, const int lowVelocity, const int highVelocity) throw();
00157     void getInstrumentData (int& baseNote, int& detune, int& gain, int& lowNote, int& highNote, int& lowVelocity, int& highVelocity) throw();
00158     AudioFileMetaData& setSamplerData (const UnsignedInt manufacturer, const UnsignedInt product, const UnsignedInt samplePeriod, const UnsignedInt smpteFormat, const UnsignedInt smpteOffset) throw();
00159     void getSamplerData (UnsignedInt& manufacturer, UnsignedInt& product, UnsignedInt& samplePeriod, UnsignedInt& smpteFormat, UnsignedInt& smpteOffset) throw();
00160     
00161 //    PlankDynamicArrayRef getExtraSamplerData () throw();
00162     
00163     AudioFileMetaData& setDescriptionComment (const char* text) throw();
00164     AudioFileMetaData& setOriginatorArtist (const char* text) throw();
00165     AudioFileMetaData& setOriginatorRef (const char* text) throw();
00166     AudioFileMetaData& setOriginationDate (const char* text) throw();
00167     AudioFileMetaData& setOriginationTime (const char* text) throw();
00168     
00169     const char* getDescriptionComment() throw();
00170     const char* getOriginatorArtist() throw();
00171     const char* getOriginatorRef() throw();
00172     const char* getOriginationDate() throw();
00173     const char* getOriginationTime() throw();
00174     
00175     AudioFileMetaData& setPerformer (const char* text) throw();
00176     AudioFileMetaData& setTitle (const char* text) throw();
00177     AudioFileMetaData& setAlbum (const char* text) throw();
00178     AudioFileMetaData& setGenre (const char* text) throw();
00179     AudioFileMetaData& setLyrics (const char* text) throw();
00180     AudioFileMetaData& setVendor (const char* text) throw();
00181     AudioFileMetaData& setISRC (const char* text) throw();
00182     
00183     const char* getPerformer() throw();
00184     const char* getTitle() throw();
00185     const char* getAlbum() throw();
00186     const char* getGenre() throw();
00187     const char* getLyrics() throw();
00188     const char* getVendor() throw();
00189     const char* getISRC() throw();
00190     
00191     AudioFileMetaData& addPerformer (const char* text) throw();
00192     AudioFileMetaData& addDescriptionComment (const char* text) throw();
00193     AudioFileMetaData& addOriginatorArtist (const char* text) throw();
00194     AudioFileMetaData& addOriginatorRef (const char* text) throw();
00195     AudioFileMetaData& addGenre (const char* text) throw();
00196     
00197 //    AudioFileMetaData& setArt (PlankConstantP data, const PlankL size) throw();
00198 //    PlankResult getArt (PlankConstantP* data, PlankL* size) throw();
00199     
00200     AudioFileMetaData& setYear (const int year) throw();
00201     int getYear() throw();
00202     
00203     AudioFileMetaData& setTrackInfo (const int trackNum, const int trackTotal) throw();
00204     void getTrackInfo (int& trackNum, int& trackTotal) throw();
00205     
00206     AudioFileMetaData& setTimeRef (const LongLong timeRef) throw();
00207     LongLong getTimeRef() throw();
00208     
00209     AudioFileMetaData& setSource (const UnsignedInt source) throw();
00210     UnsignedInt getSource() throw();
00211     
00212     AudioFileMetaData& setUMID (const UnsignedChar* umid) throw();
00213     const UnsignedChar* getUMID() throw();
00214     
00215     AudioFileCuePointArray getCuePoints() const throw();
00216     AudioFileRegionArray getRegions() const throw();
00217     AudioFileRegionArray getLoopPoints() const throw();
00218     
00219     AudioFileMetaData& convertCuePointsToRegions (const double totalDuration, const bool removeCuePoints) throw();
00220     AudioFileMetaData& sortCuePointsByPosition() throw();
00221     AudioFileMetaData& sortCuePointsByID() throw();
00222     
00223     friend class AudioFileReaderInternal;
00224     template<class SampleType> friend class AudioFileWriterInternal;
00225     
00226 private:
00227     PlankAudioFileMetaDataRef incrementRefCountAndGetPeer() throw();
00228 };
00229 
00230 
00231 #endif // PLONK_AUDIOFILEMETADATA_H
 All Classes Functions Typedefs Enumerations Enumerator Properties