annotate data/fileio/DecodingWavFileReader.h @ 1886:f803d3c33f76 tip

Switch off copious debug in soft synth driving
author Chris Cannam
date Fri, 14 Aug 2020 10:44:44 +0100
parents 14747f24ad04
children
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@1858 24 #include <atomic>
Chris@297 25
Chris@297 26 class WavFileReader;
Chris@392 27 class ProgressReporter;
Chris@297 28
Chris@823 29 class DecodingWavFileReader : public CodedAudioFileReader
Chris@297 30 {
Chris@392 31 Q_OBJECT
Chris@297 32 public:
Chris@823 33 DecodingWavFileReader(FileSource source,
Chris@1097 34 DecodeMode decodeMode, // determines when to resample
Chris@920 35 CacheMode cacheMode,
Chris@1040 36 sv_samplerate_t targetRate = 0,
Chris@920 37 bool normalised = false,
Chris@920 38 ProgressReporter *reporter = 0);
Chris@823 39 virtual ~DecodingWavFileReader();
Chris@297 40
Chris@1592 41 QString getTitle() const override { return m_title; }
Chris@1592 42 QString getMaker() const override { return m_maker; }
Chris@1592 43
Chris@1580 44 QString getError() const override { return m_error; }
Chris@1580 45 QString getLocation() const override { return m_source.getLocation(); }
Chris@1599 46
Chris@297 47 static void getSupportedExtensions(std::set<QString> &extensions);
Chris@316 48 static bool supportsExtension(QString ext);
Chris@316 49 static bool supportsContentType(QString type);
Chris@317 50 static bool supports(FileSource &source);
Chris@297 51
Chris@1580 52 int getDecodeCompletion() const override { return m_completion; }
Chris@297 53
Chris@1580 54 bool isUpdating() const override {
Chris@297 55 return m_decodeThread && m_decodeThread->isRunning();
Chris@297 56 }
Chris@297 57
Chris@392 58 public slots:
Chris@392 59 void cancelled();
Chris@392 60
Chris@297 61 protected:
Chris@317 62 FileSource m_source;
Chris@1592 63 QString m_title;
Chris@1592 64 QString m_maker;
Chris@297 65 QString m_path;
Chris@297 66 QString m_error;
Chris@1858 67 std::atomic<bool> m_cancelled;
Chris@1038 68 sv_frame_t m_processed;
Chris@297 69 int m_completion;
Chris@297 70
Chris@297 71 WavFileReader *m_original;
Chris@392 72 ProgressReporter *m_reporter;
Chris@297 73
Chris@1326 74 void addBlock(const floatvec_t &frames);
Chris@297 75
Chris@297 76 class DecodeThread : public Thread
Chris@297 77 {
Chris@297 78 public:
Chris@823 79 DecodeThread(DecodingWavFileReader *reader) : m_reader(reader) { }
Chris@1580 80 void run() override;
Chris@297 81
Chris@297 82 protected:
Chris@823 83 DecodingWavFileReader *m_reader;
Chris@297 84 };
Chris@297 85
Chris@297 86 DecodeThread *m_decodeThread;
Chris@297 87 };
Chris@297 88
Chris@297 89 #endif
Chris@297 90