svcore  1.9
WavFileReader Class Reference

Reader for audio files using libsndfile. More...

#include <WavFileReader.h>

Inheritance diagram for WavFileReader:
Collaboration diagram for WavFileReader:

Public Types

typedef std::map< QString, QString > TagMap
 

Signals

void frameCountChanged ()
 

Public Member Functions

 WavFileReader (FileSource source, bool fileUpdating=false)
 
virtual ~WavFileReader ()
 
virtual QString getLocation () const
 Return the location of the audio data in the reader (as passed in to the FileSource constructor, for example). More...
 
virtual QString getError () const
 
virtual bool isQuicklySeekable () const
 Return true if this file supports fast seek and random access. More...
 
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 time. More...
 
virtual int getDecodeCompletion () const
 
bool isUpdating () const
 
void updateFrameCount ()
 
void updateDone ()
 
bool isOK () const
 
int getFrameCount () const
 
int getChannelCount () const
 
int getSampleRate () const
 
virtual int getNativeRate () const
 
virtual QString getTitle () const
 Return the title of the work in the audio file, if known. More...
 
virtual QString getMaker () const
 Return the "maker" of the work in the audio file, if known. More...
 
virtual TagMap getTags () const
 
virtual void getDeInterleavedFrames (int start, int count, std::vector< SampleBlock > &frames) const
 Return de-interleaved samples for count frames from index start. More...
 

Static Public Member Functions

static void getSupportedExtensions (std::set< QString > &extensions)
 
static bool supportsExtension (QString ext)
 
static bool supportsContentType (QString type)
 
static bool supports (FileSource &source)
 

Protected Attributes

SF_INFO m_fileInfo
 
SNDFILE * m_file
 
FileSource m_source
 
QString m_path
 
QString m_error
 
bool m_seekable
 
QMutex m_mutex
 
float * m_buffer
 
int m_bufsiz
 
int m_lastStart
 
int m_lastCount
 
bool m_updating
 
int m_frameCount
 
int m_channelCount
 
int m_sampleRate
 

Detailed Description

Reader for audio files using libsndfile.

This is typically intended for seekable file types that can be read directly (e.g. WAV, AIFF etc).

Compressed files supported by libsndfile (e.g. Ogg, FLAC) should normally be read using DecodingWavFileReader instead (which decodes to an intermediate cached file).

Definition at line 36 of file WavFileReader.h.

Member Typedef Documentation

◆ TagMap

typedef std::map<QString, QString> AudioFileReader::TagMap
inherited

Definition at line 65 of file AudioFileReader.h.

Constructor & Destructor Documentation

◆ WavFileReader()

WavFileReader::WavFileReader ( FileSource  source,
bool  fileUpdating = false 
)

◆ ~WavFileReader()

WavFileReader::~WavFileReader ( )
virtual

Definition at line 81 of file WavFileReader.cpp.

References m_buffer, and m_file.

Member Function Documentation

◆ getLocation()

virtual QString WavFileReader::getLocation ( ) const
inlinevirtual

Return the location of the audio data in the reader (as passed in to the FileSource constructor, for example).

Reimplemented from AudioFileReader.

Definition at line 42 of file WavFileReader.h.

References FileSource::getLocation(), and m_source.

◆ getError()

virtual QString WavFileReader::getError ( ) const
inlinevirtual

◆ isQuicklySeekable()

virtual bool WavFileReader::isQuicklySeekable ( ) const
inlinevirtual

Return true if this file supports fast seek and random access.

Typically this will be true for uncompressed formats and false for compressed ones.

Implements AudioFileReader.

Definition at line 45 of file WavFileReader.h.

References m_seekable.

◆ getInterleavedFrames()

void WavFileReader::getInterleavedFrames ( int  start,
int  count,
SampleBlock frames 
) const
virtual

Must be safe to call from multiple threads with different arguments on the same object at the same time.

Implements AudioFileReader.

Definition at line 126 of file WavFileReader.cpp.

References m_buffer, m_bufsiz, AudioFileReader::m_channelCount, m_file, m_fileInfo, m_lastCount, m_lastStart, and m_mutex.

Referenced by DecodingWavFileReader::DecodingWavFileReader(), CodedAudioFileReader::getInterleavedFrames(), and DecodingWavFileReader::DecodeThread::run().

◆ getSupportedExtensions()

void WavFileReader::getSupportedExtensions ( std::set< QString > &  extensions)
static

◆ supportsExtension()

bool WavFileReader::supportsExtension ( QString  ext)
static

Definition at line 216 of file WavFileReader.cpp.

References getSupportedExtensions().

Referenced by supports(), and DecodingWavFileReader::supportsExtension().

◆ supportsContentType()

bool WavFileReader::supportsContentType ( QString  type)
static

Definition at line 224 of file WavFileReader.cpp.

Referenced by supports(), and DecodingWavFileReader::supportsContentType().

◆ supports()

bool WavFileReader::supports ( FileSource source)
static

◆ getDecodeCompletion()

