A specialised type of AudioFormatReader that uses a MemoryMappedFile to read directly from an audio file.
More...
#include <juce_MemoryMappedAudioFormatReader.h>
|
const File & | getFile () const noexcept |
| Returns the file that is being mapped.
|
|
bool | mapEntireFile () |
| Attempts to map the entire file into memory.
|
|
virtual bool | mapSectionOfFile (Range< int64 > samplesToMap) |
| Attempts to map a section of the file into memory.
|
|
Range< int64 > | getMappedSection () const noexcept |
| Returns the sample range that's currently memory-mapped and available for reading.
|
|
void | touchSample (int64 sample) const noexcept |
| Touches the memory for the given sample, to force it to be loaded into active memory.
|
|
virtual void | getSample (int64 sampleIndex, float *result) const noexcept=0 |
| Returns the samples for all channels at a given sample position.
|
|
size_t | getNumBytesUsed () const |
| Returns the number of bytes currently being mapped.
|
|
virtual | ~AudioFormatReader () |
| Destructor.
|
|
const String & | getFormatName () const noexcept |
| Returns a description of what type of format this is.
|
|
bool | read (float *const *destChannels, int numDestChannels, int64 startSampleInSource, int numSamplesToRead) |
| Reads samples from the stream.
|
|
bool | read (int *const *destChannels, int numDestChannels, int64 startSampleInSource, int numSamplesToRead, bool fillLeftoverChannelsWithCopies) |
| Reads samples from the stream.
|
|
bool | read (AudioBuffer< float > *buffer, int startSampleInDestBuffer, int numSamples, int64 readerStartSample, bool useReaderLeftChan, bool useReaderRightChan) |
| Fills a section of an AudioBuffer from this reader.
|
|
virtual void | readMaxLevels (int64 startSample, int64 numSamples, Range< float > *results, int numChannelsToRead) |
| Finds the highest and lowest sample levels from a section of the audio stream.
|
|
virtual void | readMaxLevels (int64 startSample, int64 numSamples, float &lowestLeft, float &highestLeft, float &lowestRight, float &highestRight) |
| Finds the highest and lowest sample levels from a section of the audio stream.
|
|
int64 | searchForLevel (int64 startSample, int64 numSamplesToSearch, double magnitudeRangeMinimum, double magnitudeRangeMaximum, int minimumConsecutiveSamples) |
| Scans the source looking for a sample whose magnitude is in a specified range.
|
|
virtual AudioChannelSet | getChannelLayout () |
| Get the channel layout of the audio stream.
|
|
virtual bool | readSamples (int *const *destChannels, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples)=0 |
| Subclasses must implement this method to perform the low-level read operation.
|
|
A specialised type of AudioFormatReader that uses a MemoryMappedFile to read directly from an audio file.
This allows for incredibly fast random-access to sample data in the mapped region of the file, but not all audio formats support it - see AudioFormat::createMemoryMappedReader().
Note that before reading samples from a MemoryMappedAudioFormatReader, you must first call mapEntireFile() or mapSectionOfFile() to ensure that the region you want to read has been mapped.
- See also
- AudioFormat::createMemoryMappedReader, AudioFormatReader
◆ MemoryMappedAudioFormatReader()
◆ getFile()
const File & MemoryMappedAudioFormatReader::getFile |
( |
| ) |
const |
|
noexcept |
Returns the file that is being mapped.
◆ mapEntireFile()
bool MemoryMappedAudioFormatReader::mapEntireFile |
( |
| ) |
|
Attempts to map the entire file into memory.
◆ mapSectionOfFile()
Attempts to map a section of the file into memory.
◆ getMappedSection()
Range< int64 > MemoryMappedAudioFormatReader::getMappedSection |
( |
| ) |
const |
|
noexcept |
Returns the sample range that's currently memory-mapped and available for reading.
◆ touchSample()
void MemoryMappedAudioFormatReader::touchSample |
( |
int64 | sample | ) |
const |
|
noexcept |
Touches the memory for the given sample, to force it to be loaded into active memory.
◆ getSample()
Returns the samples for all channels at a given sample position.
The result array must be large enough to hold a value for each channel that this reader contains.
◆ getNumBytesUsed()
size_t MemoryMappedAudioFormatReader::getNumBytesUsed |
( |
| ) |
const |
Returns the number of bytes currently being mapped.
◆ sampleToFilePos()
int64 MemoryMappedAudioFormatReader::sampleToFilePos |
( |
int64 | sample | ) |
const |
|
protectednoexcept |
Converts a sample index to a byte position in the file.
◆ filePosToSample()
int64 MemoryMappedAudioFormatReader::filePosToSample |
( |
int64 | filePos | ) |
const |
|
protectednoexcept |
Converts a byte position in the file to a sample index.
◆ sampleToPointer()
const void * MemoryMappedAudioFormatReader::sampleToPointer |
( |
int64 | sample | ) |
const |
|
protectednoexcept |
Converts a sample index to a pointer to the mapped file memory.
References addBytesToPointer().
◆ scanMinAndMaxInterleaved()
Range< float > MemoryMappedAudioFormatReader::scanMinAndMaxInterleaved |
( |
int | channel, |
|
|
int64 | startSampleInFile, |
|
|
int64 | numSamples ) const |
|
protectednoexcept |
◆ file
File MemoryMappedAudioFormatReader::file |
|
protected |
◆ mappedSection
Range<int64> MemoryMappedAudioFormatReader::mappedSection |
|
protected |
◆ map
◆ dataChunkStart
int64 MemoryMappedAudioFormatReader::dataChunkStart |
|
protected |
◆ dataLength
int64 MemoryMappedAudioFormatReader::dataLength |
|
protected |
◆ bytesPerFrame
int MemoryMappedAudioFormatReader::bytesPerFrame |
|
protected |
The documentation for this class was generated from the following file: