svcore  1.9
DecodingWavFileReader.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2007 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 _DECODING_WAV_FILE_READER_H_
17 #define _DECODING_WAV_FILE_READER_H_
18 
19 #include "CodedAudioFileReader.h"
20 
21 #include "base/Thread.h"
22 
23 #include <set>
24 
25 class WavFileReader;
26 class ProgressReporter;
27 
29 {
30  Q_OBJECT
31 public:
32  enum ResampleMode {
33  ResampleAtOnce, // resample the file on construction, with progress dialog
34  ResampleThreaded // resample in a background thread after construction
35  };
36 
38  ResampleMode resampleMode,
39  CacheMode cacheMode,
40  int targetRate = 0,
41  bool normalised = false,
42  ProgressReporter *reporter = 0);
43  virtual ~DecodingWavFileReader();
44 
45  virtual QString getError() const { return m_error; }
46  virtual QString getLocation() const { return m_source.getLocation(); }
47  static void getSupportedExtensions(std::set<QString> &extensions);
48  static bool supportsExtension(QString ext);
49  static bool supportsContentType(QString type);
50  static bool supports(FileSource &source);
51 
52  virtual int getDecodeCompletion() const { return m_completion; }
53 
54  virtual bool isUpdating() const {
55  return m_decodeThread && m_decodeThread->isRunning();
56  }
57 
58 public slots:
59  void cancelled();
60 
61 protected:
63  QString m_path;
64  QString m_error;
68 
71 
72  void addBlock(const SampleBlock &frames);
73 
74  class DecodeThread : public Thread
75  {
76  public:
78  virtual void run();
79 
80  protected:
82  };
83 
85 };
86 
87 #endif
88 
DecodeThread(DecodingWavFileReader *reader)
static bool supportsContentType(QString type)
std::vector< float > SampleBlock
QString getLocation() const
Return the location filename or URL as passed to the constructor.
Definition: FileSource.cpp:595
Reader for audio files using libsndfile.
Definition: WavFileReader.h:36
static bool supports(FileSource &source)
virtual int getDecodeCompletion() const
DecodingWavFileReader(FileSource source, ResampleMode resampleMode, CacheMode cacheMode, int targetRate=0, bool normalised=false, ProgressReporter *reporter=0)
virtual QString getError() const
virtual bool isUpdating() const
static void getSupportedExtensions(std::set< QString > &extensions)
virtual QString getLocation() const
Return the location of the audio data in the reader (as passed in to the FileSource constructor,...
FileSource is a class used to refer to the contents of a file that may be either local or at a remote...
Definition: FileSource.h:59
void addBlock(const SampleBlock &frames)
Definition: Thread.h:24
ProgressReporter * m_reporter
static bool supportsExtension(QString ext)