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 SV_AUDIO_FILE_READER_H
17 #define SV_AUDIO_FILE_READER_H
18 
19 #include <QString>
20 
21 #include "base/BaseTypes.h"
22 #include "FileSource.h"
23 
24 #include <vector>
25 #include <map>
26 
27 class AudioFileReader : public QObject
28 {
29  Q_OBJECT
30 
31 public:
32  virtual ~AudioFileReader() { }
33 
38  bool isOK() const { return (m_channelCount > 0); }
39 
43  virtual QString getError() const { return ""; }
44 
50 
54  int getChannelCount() const { return m_channelCount; }
55 
63 
69  virtual sv_samplerate_t getNativeRate() const { return m_sampleRate; }
70 
78  virtual QString getLocation() const = 0;
79 
96  virtual QString getLocalFilename() const = 0;
97 
103  virtual QString getTitle() const = 0;
104 
110  virtual QString getMaker() const = 0;
111 
117  typedef std::map<QString, QString> TagMap;
118  virtual TagMap getTags() const { return TagMap(); }
119 
125  virtual bool isQuicklySeekable() const = 0;
126 
135  virtual int getDecodeCompletion() const { return 100; }
136 
141  virtual bool isUpdating() const { return false; }
142 
153  sv_frame_t count) const = 0;
154 
162  virtual std::vector<floatvec_t> getDeInterleavedFrames(sv_frame_t start,
163  sv_frame_t count) const;
164 
165 signals:
166  void frameCountChanged();
167 
168 protected:
172 };
173 
174 #endif
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
virtual sv_samplerate_t getNativeRate() const
Return the native samplerate of the file.
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
virtual QString getMaker() const =0
Return the "maker" of the work in the audio file, if known.
virtual floatvec_t getInterleavedFrames(sv_frame_t start, sv_frame_t count) const =0
Return interleaved samples for count frames from index start.
virtual TagMap getTags() const
virtual QString getTitle() const =0
Return the title of the work in the audio file, if known.
virtual bool isUpdating() const
Return true if decoding is still in progress and the frame count may change.
std::vector< float, breakfastquay::StlAllocator< float > > floatvec_t
Definition: BaseTypes.h:53
std::map< QString, QString > TagMap
Return any tag pairs picked up from the audio file.
virtual QString getError() const
If isOK() is false, return an error string.
void frameCountChanged()
virtual QString getLocation() const =0
Return the location of the audio data in the reader (as passed in to the FileSource constructor...
virtual QString getLocalFilename() const =0
Return the local file path of the audio data.
virtual ~AudioFileReader()
virtual std::vector< floatvec_t > getDeInterleavedFrames(sv_frame_t start, sv_frame_t count) const
Return de-interleaved samples for count frames from index start.
bool isOK() const
Return true if the file was opened successfully and no error has subsequently occurred.
sv_frame_t m_frameCount
virtual int getDecodeCompletion() const
Return a percentage value indicating how far through decoding the audio file we are.
virtual bool isQuicklySeekable() const =0
Return true if this file supports fast seek and random access.
sv_frame_t getFrameCount() const
Return the number of audio sample frames (i.e.
sv_samplerate_t m_sampleRate
sv_samplerate_t getSampleRate() const
Return the samplerate at which the file is being read.
int getChannelCount() const
Return the number of channels in the file.