svcore  1.9
WavFileReader.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 2006 Chris Cannam.
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 _WAV_FILE_READER_H_
17 #define _WAV_FILE_READER_H_
18 
19 #include "AudioFileReader.h"
20 
21 #include <sndfile.h>
22 #include <QMutex>
23 
24 #include <set>
25 
37 {
38 public:
39  WavFileReader(FileSource source, bool fileUpdating = false);
40  virtual ~WavFileReader();
41 
42  virtual QString getLocation() const { return m_source.getLocation(); }
43  virtual QString getError() const { return m_error; }
44 
45  virtual bool isQuicklySeekable() const { return m_seekable; }
46 
51  virtual void getInterleavedFrames(int start, int count,
52  SampleBlock &frames) const;
53 
54  static void getSupportedExtensions(std::set<QString> &extensions);
55  static bool supportsExtension(QString ext);
56  static bool supportsContentType(QString type);
57  static bool supports(FileSource &source);
58 
59  virtual int getDecodeCompletion() const { return 100; }
60 
61  bool isUpdating() const { return m_updating; }
62 
63  void updateFrameCount();
64  void updateDone();
65 
66 protected:
67  SF_INFO m_fileInfo;
68  SNDFILE *m_file;
69 
71  QString m_path;
72  QString m_error;
73 
74  bool m_seekable;
75 
76  mutable QMutex m_mutex;
77  mutable float *m_buffer;
78  mutable int m_bufsiz;
79  mutable int m_lastStart;
80  mutable int m_lastCount;
81 
82  bool m_updating;
83 };
84 
85 #endif
SF_INFO m_fileInfo
Definition: WavFileReader.h:67
bool isUpdating() const
Definition: WavFileReader.h:61
WavFileReader(FileSource source, bool fileUpdating=false)
std::vector< float > SampleBlock
FileSource m_source
Definition: WavFileReader.h:70
virtual QString getLocation() const
Return the location of the audio data in the reader (as passed in to the FileSource constructor,...
Definition: WavFileReader.h:42
virtual int getDecodeCompletion() const
Definition: WavFileReader.h:59
virtual bool isQuicklySeekable() const
Return true if this file supports fast seek and random access.
Definition: WavFileReader.h:45
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 supportsExtension(QString ext)
float * m_buffer
Definition: WavFileReader.h:77
static bool supportsContentType(QString type)
static bool supports(FileSource &source)
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
static void getSupportedExtensions(std::set< QString > &extensions)
QString m_path
Definition: WavFileReader.h:71
SNDFILE * m_file
Definition: WavFileReader.h:68
virtual void getInterleavedFrames(int start, int count, SampleBlock &frames) const
Must be safe to call from multiple threads with different arguments on the same object at the same ti...
void updateFrameCount()
virtual QString getError() const
Definition: WavFileReader.h:43
virtual ~WavFileReader()
QString m_error
Definition: WavFileReader.h:72