Mercurial > hg > sonic-annotator
comparison runner/MultiplexedReader.h @ 106:de76b2df518f multiplex
Start on multiplex implementation
author | Chris Cannam |
---|---|
date | Wed, 01 Oct 2014 18:38:32 +0100 |
parents | |
children | 7b60603966cf |
comparison
equal
deleted
inserted
replaced
105:76d9d86ae6cd | 106:de76b2df518f |
---|---|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ | |
2 | |
3 /* | |
4 Sonic Annotator | |
5 A utility for batch feature extraction from audio files. | |
6 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London. | |
7 Copyright 2007-2014 QMUL. | |
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 _MULTIPLEXED_READER_H_ | |
17 #define _MULTIPLEXED_READER_H_ | |
18 | |
19 #include "data/fileio/AudioFileReader.h" | |
20 | |
21 #include <QString> | |
22 #include <QList> | |
23 | |
24 typedef std::vector<float> SampleBlock; | |
25 | |
26 class MultiplexedReader : public QObject | |
27 { | |
28 Q_OBJECT | |
29 | |
30 public: | |
31 MultiplexedReader(QList<AudioFileReader *> readers); | |
32 virtual ~MultiplexedReader() { } | |
33 | |
34 //!!! the rest of this is currently still from AudioFileReader.h! Finish! | |
35 | |
36 | |
37 | |
38 | |
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: | |
88 int m_frameCount; | |
89 int m_channelCount; | |
90 int m_sampleRate; | |
91 }; | |
92 | |
93 #endif |