svcore
1.9
|
#include <CodedAudioFileReader.h>
Public Types | |
enum | CacheMode { CacheInTemporaryFile, CacheInMemory } |
enum | DecodeMode { DecodeAtOnce, DecodeThreaded } |
typedef std::map< QString, QString > | TagMap |
Return any tag pairs picked up from the audio file. More... | |
Signals | |
void | progress (int) |
void | frameCountChanged () |
Public Member Functions | |
virtual | ~CodedAudioFileReader () |
floatvec_t | getInterleavedFrames (sv_frame_t start, sv_frame_t count) const override |
Return interleaved samples for count frames from index start. More... | |
sv_samplerate_t | getNativeRate () const override |
Return the native samplerate of the file. More... | |
QString | getLocalFilename () const override |
Return the local file path of the audio data. More... | |
bool | isQuicklySeekable () const override |
Intermediate cache means all CodedAudioFileReaders are quickly seekable. More... | |
bool | isOK () const |
Return true if the file was opened successfully and no error has subsequently occurred. More... | |
virtual QString | getError () const |
If isOK() is false, return an error string. More... | |
sv_frame_t | getFrameCount () const |
Return the number of audio sample frames (i.e. More... | |
int | getChannelCount () const |
Return the number of channels in the file. More... | |
sv_samplerate_t | getSampleRate () const |
Return the samplerate at which the file is being read. More... | |
virtual QString | getLocation () const =0 |
Return the location of the audio data in the reader (as passed in to the FileSource constructor, for example). More... | |
virtual QString | getTitle () const =0 |
Return the title of the work in the audio file, if known. More... | |
virtual QString | getMaker () const =0 |
Return the "maker" of the work in the audio file, if known. More... | |
virtual TagMap | getTags () const |
virtual int | getDecodeCompletion () const |
Return a percentage value indicating how far through decoding the audio file we are. More... | |
virtual bool | isUpdating () const |
Return true if decoding is still in progress and the frame count may change. More... | |
virtual std::vector< floatvec_t > | getDeInterleavedFrames (sv_frame_t start, sv_frame_t count) const |
Return de-interleaved samples for count frames from index start. More... | |
Protected Member Functions | |
CodedAudioFileReader (CacheMode cacheMode, sv_samplerate_t targetRate, bool normalised) | |
void | initialiseDecodeCache () |
void | setFramesToTrim (sv_frame_t fromStart, sv_frame_t fromEnd) |
void | addSamplesToDecodeCache (float **samples, sv_frame_t nframes) |
void | addSamplesToDecodeCache (float *samplesInterleaved, sv_frame_t nframes) |
void | addSamplesToDecodeCache (const floatvec_t &interleaved) |
void | finishDecodeCache () |
bool | isDecodeCacheInitialised () const |
void | startSerialised (QString id, const std::atomic< bool > *cancelled) |
void | endSerialised () |
Protected Attributes | |
QMutex | m_cacheMutex |
CacheMode | m_cacheMode |
floatvec_t | m_data |
QMutex | m_dataLock |
bool | m_initialised |
Serialiser * | m_serialiser |
sv_samplerate_t | m_fileRate |
QString | m_cacheFileName |
SNDFILE * | m_cacheFileWritePtr |
WavFileReader * | m_cacheFileReader |
float * | m_cacheWriteBuffer |
sv_frame_t | m_cacheWriteBufferIndex |
sv_frame_t | m_cacheWriteBufferFrames |
breakfastquay::Resampler * | m_resampler |
float * | m_resampleBuffer |
int | m_resampleBufferFrames |
sv_frame_t | m_fileFrameCount |
bool | m_normalised |
float | m_max |
float | m_gain |
sv_frame_t | m_trimFromStart |
sv_frame_t | m_trimFromEnd |
sv_frame_t | m_clippedCount |
sv_frame_t | m_firstNonzero |
sv_frame_t | m_lastNonzero |
sv_frame_t | m_frameCount |
int | m_channelCount |
sv_samplerate_t | m_sampleRate |
Private Member Functions | |
void | pushCacheWriteBufferMaybe (bool final) |
sv_frame_t | pushBuffer (float *interleaved, sv_frame_t sz, bool final) |
void | pushBufferResampling (float *interleaved, sv_frame_t sz, double ratio, bool final) |
void | pushBufferNonResampling (float *interleaved, sv_frame_t sz) |
Detailed Description
Definition at line 40 of file CodedAudioFileReader.h.
Member Typedef Documentation
|
inherited |
Return any tag pairs picked up from the audio file.
See also getTitle and getMaker, and note that a reader which does not implement getTags may still return values from those.
Definition at line 117 of file AudioFileReader.h.
Member Enumeration Documentation
Enumerator | |
---|---|
CacheInTemporaryFile | |
CacheInMemory |
Definition at line 47 of file CodedAudioFileReader.h.
Enumerator | |
---|---|
DecodeAtOnce | |
DecodeThreaded |
Definition at line 52 of file CodedAudioFileReader.h.
Constructor & Destructor Documentation
|
virtual |
Definition at line 70 of file CodedAudioFileReader.cpp.
References endSerialised(), m_cacheFileName, m_cacheFileReader, m_cacheFileWritePtr, m_cacheMutex, m_cacheWriteBuffer, m_data, m_resampleBuffer, m_resampler, m_serialiser, StorageAdviser::MemoryAllocation, StorageAdviser::notifyDoneAllocation(), and SVDEBUG.
|
protected |
Definition at line 34 of file CodedAudioFileReader.cpp.
References CacheInTemporaryFile, AudioFileReader::m_frameCount, AudioFileReader::m_sampleRate, and SVDEBUG.
Member Function Documentation
|
overridevirtual |
Return interleaved samples for count frames from index start.
The resulting vector will contain count * getChannelCount() samples (or fewer if end of file is reached).
The subclass implementations of this function must be thread-safe – that is, safe to call from multiple threads with different arguments on the same object at the same time.
Implements AudioFileReader.
Definition at line 550 of file CodedAudioFileReader.cpp.
References CacheInMemory, CacheInTemporaryFile, WavFileReader::getInterleavedFrames(), AudioFileReader::isOK(), m_cacheFileReader, m_cacheMode, AudioFileReader::m_channelCount, m_data, m_dataLock, m_gain, m_initialised, m_normalised, and SVDEBUG.
|
inlineoverridevirtual |
Return the native samplerate of the file.
This will differ from getSampleRate() if the file is being resampled because it was requested to open at a different rate from native.
Reimplemented from AudioFileReader.
Definition at line 59 of file CodedAudioFileReader.h.
|
inlineoverridevirtual |
Return the local file path of the audio data.
This is the filesystem location most likely to contain readable audio data, but it may be in a different place or format from the originally specified location - for example, if the file has been retrieved and decoded, then it will be the (possibly temporary) decode target file.
This returns a non-empty value only if there is some local filename that contains exactly the audio data being provided by this reader. In some cases this may not exist, for example when a file has been resampled or normalised directly into a memory buffer. In this case, return an empty string.
See also getLocation().
Implements AudioFileReader.
Definition at line 61 of file CodedAudioFileReader.h.
|
inlineoverridevirtual |
Intermediate cache means all CodedAudioFileReaders are quickly seekable.
Implements AudioFileReader.
Definition at line 64 of file CodedAudioFileReader.h.
|
signal |
Referenced by DecodingWavFileReader::addBlock().
|
protected |
Definition at line 127 of file CodedAudioFileReader.cpp.
References CacheInMemory, CacheInTemporaryFile, WavFileReader::getError(), TempDirectory::getInstance(), AudioFileReader::isOK(), m_cacheFileName, m_cacheFileReader, m_cacheFileWritePtr, m_cacheMode, m_cacheMutex, m_cacheWriteBuffer, m_cacheWriteBufferFrames, m_cacheWriteBufferIndex, AudioFileReader::m_channelCount, m_data, m_fileRate, m_initialised, m_resampleBuffer, m_resampleBufferFrames, m_resampler, AudioFileReader::m_sampleRate, m_trimFromEnd, SVCERR, and SVDEBUG.
Referenced by MP3FileReader::accept(), BQAFileReader::BQAFileReader(), and DecodingWavFileReader::DecodingWavFileReader().
|
protected |
Definition at line 101 of file CodedAudioFileReader.cpp.
References m_trimFromEnd, and m_trimFromStart.
Referenced by MP3FileReader::filter(), and MP3FileReader::MP3FileReader().
|
protected |
Definition at line 251 of file CodedAudioFileReader.cpp.
References m_cacheMutex, m_cacheWriteBuffer, m_cacheWriteBufferIndex, AudioFileReader::m_channelCount, m_initialised, m_trimFromStart, and pushCacheWriteBufferMaybe().
Referenced by MP3FileReader::accept(), DecodingWavFileReader::addBlock(), and BQAFileReader::BQAFileReader().
|
protected |
Definition at line 276 of file CodedAudioFileReader.cpp.
References m_cacheMutex, m_cacheWriteBuffer, m_cacheWriteBufferIndex, AudioFileReader::m_channelCount, m_initialised, m_trimFromStart, and pushCacheWriteBufferMaybe().
|
protected |
Definition at line 301 of file CodedAudioFileReader.cpp.
References m_cacheMutex, m_cacheWriteBuffer, m_cacheWriteBufferIndex, m_initialised, m_trimFromStart, and pushCacheWriteBufferMaybe().
|
protected |
Definition at line 321 of file CodedAudioFileReader.cpp.
References CacheInTemporaryFile, m_cacheFileReader, m_cacheFileWritePtr, m_cacheMode, m_cacheMutex, m_cacheWriteBuffer, m_clippedCount, m_data, m_fileFrameCount, m_firstNonzero, AudioFileReader::m_frameCount, m_gain, m_initialised, m_lastNonzero, m_max, m_normalised, m_resampleBuffer, m_resampler, StorageAdviser::MemoryAllocation, StorageAdviser::notifyPlannedAllocation(), pushCacheWriteBufferMaybe(), SVDEBUG, and WavFileReader::updateFrameCount().
Referenced by BQAFileReader::BQAFileReader(), DecodingWavFileReader::DecodingWavFileReader(), and MP3FileReader::MP3FileReader().
|
inlineprotected |
Definition at line 87 of file CodedAudioFileReader.h.
Referenced by MP3FileReader::accept(), BQAFileReader::BQAFileReader(), DecodingWavFileReader::DecodingWavFileReader(), and MP3FileReader::MP3FileReader().
|
protected |
Definition at line 108 of file CodedAudioFileReader.cpp.
References m_serialiser.
Referenced by MP3FileReader::accept().
|
protected |
Definition at line 118 of file CodedAudioFileReader.cpp.
References m_serialiser.
Referenced by BQAFileReader::BQAFileReader(), DecodingWavFileReader::DecodingWavFileReader(), MP3FileReader::MP3FileReader(), and ~CodedAudioFileReader().
|
private |
Definition at line 372 of file CodedAudioFileReader.cpp.
References m_cacheFileReader, m_cacheWriteBuffer, m_cacheWriteBufferFrames, m_cacheWriteBufferIndex, AudioFileReader::m_channelCount, m_trimFromEnd, pushBuffer(), and WavFileReader::updateFrameCount().
Referenced by addSamplesToDecodeCache(), and finishDecodeCache().
|
private |
Definition at line 414 of file CodedAudioFileReader.cpp.
References m_fileFrameCount, m_fileRate, m_resampler, AudioFileReader::m_sampleRate, pushBufferNonResampling(), and pushBufferResampling().
Referenced by pushCacheWriteBufferMaybe().
|
private |
Definition at line 496 of file CodedAudioFileReader.cpp.
References AudioFileReader::m_channelCount, m_fileFrameCount, AudioFileReader::m_frameCount, m_resampleBuffer, m_resampleBufferFrames, m_resampler, pushBufferNonResampling(), and SVDEBUG.
Referenced by pushBuffer().
|
private |
Definition at line 433 of file CodedAudioFileReader.cpp.
References CacheInMemory, CacheInTemporaryFile, TempDirectory::getInstance(), m_cacheFileWritePtr, m_cacheMode, AudioFileReader::m_channelCount, m_clippedCount, m_data, m_dataLock, m_firstNonzero, AudioFileReader::m_frameCount, m_gain, m_lastNonzero, m_max, m_normalised, and SVCERR.
Referenced by pushBuffer(), and pushBufferResampling().
|
inlineinherited |
Return true if the file was opened successfully and no error has subsequently occurred.
Definition at line 38 of file AudioFileReader.h.
References AudioFileReader::m_channelCount.
Referenced by AudioFileReaderFactory::createReader(), DecodingWavFileReader::DecodingWavFileReader(), AudioFileSizeEstimator::estimate(), ReadOnlyWaveFileModel::getData(), getInterleavedFrames(), ReadOnlyWaveFileModel::getMultiChannelData(), initialiseDecodeCache(), and ReadOnlyWaveFileModel::isOK().
|
inlinevirtualinherited |
If isOK() is false, return an error string.
Reimplemented in MP3FileReader, WavFileReader, BQAFileReader, and DecodingWavFileReader.
Definition at line 43 of file AudioFileReader.h.
|
inlineinherited |
Return the number of audio sample frames (i.e.
samples per channel) in the file.
Definition at line 49 of file AudioFileReader.h.
References AudioFileReader::m_frameCount.
Referenced by DecodingWavFileReader::addBlock(), DecodingWavFileReader::DecodingWavFileReader(), AudioFileSizeEstimator::estimate(), ReadOnlyWaveFileModel::getFrameCount(), and WritableWaveFileModel::normaliseToTarget().
|
inlineinherited |
Return the number of channels in the file.
Definition at line 54 of file AudioFileReader.h.
References AudioFileReader::m_channelCount.
Referenced by WritableWaveFileModel::addSamples(), DecodingWavFileReader::DecodingWavFileReader(), AudioFileSizeEstimator::estimate(), ReadOnlyWaveFileModel::getChannelCount(), and AudioFileReader::getDeInterleavedFrames().
|
inlineinherited |
Return the samplerate at which the file is being read.
This is the rate requested when the file was opened, which may differ from the native rate of the file (in which case the file will be resampled as it is read).
Definition at line 62 of file AudioFileReader.h.
References AudioFileReader::m_sampleRate.
Referenced by AudioFileReaderFactory::createReader(), DecodingWavFileReader::DecodingWavFileReader(), AudioFileSizeEstimator::estimate(), ReadOnlyWaveFileModel::getSampleRate(), and ReadOnlyWaveFileModel::ReadOnlyWaveFileModel().
|
pure virtualinherited |
Return the location of the audio data in the reader (as passed in to the FileSource constructor, for example).
This might be a remote URL.
See also getLocalFilename().
Implemented in MP3FileReader, WavFileReader, BQAFileReader, and DecodingWavFileReader.
Referenced by ReadOnlyWaveFileModel::getLocation(), and AudioFileReader::getNativeRate().
|
pure virtualinherited |
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.
Implemented in MP3FileReader, WavFileReader, BQAFileReader, and DecodingWavFileReader.
Referenced by AudioFileReader::getNativeRate(), ReadOnlyWaveFileModel::getTitle(), and ReadOnlyWaveFileModel::ReadOnlyWaveFileModel().
|
pure virtualinherited |
Return the "maker" of the work in the audio file, if known.
This could represent almost anything (band, composer, conductor, artist etc).
Implemented in MP3FileReader, WavFileReader, BQAFileReader, and DecodingWavFileReader.
Referenced by ReadOnlyWaveFileModel::getMaker(), and AudioFileReader::getNativeRate().
|
inlinevirtualinherited |
Reimplemented in MP3FileReader.
Definition at line 118 of file AudioFileReader.h.
References AudioFileReader::isQuicklySeekable().
|
inlinevirtualinherited |
Return a percentage value indicating how far through decoding the audio file we are.
This should be implemented by subclasses that will not know exactly how long the audio file is (in sample frames) until it has been completely decoded. A reader that initialises the frame count directly within its constructor should always return 100 from this.
Reimplemented in MP3FileReader, WavFileReader, BQAFileReader, and DecodingWavFileReader.
Definition at line 135 of file AudioFileReader.h.
Referenced by ReadOnlyWaveFileModel::isReady().
|
inlinevirtualinherited |
Return true if decoding is still in progress and the frame count may change.
Reimplemented in MP3FileReader, WavFileReader, BQAFileReader, and DecodingWavFileReader.
Definition at line 141 of file AudioFileReader.h.
References AudioFileReader::frameCountChanged(), AudioFileReader::getDeInterleavedFrames(), and AudioFileReader::getInterleavedFrames().
Referenced by ReadOnlyWaveFileModel::isReady().
|
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 21 of file AudioFileReader.cpp.
References AudioFileReader::getChannelCount(), and AudioFileReader::getInterleavedFrames().
Referenced by AudioFileReader::isUpdating().
|
signalinherited |
Referenced by AudioFileReader::isUpdating(), and WavFileReader::updateFrameCount().
Member Data Documentation
|
protected |
Definition at line 104 of file CodedAudioFileReader.h.
Referenced by addSamplesToDecodeCache(), finishDecodeCache(), initialiseDecodeCache(), and ~CodedAudioFileReader().
|
protected |
Definition at line 105 of file CodedAudioFileReader.h.
Referenced by MP3FileReader::accept(), finishDecodeCache(), getInterleavedFrames(), initialiseDecodeCache(), and pushBufferNonResampling().
|
protected |
Definition at line 106 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), getInterleavedFrames(), initialiseDecodeCache(), pushBufferNonResampling(), and ~CodedAudioFileReader().
|
mutableprotected |
Definition at line 107 of file CodedAudioFileReader.h.
Referenced by getInterleavedFrames(), and pushBufferNonResampling().
|
protected |
Definition at line 108 of file CodedAudioFileReader.h.
Referenced by addSamplesToDecodeCache(), finishDecodeCache(), getInterleavedFrames(), and initialiseDecodeCache().
|
protected |
Definition at line 109 of file CodedAudioFileReader.h.
Referenced by endSerialised(), startSerialised(), and ~CodedAudioFileReader().
|
protected |
Definition at line 110 of file CodedAudioFileReader.h.
Referenced by MP3FileReader::accept(), DecodingWavFileReader::addBlock(), BQAFileReader::BQAFileReader(), DecodingWavFileReader::DecodingWavFileReader(), initialiseDecodeCache(), MP3FileReader::MP3FileReader(), and pushBuffer().
|
protected |
Definition at line 112 of file CodedAudioFileReader.h.
Referenced by initialiseDecodeCache(), and ~CodedAudioFileReader().
|
protected |
Definition at line 113 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), initialiseDecodeCache(), pushBufferNonResampling(), and ~CodedAudioFileReader().
|
protected |
Definition at line 114 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), getInterleavedFrames(), initialiseDecodeCache(), pushCacheWriteBufferMaybe(), and ~CodedAudioFileReader().
|
protected |
Definition at line 115 of file CodedAudioFileReader.h.
Referenced by addSamplesToDecodeCache(), finishDecodeCache(), initialiseDecodeCache(), pushCacheWriteBufferMaybe(), and ~CodedAudioFileReader().
|
protected |
Definition at line 116 of file CodedAudioFileReader.h.
Referenced by addSamplesToDecodeCache(), initialiseDecodeCache(), and pushCacheWriteBufferMaybe().
|
protected |
Definition at line 117 of file CodedAudioFileReader.h.
Referenced by initialiseDecodeCache(), and pushCacheWriteBufferMaybe().
|
protected |
Definition at line 119 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), initialiseDecodeCache(), pushBuffer(), pushBufferResampling(), and ~CodedAudioFileReader().
|
protected |
Definition at line 120 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), initialiseDecodeCache(), pushBufferResampling(), and ~CodedAudioFileReader().
|
protected |
Definition at line 121 of file CodedAudioFileReader.h.
Referenced by initialiseDecodeCache(), and pushBufferResampling().
|
protected |
Definition at line 122 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), pushBuffer(), and pushBufferResampling().
|
protected |
Definition at line 124 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), getInterleavedFrames(), and pushBufferNonResampling().
|
protected |
Definition at line 125 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), and pushBufferNonResampling().
|
protected |
Definition at line 126 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), getInterleavedFrames(), and pushBufferNonResampling().
|
protected |
Definition at line 128 of file CodedAudioFileReader.h.
Referenced by addSamplesToDecodeCache(), and setFramesToTrim().
|
protected |
Definition at line 129 of file CodedAudioFileReader.h.
Referenced by initialiseDecodeCache(), pushCacheWriteBufferMaybe(), and setFramesToTrim().
|
protected |
Definition at line 131 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), and pushBufferNonResampling().
|
protected |
Definition at line 132 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), and pushBufferNonResampling().
|
protected |
Definition at line 133 of file CodedAudioFileReader.h.
Referenced by finishDecodeCache(), and pushBufferNonResampling().
|
protectedinherited |
Definition at line 169 of file AudioFileReader.h.
Referenced by MP3FileReader::accept(), CodedAudioFileReader(), finishDecodeCache(), AudioFileReader::getFrameCount(), WavFileReader::getMax(), pushBufferNonResampling(), pushBufferResampling(), WavFileReader::updateFrameCount(), and WavFileReader::WavFileReader().
|
protectedinherited |
Definition at line 170 of file AudioFileReader.h.
Referenced by MP3FileReader::accept(), addSamplesToDecodeCache(), BQAFileReader::BQAFileReader(), DecodingWavFileReader::DecodingWavFileReader(), AudioFileReader::getChannelCount(), getInterleavedFrames(), WavFileReader::getInterleavedFramesUnnormalised(), WavFileReader::getMax(), initialiseDecodeCache(), AudioFileReader::isOK(), MP3FileReader::MP3FileReader(), pushBufferNonResampling(), pushBufferResampling(), pushCacheWriteBufferMaybe(), WavFileReader::updateFrameCount(), and WavFileReader::WavFileReader().
|
protectedinherited |
Definition at line 171 of file AudioFileReader.h.
Referenced by MP3FileReader::accept(), DecodingWavFileReader::addBlock(), CodedAudioFileReader(), AudioFileReader::getNativeRate(), AudioFileReader::getSampleRate(), initialiseDecodeCache(), MP3FileReader::MP3FileReader(), pushBuffer(), WavFileReader::updateFrameCount(), and WavFileReader::WavFileReader().
The documentation for this class was generated from the following files:
Generated by 1.8.11