svcore  1.9
AudioFileReader.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef _AUDIO_FILE_READER_H_
17 #define _AUDIO_FILE_READER_H_
18 
19 #include <QString>
20 
21 #include "FileSource.h"
22 
23 #include <vector>
24 #include <map>
25 
26 typedef std::vector<float> SampleBlock;
27 
28 class AudioFileReader : public QObject
29 {
30  Q_OBJECT
31 
32 public:
33  virtual ~AudioFileReader() { }
34 
35  bool isOK() const { return (m_channelCount > 0); }
36 
37  virtual QString getError() const { return ""; }
38 
39  int getFrameCount() const { return m_frameCount; }
40  int getChannelCount() const { return m_channelCount; }
41  int getSampleRate() const { return m_sampleRate; }
42 
43  virtual int getNativeRate() const { return m_sampleRate; } // if resampled
44 
49  virtual QString getLocation() const { return ""; }
50 
56  virtual QString getTitle() const { return ""; }
57 
63  virtual QString getMaker() const { return ""; }
64 
65  typedef std::map<QString, QString> TagMap;
66  virtual TagMap getTags() const { return TagMap(); }
67 
73  virtual bool isQuicklySeekable() const = 0;
74 
84  virtual void getInterleavedFrames(int start, int count,
85  SampleBlock &frames) const = 0;
86 
94  virtual void getDeInterleavedFrames(int start, int count,
95  std::vector<SampleBlock> &frames) const;
96 
97  // only subclasses that do not know exactly how long the audio
98  // file is until it's been completely decoded should implement this
99  virtual int getDecodeCompletion() const { return 100; } // %
100 
101  virtual bool isUpdating() const { return false; }
102 
103 signals:
104  void frameCountChanged();
105 
106 protected:
110 };
111 
112 #endif
virtual QString getError() const
int getChannelCount() const
std::vector< float > SampleBlock
virtual QString getMaker() const
Return the "maker" of the work in the audio file, if known.
virtual TagMap getTags() const
bool isOK() const
virtual void getInterleavedFrames(int start, int count, SampleBlock &frames) const =0
Return interleaved samples for count frames from index start.
std::map< QString, QString > TagMap
int getFrameCount() const
void frameCountChanged()
virtual QString getLocation() const
Return the location of the audio data in the reader (as passed in to the FileSource constructor,...
virtual int getDecodeCompletion() const
virtual ~AudioFileReader()
virtual int getNativeRate() const
virtual void getDeInterleavedFrames(int start, int count, std::vector< SampleBlock > &frames) const
Return de-interleaved samples for count frames from index start.
virtual bool isQuicklySeekable() const =0
Return true if this file supports fast seek and random access.
int getSampleRate() const
virtual bool isUpdating() const
virtual QString getTitle() const
Return the title of the work in the audio file, if known.