svcore  1.9
WavFileReader.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 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 
00036 class WavFileReader : public AudioFileReader
00037 {
00038 public:
00039     WavFileReader(FileSource source, bool fileUpdating = false);
00040     virtual ~WavFileReader();
00041 
00042     virtual QString getLocation() const { return m_source.getLocation(); }
00043     virtual QString getError() const { return m_error; }
00044 
00045     virtual bool isQuicklySeekable() const { return m_seekable; }
00046     
00051     virtual void getInterleavedFrames(int start, int count,
00052                                       SampleBlock &frames) const;
00053     
00054     static void getSupportedExtensions(std::set<QString> &extensions);
00055     static bool supportsExtension(QString ext);
00056     static bool supportsContentType(QString type);
00057     static bool supports(FileSource &source);
00058 
00059     virtual int getDecodeCompletion() const { return 100; }
00060 
00061     bool isUpdating() const { return m_updating; }
00062 
00063     void updateFrameCount();
00064     void updateDone();
00065 
00066 protected:
00067     SF_INFO m_fileInfo;
00068     SNDFILE *m_file;
00069 
00070     FileSource m_source;
00071     QString m_path;
00072     QString m_error;
00073 
00074     bool m_seekable;
00075 
00076     mutable QMutex m_mutex;
00077     mutable float *m_buffer;
00078     mutable int m_bufsiz;
00079     mutable int m_lastStart;
00080     mutable int m_lastCount;
00081 
00082     bool m_updating;
00083 };
00084 
00085 #endif