Mercurial > hg > sonic-annotator
comparison runner/MultiplexedReader.h @ 107:7b60603966cf multiplex
Implementation of MultiplexedReader -- now builds, not yet tested
author | Chris Cannam |
---|---|
date | Thu, 02 Oct 2014 08:16:42 +0100 |
parents | de76b2df518f |
children | 3f7c65f26559 |
comparison
equal
deleted
inserted
replaced
106:de76b2df518f | 107:7b60603966cf |
---|---|
19 #include "data/fileio/AudioFileReader.h" | 19 #include "data/fileio/AudioFileReader.h" |
20 | 20 |
21 #include <QString> | 21 #include <QString> |
22 #include <QList> | 22 #include <QList> |
23 | 23 |
24 typedef std::vector<float> SampleBlock; | 24 class MultiplexedReader : public AudioFileReader |
25 | |
26 class MultiplexedReader : public QObject | |
27 { | 25 { |
28 Q_OBJECT | 26 Q_OBJECT |
29 | 27 |
30 public: | 28 public: |
29 // I take ownership of readers | |
31 MultiplexedReader(QList<AudioFileReader *> readers); | 30 MultiplexedReader(QList<AudioFileReader *> readers); |
32 virtual ~MultiplexedReader() { } | 31 virtual ~MultiplexedReader(); |
33 | 32 |
34 //!!! the rest of this is currently still from AudioFileReader.h! Finish! | 33 virtual QString getError() const { return m_error; } |
34 virtual bool isQuicklySeekable() const { return m_quicklySeekable; } | |
35 | 35 |
36 virtual void getInterleavedFrames(int start, int count, | |
37 SampleBlock &frames) const; | |
36 | 38 |
39 virtual int getDecodeCompletion() const; | |
37 | 40 |
41 virtual bool isUpdating() const; | |
38 | 42 |
39 bool isOK() const { return (m_channelCount > 0); } | |
40 | |
41 virtual QString getError() const { return ""; } | |
42 | |
43 int getFrameCount() const { return m_frameCount; } | |
44 int getChannelCount() const { return m_channelCount; } | |
45 int getSampleRate() const { return m_sampleRate; } | |
46 | |
47 virtual int getNativeRate() const { return m_sampleRate; } // if resampled | |
48 | |
49 /** | |
50 * Return true if this file supports fast seek and random | |
51 * access. Typically this will be true for uncompressed formats | |
52 * and false for compressed ones. | |
53 */ | |
54 virtual bool isQuicklySeekable() const = 0; | |
55 | |
56 /** | |
57 * Return interleaved samples for count frames from index start. | |
58 * The resulting sample block will contain count * | |
59 * getChannelCount() samples (or fewer if end of file is reached). | |
60 * | |
61 * The subclass implementations of this function must be | |
62 * thread-safe -- that is, safe to call from multiple threads with | |
63 * different arguments on the same object at the same time. | |
64 */ | |
65 virtual void getInterleavedFrames(int start, int count, | |
66 SampleBlock &frames) const = 0; | |
67 | |
68 /** | |
69 * Return de-interleaved samples for count frames from index | |
70 * start. Implemented in this class (it calls | |
71 * getInterleavedFrames and de-interleaves). The resulting vector | |
72 * will contain getChannelCount() sample blocks of count samples | |
73 * each (or fewer if end of file is reached). | |
74 */ | |
75 virtual void getDeInterleavedFrames(int start, int count, | |
76 std::vector<SampleBlock> &frames) const; | |
77 | |
78 // only subclasses that do not know exactly how long the audio | |
79 // file is until it's been completely decoded should implement this | |
80 virtual int getDecodeCompletion() const { return 100; } // % | |
81 | |
82 virtual bool isUpdating() const { return false; } | |
83 | |
84 signals: | |
85 void frameCountChanged(); | |
86 | |
87 protected: | 43 protected: |
88 int m_frameCount; | 44 QString m_error; |
89 int m_channelCount; | 45 bool m_quicklySeekable; |
90 int m_sampleRate; | 46 QList<AudioFileReader *> m_readers; |
91 }; | 47 }; |
92 | 48 |
93 #endif | 49 #endif |