Chris@148: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*-  vi:set ts=8 sts=4 sw=4: */
Chris@148: 
Chris@148: /*
Chris@148:     Sonic Visualiser
Chris@148:     An audio file viewer and annotation editor.
Chris@148:     Centre for Digital Music, Queen Mary, University of London.
Chris@148:     This file copyright 2006 Chris Cannam.
Chris@148:     
Chris@148:     This program is free software; you can redistribute it and/or
Chris@148:     modify it under the terms of the GNU General Public License as
Chris@148:     published by the Free Software Foundation; either version 2 of the
Chris@148:     License, or (at your option) any later version.  See the file
Chris@148:     COPYING included with this distribution for more information.
Chris@148: */
Chris@148: 
Chris@148: #ifndef _WAV_FILE_READER_H_
Chris@148: #define _WAV_FILE_READER_H_
Chris@148: 
Chris@148: #include "AudioFileReader.h"
Chris@148: 
Chris@148: #include <sndfile.h>
Chris@148: #include <QMutex>
Chris@148: 
Chris@157: #include <set>
Chris@157: 
Chris@148: class WavFileReader : public AudioFileReader
Chris@148: {
Chris@148: public:
Chris@176:     WavFileReader(QString path, bool fileUpdating = false);
Chris@148:     virtual ~WavFileReader();
Chris@148: 
Chris@148:     virtual QString getError() const { return m_error; }
Chris@148: 
Chris@148:     /** 
Chris@148:      * Must be safe to call from multiple threads with different
Chris@148:      * arguments on the same object at the same time.
Chris@148:      */
Chris@148:     virtual void getInterleavedFrames(size_t start, size_t count,
Chris@148: 				      SampleBlock &frames) const;
Chris@148:     
Chris@157:     static void getSupportedExtensions(std::set<QString> &extensions);
Chris@157: 
Chris@176:     bool isUpdating() const { return m_updating; }
Chris@176: 
Chris@175:     void updateFrameCount();
Chris@176:     void updateDone();
Chris@175: 
Chris@148: protected:
Chris@148:     SF_INFO m_fileInfo;
Chris@148:     SNDFILE *m_file;
Chris@148: 
Chris@148:     QString m_path;
Chris@148:     QString m_error;
Chris@148: 
Chris@148:     mutable QMutex m_mutex;
Chris@148:     mutable float *m_buffer;
Chris@148:     mutable size_t m_bufsiz;
Chris@148:     mutable size_t m_lastStart;
Chris@148:     mutable size_t m_lastCount;
Chris@176: 
Chris@176:     bool m_updating;
Chris@148: };
Chris@148: 
Chris@148: #endif