svcore
1.9
|
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ 00002 00003 /* 00004 Sonic Visualiser 00005 An audio file viewer and annotation editor. 00006 Centre for Digital Music, Queen Mary, University of London. 00007 This file copyright 2006 Chris Cannam. 00008 00009 This program is free software; you can redistribute it and/or 00010 modify it under the terms of the GNU General Public License as 00011 published by the Free Software Foundation; either version 2 of the 00012 License, or (at your option) any later version. See the file 00013 COPYING included with this distribution for more information. 00014 */ 00015 00016 #ifndef _AUDIO_FILE_READER_H_ 00017 #define _AUDIO_FILE_READER_H_ 00018 00019 #include <QString> 00020 00021 #include "FileSource.h" 00022 00023 #include <vector> 00024 #include <map> 00025 00026 typedef std::vector<float> SampleBlock; 00027 00028 class AudioFileReader : public QObject 00029 { 00030 Q_OBJECT 00031 00032 public: 00033 virtual ~AudioFileReader() { } 00034 00035 bool isOK() const { return (m_channelCount > 0); } 00036 00037 virtual QString getError() const { return ""; } 00038 00039 int getFrameCount() const { return m_frameCount; } 00040 int getChannelCount() const { return m_channelCount; } 00041 int getSampleRate() const { return m_sampleRate; } 00042 00043 virtual int getNativeRate() const { return m_sampleRate; } // if resampled 00044 00049 virtual QString getLocation() const { return ""; } 00050 00056 virtual QString getTitle() const { return ""; } 00057 00063 virtual QString getMaker() const { return ""; } 00064 00065 typedef std::map<QString, QString> TagMap; 00066 virtual TagMap getTags() const { return TagMap(); } 00067 00073 virtual bool isQuicklySeekable() const = 0; 00074 00084 virtual void getInterleavedFrames(int start, int count, 00085 SampleBlock &frames) const = 0; 00086 00094 virtual void getDeInterleavedFrames(int start, int count, 00095 std::vector<SampleBlock> &frames) const; 00096 00097 // only subclasses that do not know exactly how long the audio 00098 // file is until it's been completely decoded should implement this 00099 virtual int getDecodeCompletion() const { return 100; } // % 00100 00101 virtual bool isUpdating() const { return false; } 00102 00103 signals: 00104 void frameCountChanged(); 00105 00106 protected: 00107 int m_frameCount; 00108 int m_channelCount; 00109 int m_sampleRate; 00110 }; 00111 00112 #endif