virtual int WavFileReader::getDecodeCompletion ( ) const
inlinevirtual

Reimplemented from AudioFileReader.

Definition at line 59 of file WavFileReader.h.

◆ isUpdating()

bool WavFileReader::isUpdating ( ) const
inlinevirtual

Reimplemented from AudioFileReader.

Definition at line 61 of file WavFileReader.h.

References m_updating.

◆ updateFrameCount()

◆ updateDone()

void WavFileReader::updateDone ( )

Definition at line 119 of file WavFileReader.cpp.

References m_updating, and updateFrameCount().

Referenced by WritableWaveFileModel::setCompletion().

◆ isOK()

◆ getFrameCount()

◆ getChannelCount()

◆ getSampleRate()

int AudioFileReader::getSampleRate ( ) const
inlineinherited

◆ getNativeRate()

virtual int AudioFileReader::getNativeRate ( ) const
inlinevirtualinherited

Reimplemented in CodedAudioFileReader.

Definition at line 43 of file AudioFileReader.h.

References AudioFileReader::m_sampleRate.

Referenced by WaveFileModel::getNativeRate().

◆ getTitle()

virtual QString AudioFileReader::getTitle ( ) const
inlinevirtualinherited

Return the title of the work in the audio file, if known.

This may be implemented by subclasses that support file tagging. This is not the same thing as the file name.

Reimplemented in OggVorbisFileReader, and MP3FileReader.

Definition at line 56 of file AudioFileReader.h.

Referenced by WaveFileModel::getTitle(), and WaveFileModel::WaveFileModel().

◆ getMaker()

virtual QString AudioFileReader::getMaker ( ) const
inlinevirtualinherited

Return the "maker" of the work in the audio file, if known.

This could represent almost anything (band, composer, conductor, artist etc).

Reimplemented in OggVorbisFileReader, and MP3FileReader.

Definition at line 63 of file AudioFileReader.h.

Referenced by WaveFileModel::getMaker().

◆ getTags()

virtual TagMap AudioFileReader::getTags ( ) const
inlinevirtualinherited

Reimplemented in OggVorbisFileReader, and MP3FileReader.

Definition at line 66 of file AudioFileReader.h.

◆ getDeInterleavedFrames()

void AudioFileReader::getDeInterleavedFrames ( int  start,
int  count,
std::vector< SampleBlock > &  frames 
) const
virtualinherited

Return de-interleaved samples for count frames from index start.

Implemented in this class (it calls getInterleavedFrames and de-interleaves). The resulting vector will contain getChannelCount() sample blocks of count samples each (or fewer if end of file is reached).

Definition at line 19 of file AudioFileReader.cpp.

References AudioFileReader::getChannelCount(), and AudioFileReader::getInterleavedFrames().

◆ frameCountChanged

void AudioFileReader::frameCountChanged ( )
signalinherited

Referenced by updateFrameCount().

Member Data Documentation

◆ m_fileInfo

SF_INFO WavFileReader::m_fileInfo
protected

Definition at line 67 of file WavFileReader.h.

Referenced by getInterleavedFrames(), updateFrameCount(), and WavFileReader().

◆ m_file

SNDFILE* WavFileReader::m_file
protected

◆ m_source

FileSource WavFileReader::m_source
protected

Definition at line 70 of file WavFileReader.h.

Referenced by getLocation().

◆ m_path

QString WavFileReader::m_path
protected

Definition at line 71 of file WavFileReader.h.

Referenced by updateFrameCount(), and WavFileReader().

◆ m_error

QString WavFileReader::m_error
protected

Definition at line 72 of file WavFileReader.h.

Referenced by getError(), and WavFileReader().

◆ m_seekable

bool WavFileReader::m_seekable
protected

Definition at line 74 of file WavFileReader.h.

Referenced by isQuicklySeekable(), and WavFileReader().

◆ m_mutex

QMutex WavFileReader::m_mutex
mutableprotected

Definition at line 76 of file WavFileReader.h.

Referenced by getInterleavedFrames(), and updateFrameCount().

◆ m_buffer

float* WavFileReader::m_buffer
mutableprotected

Definition at line 77 of file WavFileReader.h.

Referenced by getInterleavedFrames(), and ~WavFileReader().

◆ m_bufsiz

int WavFileReader::m_bufsiz
mutableprotected

Definition at line 78 of file WavFileReader.h.

Referenced by getInterleavedFrames().

◆ m_lastStart

int WavFileReader::m_lastStart
mutableprotected

Definition at line 79 of file WavFileReader.h.

Referenced by getInterleavedFrames().

◆ m_lastCount

int WavFileReader::m_lastCount
mutableprotected

Definition at line 80 of file WavFileReader.h.

Referenced by getInterleavedFrames().

◆ m_updating

bool WavFileReader::m_updating
protected

Definition at line 82 of file WavFileReader.h.

Referenced by isUpdating(), and updateDone().

◆ m_frameCount

◆ m_channelCount

◆ m_sampleRate


The documentation for this class was generated from the following files: