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 2006 Chris Cannam. 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 _WAV_FILE_READER_H_ 00017 #define _WAV_FILE_READER_H_ 00018 00019 #include "AudioFileReader.h" 00020 00021 #include <sndfile.h> 00022 #include <QMutex> 00023 00024 #include <set> 00025 00026 class WavFileReader : public AudioFileReader 00027 { 00028 public: 00029 WavFileReader(FileSource source, bool fileUpdating = false); 00030 virtual ~WavFileReader(); 00031 00032 virtual QString getLocation() const { return m_source.getLocation(); } 00033 virtual QString getError() const { return m_error; } 00034 00039 virtual void getInterleavedFrames(size_t start, size_t count, 00040 SampleBlock &frames) const; 00041 00042 static void getSupportedExtensions(std::set<QString> &extensions); 00043 static bool supportsExtension(QString ext); 00044 static bool supportsContentType(QString type); 00045 static bool supports(FileSource &source); 00046 00047 virtual int getDecodeCompletion() const { return 100; } 00048 00049 bool isUpdating() const { return m_updating; } 00050 00051 void updateFrameCount(); 00052 void updateDone(); 00053 00054 protected: 00055 SF_INFO m_fileInfo; 00056 SNDFILE *m_file; 00057 00058 FileSource m_source; 00059 QString m_path; 00060 QString m_error; 00061 00062 mutable QMutex m_mutex; 00063 mutable float *m_buffer; 00064 mutable size_t m_bufsiz; 00065 mutable size_t m_lastStart; 00066 mutable size_t m_lastCount; 00067 00068 bool m_updating; 00069 }; 00070 00071 #endif
1.5.1