annotate 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
rev   line source
Chris@106 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@106 2
Chris@106 3 /*
Chris@106 4 Sonic Annotator
Chris@106 5 A utility for batch feature extraction from audio files.
Chris@106 6 Mark Levy, Chris Sutton and Chris Cannam, Queen Mary, University of London.
Chris@106 7 Copyright 2007-2014 QMUL.
Chris@106 8
Chris@106 9 This program is free software; you can redistribute it and/or
Chris@106 10 modify it under the terms of the GNU General Public License as
Chris@106 11 published by the Free Software Foundation; either version 2 of the
Chris@106 12 License, or (at your option) any later version. See the file
Chris@106 13 COPYING included with this distribution for more information.
Chris@106 14 */
Chris@106 15
Chris@106 16 #ifndef _MULTIPLEXED_READER_H_
Chris@106 17 #define _MULTIPLEXED_READER_H_
Chris@106 18
Chris@106 19 #include "data/fileio/AudioFileReader.h"
Chris@106 20
Chris@106 21 #include <QString>
Chris@106 22 #include <QList>
Chris@106 23
Chris@106 24 typedef std::vector<float> SampleBlock;
Chris@106 25
Chris@106 26 class MultiplexedReader : public QObject
Chris@106 27 {
Chris@106 28 Q_OBJECT
Chris@106 29
Chris@106 30 public:
Chris@106 31 MultiplexedReader(QList<AudioFileReader *> readers);
Chris@106 32 virtual ~MultiplexedReader() { }
Chris@106 33
Chris@106 34 //!!! the rest of this is currently still from AudioFileReader.h! Finish!
Chris@106 35
Chris@106 36
Chris@106 37
Chris@106 38
Chris@106 39 bool isOK() const { return (m_channelCount > 0); }
Chris@106 40
Chris@106 41 virtual QString getError() const { return ""; }
Chris@106 42
Chris@106 43 int getFrameCount() const { return m_frameCount; }
Chris@106 44 int getChannelCount() const { return m_channelCount; }
Chris@106 45 int getSampleRate() const { return m_sampleRate; }
Chris@106 46
Chris@106 47 virtual int getNativeRate() const { return m_sampleRate; } // if resampled
Chris@106 48
Chris@106 49 /**
Chris@106 50 * Return true if this file supports fast seek and random
Chris@106 51 * access. Typically this will be true for uncompressed formats
Chris@106 52 * and false for compressed ones.
Chris@106 53 */
Chris@106 54 virtual bool isQuicklySeekable() const = 0;
Chris@106 55
Chris@106 56 /**
Chris@106 57 * Return interleaved samples for count frames from index start.
Chris@106 58 * The resulting sample block will contain count *
Chris@106 59 * getChannelCount() samples (or fewer if end of file is reached).
Chris@106 60 *
Chris@106 61 * The subclass implementations of this function must be
Chris@106 62 * thread-safe -- that is, safe to call from multiple threads with
Chris@106 63 * different arguments on the same object at the same time.
Chris@106 64 */
Chris@106 65 virtual void getInterleavedFrames(int start, int count,
Chris@106 66 SampleBlock &frames) const = 0;
Chris@106 67
Chris@106 68 /**
Chris@106 69 * Return de-interleaved samples for count frames from index
Chris@106 70 * start. Implemented in this class (it calls
Chris@106 71 * getInterleavedFrames and de-interleaves). The resulting vector
Chris@106 72 * will contain getChannelCount() sample blocks of count samples
Chris@106 73 * each (or fewer if end of file is reached).
Chris@106 74 */
Chris@106 75 virtual void getDeInterleavedFrames(int start, int count,
Chris@106 76 std::vector<SampleBlock> &frames) const;
Chris@106 77
Chris@106 78 // only subclasses that do not know exactly how long the audio
Chris@106 79 // file is until it's been completely decoded should implement this
Chris@106 80 virtual int getDecodeCompletion() const { return 100; } // %
Chris@106 81
Chris@106 82 virtual bool isUpdating() const { return false; }
Chris@106 83
Chris@106 84 signals:
Chris@106 85 void frameCountChanged();
Chris@106 86
Chris@106 87 protected:
Chris@106 88 int m_frameCount;
Chris@106 89 int m_channelCount;
Chris@106 90 int m_sampleRate;
Chris@106 91 };
Chris@106 92
Chris@106 93 #endif