openshot-audio  0.1.4
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
MemoryMappedAudioFormatReader Class Referenceabstract

#include <juce_MemoryMappedAudioFormatReader.h>

Inheritance diagram for MemoryMappedAudioFormatReader:
AudioFormatReader MemoryMappedAiffReader MemoryMappedWavReader

Public Member Functions

const FilegetFile () const noexcept
 
bool mapEntireFile ()
 
bool mapSectionOfFile (Range< int64 > samplesToMap)
 
Range< int64getMappedSection () const noexcept
 
void touchSample (int64 sample) const noexcept
 
virtual void getSample (int64 sampleIndex, float *result) const noexcept=0
 
size_t getNumBytesUsed () const
 
- Public Member Functions inherited from AudioFormatReader
virtual ~AudioFormatReader ()
 
const StringgetFormatName () const noexcept
 
bool read (int *const *destSamples, int numDestChannels, int64 startSampleInSource, int numSamplesToRead, bool fillLeftoverChannelsWithCopies)
 
void read (AudioSampleBuffer *buffer, int startSampleInDestBuffer, int numSamples, int64 readerStartSample, bool useReaderLeftChan, bool useReaderRightChan)
 
virtual void readMaxLevels (int64 startSample, int64 numSamples, Range< float > *results, int numChannelsToRead)
 
virtual void readMaxLevels (int64 startSample, int64 numSamples, float &lowestLeft, float &highestLeft, float &lowestRight, float &highestRight)
 
int64 searchForLevel (int64 startSample, int64 numSamplesToSearch, double magnitudeRangeMinimum, double magnitudeRangeMaximum, int minimumConsecutiveSamples)
 
virtual bool readSamples (int **destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples)=0
 

Protected Member Functions

 MemoryMappedAudioFormatReader (const File &file, const AudioFormatReader &details, int64 dataChunkStart, int64 dataChunkLength, int bytesPerFrame)
 
int64 sampleToFilePos (int64 sample) const noexcept
 
int64 filePosToSample (int64 filePos) const noexcept
 
const void * sampleToPointer (int64 sample) const noexcept
 
template<typename SampleType , typename Endianness >
Range< float > scanMinAndMaxInterleaved (int channel, int64 startSampleInFile, int64 numSamples) const noexcept
 
- Protected Member Functions inherited from AudioFormatReader
 AudioFormatReader (InputStream *sourceStream, const String &formatName)
 

Protected Attributes

File file
 
Range< int64mappedSection
 
ScopedPointer< MemoryMappedFilemap
 
int64 dataChunkStart
 
int64 dataLength
 
int bytesPerFrame
 

Additional Inherited Members

- Public Attributes inherited from AudioFormatReader
double sampleRate
 
unsigned int bitsPerSample
 
int64 lengthInSamples
 
unsigned int numChannels
 
bool usesFloatingPointData
 
StringPairArray metadataValues
 
InputStreaminput
 
- Static Protected Member Functions inherited from AudioFormatReader
static void clearSamplesBeyondAvailableLength (int **destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int &numSamples, int64 fileLengthInSamples)
 

Detailed Description

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

Constructor & Destructor Documentation

◆ MemoryMappedAudioFormatReader()

MemoryMappedAudioFormatReader::MemoryMappedAudioFormatReader ( const File file,
const AudioFormatReader details,
int64  dataChunkStart,
int64  dataChunkLength,
int  bytesPerFrame 
)
protected

Creates an MemoryMappedAudioFormatReader object.

Note that before attempting to read any data, you must call mapEntireFile() or mapSectionOfFile() to ensure that the region you want to read has been mapped.

Member Function Documentation

◆ filePosToSample()

int64 MemoryMappedAudioFormatReader::filePosToSample ( int64  filePos) const
inlineprotectednoexcept

Converts a byte position in the file to a sample index.

◆ getFile()

const File& MemoryMappedAudioFormatReader::getFile ( ) const
inlinenoexcept

Returns the file that is being mapped

◆ getMappedSection()

Range<int64> MemoryMappedAudioFormatReader::getMappedSection ( ) const
inlinenoexcept

Returns the sample range that's currently memory-mapped and available for reading.

◆ getNumBytesUsed()

size_t MemoryMappedAudioFormatReader::getNumBytesUsed ( ) const
inline

Returns the number of bytes currently being mapped

◆ getSample()

virtual void MemoryMappedAudioFormatReader::getSample ( int64  sampleIndex,
float *  result 
) const
pure virtualnoexcept

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.

Implemented in MemoryMappedWavReader, and MemoryMappedAiffReader.

◆ mapEntireFile()

bool MemoryMappedAudioFormatReader::mapEntireFile ( )

Attempts to map the entire file into memory.

◆ mapSectionOfFile()

bool MemoryMappedAudioFormatReader::mapSectionOfFile ( Range< int64 samplesToMap)

Attempts to map a section of the file into memory.

◆ sampleToFilePos()

int64 MemoryMappedAudioFormatReader::sampleToFilePos ( int64  sample) const
inlineprotectednoexcept

Converts a sample index to a byte position in the file.

◆ sampleToPointer()

const void* MemoryMappedAudioFormatReader::sampleToPointer ( int64  sample) const
inlineprotectednoexcept

Converts a sample index to a pointer to the mapped file memory.

◆ scanMinAndMaxInterleaved()

template<typename SampleType , typename Endianness >
Range<float> MemoryMappedAudioFormatReader::scanMinAndMaxInterleaved ( int  channel,
int64  startSampleInFile,
int64  numSamples 
) const
inlineprotectednoexcept

Used by AudioFormatReader subclasses to scan for min/max ranges in interleaved data.

◆ touchSample()

void MemoryMappedAudioFormatReader::touchSample ( int64  sample) const
noexcept

Touches the memory for the given sample, to force it to be loaded into active memory.

Member Data Documentation

◆ bytesPerFrame

int MemoryMappedAudioFormatReader::bytesPerFrame
protected

◆ dataChunkStart

int64 MemoryMappedAudioFormatReader::dataChunkStart
protected

◆ dataLength

int64 MemoryMappedAudioFormatReader::dataLength
protected

◆ file

File MemoryMappedAudioFormatReader::file
protected

◆ map

ScopedPointer<MemoryMappedFile> MemoryMappedAudioFormatReader::map
protected

◆ mappedSection

Range<int64> MemoryMappedAudioFormatReader::mappedSection
protected

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