annotate data/fileio/DecodingWavFileReader.h @ 1675:6804af71b7be osc-script

Write path points
author Chris Cannam
date Thu, 28 Mar 2019 10:39:02 +0000
parents ce185d4dd408
children 14747f24ad04
rev   line source
Chris@297 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@297 2
Chris@297 3 /*
Chris@297 4 Sonic Visualiser
Chris@297 5 An audio file viewer and annotation editor.
Chris@297 6 Centre for Digital Music, Queen Mary, University of London.
Chris@297 7 This file copyright 2007 QMUL.
Chris@297 8
Chris@297 9 This program is free software; you can redistribute it and/or
Chris@297 10 modify it under the terms of the GNU General Public License as
Chris@297 11 published by the Free Software Foundation; either version 2 of the
Chris@297 12 License, or (at your option) any later version. See the file
Chris@297 13 COPYING included with this distribution for more information.
Chris@297 14 */
Chris@297 15
Chris@1581 16 #ifndef SV_DECODING_WAV_FILE_READER_H
Chris@1581 17 #define SV_DECODING_WAV_FILE_READER_H
Chris@297 18
Chris@297 19 #include "CodedAudioFileReader.h"
Chris@297 20
Chris@297 21 #include "base/Thread.h"
Chris@297 22
Chris@297 23 #include <set>
Chris@297 24
Chris@297 25 class WavFileReader;
Chris@392 26 class ProgressReporter;
Chris@297 27
Chris@823 28 class DecodingWavFileReader : public CodedAudioFileReader
Chris@297 29 {
Chris@392 30 Q_OBJECT
Chris@297 31 public:
Chris@823 32 DecodingWavFileReader(FileSource source,
Chris@1097 33 DecodeMode decodeMode, // determines when to resample
Chris@920 34 CacheMode cacheMode,
Chris@1040 35 sv_samplerate_t targetRate = 0,
Chris@920 36 bool normalised = false,
Chris@920 37 ProgressReporter *reporter = 0);
Chris@823 38 virtual ~DecodingWavFileReader();
Chris@297 39
Chris@1592 40 QString getTitle() const override { return m_title; }
Chris@1592 41 QString getMaker() const override { return m_maker; }
Chris@1592 42
Chris@1580 43 QString getError() const override { return m_error; }
Chris@1580 44 QString getLocation() const override { return m_source.getLocation(); }
Chris@1599 45
Chris@297 46 static void getSupportedExtensions(std::set<QString> &extensions);
Chris@316 47 static bool supportsExtension(QString ext);
Chris@316 48 static bool supportsContentType(QString type);
Chris@317 49 static bool supports(FileSource &source);
Chris@297 50
Chris@1580 51 int getDecodeCompletion() const override { return m_completion; }
Chris@297 52
Chris@1580 53 bool isUpdating() const override {
Chris@297 54 return m_decodeThread && m_decodeThread->isRunning();
Chris@297 55 }
Chris@297 56
Chris@392 57 public slots:
Chris@392 58 void cancelled();
Chris@392 59
Chris@297 60 protected:
Chris@317 61 FileSource m_source;
Chris@1592 62 QString m_title;
Chris@1592 63 QString m_maker;
Chris@297 64 QString m_path;
Chris@297 65 QString m_error;
Chris@297 66 bool m_cancelled;
Chris@1038 67 sv_frame_t m_processed;
Chris@297 68 int m_completion;
Chris@297 69
Chris@297 70 WavFileReader *m_original;
Chris@392 71 ProgressReporter *m_reporter;
Chris@297 72
Chris@1326 73 void addBlock(const floatvec_t &frames);
Chris@297 74
Chris@297 75 class DecodeThread : public Thread
Chris@297 76 {
Chris@297 77 public:
Chris@823 78 DecodeThread(DecodingWavFileReader *reader) : m_reader(reader) { }
Chris@1580 79 void run() override;
Chris@297 80
Chris@297 81 protected:
Chris@823 82 DecodingWavFileReader *m_reader;
Chris@297 83 };
Chris@297 84
Chris@297 85 DecodeThread *m_decodeThread;
Chris@297 86 };
Chris@297 87
Chris@297 88 #endif
Chris@297 89