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 00025 typedef std::vector<float> SampleBlock; 00026 00027 class AudioFileReader : public QObject 00028 { 00029 Q_OBJECT 00030 00031 public: 00032 virtual ~AudioFileReader() { } 00033 00034 bool isOK() const { return (m_channelCount > 0); } 00035 00036 virtual QString getError() const { return ""; } 00037 00038 size_t getFrameCount() const { return m_frameCount; } 00039 size_t getChannelCount() const { return m_channelCount; } 00040 size_t getSampleRate() const { return m_sampleRate; } 00041 size_t getNativeRate() const { return m_sampleRate; } // if resampled 00042 00047 virtual QString getLocation() const { return ""; } 00048 00054 virtual QString getTitle() const { return ""; } 00055 00061 virtual QString getMaker() const { return ""; } 00062 00072 virtual void getInterleavedFrames(size_t start, size_t count, 00073 SampleBlock &frames) const = 0; 00074 00082 virtual void getDeInterleavedFrames(size_t start, size_t count, 00083 std::vector<SampleBlock> &frames) const; 00084 00085 // only subclasses that do not know exactly how long the audio 00086 // file is until it's been completely decoded should implement this 00087 virtual int getDecodeCompletion() const { return 100; } // % 00088 00089 virtual bool isUpdating() const { return false; } 00090 00091 signals: 00092 void frameCountChanged(); 00093 00094 protected: 00095 size_t m_frameCount; 00096 size_t m_channelCount; 00097 size_t m_sampleRate; 00098 }; 00099 00100 #endif
1.5.1