ResamplingWavFileReader.h

Go to the documentation of this file.
00001 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
00002 
00003 /*
00004     Sonic Visualiser
00005     An audio file viewer and annotation editor.
00006     Centre for Digital Music, Queen Mary, University of London.
00007     This file copyright 2007 QMUL.
00008     
00009     This program is free software; you can redistribute it and/or
00010     modify it under the terms of the GNU General Public License as
00011     published by the Free Software Foundation; either version 2 of the
00012     License, or (at your option) any later version.  See the file
00013     COPYING included with this distribution for more information.
00014 */
00015 
00016 #ifndef _RESAMPLING_WAV_FILE_READER_H_
00017 #define _RESAMPLING_WAV_FILE_READER_H_
00018 
00019 #include "CodedAudioFileReader.h"
00020 
00021 #include "base/Thread.h"
00022 
00023 #include <set>
00024 
00025 class WavFileReader;
00026 class QProgressDialog;
00027 
00028 class ResamplingWavFileReader : public CodedAudioFileReader
00029 {
00030 public:
00031     enum ResampleMode {
00032         ResampleAtOnce, // resample the file on construction, with progress dialog
00033         ResampleThreaded // resample in a background thread after construction
00034     };
00035 
00036     ResamplingWavFileReader(FileSource source,
00037                             ResampleMode resampleMode,
00038                             CacheMode cacheMode,
00039                             size_t targetRate = 0);
00040     virtual ~ResamplingWavFileReader();
00041 
00042     virtual QString getError() const { return m_error; }
00043     virtual QString getLocation() const { return m_source.getLocation(); }
00044     static void getSupportedExtensions(std::set<QString> &extensions);
00045     static bool supportsExtension(QString ext);
00046     static bool supportsContentType(QString type);
00047     static bool supports(FileSource &source);
00048 
00049     virtual int getDecodeCompletion() const { return m_completion; }
00050 
00051     virtual bool isUpdating() const {
00052         return m_decodeThread && m_decodeThread->isRunning();
00053     }
00054 
00055 protected:
00056     FileSource m_source;
00057     QString m_path;
00058     QString m_error;
00059     bool m_cancelled;
00060     size_t m_processed;
00061     int m_completion;
00062 
00063     WavFileReader *m_original;
00064     QProgressDialog *m_progress;
00065 
00066     void addBlock(const SampleBlock &frames);
00067     
00068     class DecodeThread : public Thread
00069     {
00070     public:
00071         DecodeThread(ResamplingWavFileReader *reader) : m_reader(reader) { }
00072         virtual void run();
00073 
00074     protected:
00075         ResamplingWavFileReader *m_reader;
00076     };
00077 
00078     DecodeThread *m_decodeThread;
00079 };
00080 
00081 #endif
00082 

Generated on Wed Feb 20 15:45:27 2008 for SonicVisualiser by  doxygen 1.5.1