OpenShot Audio Library | OpenShotAudio: juce::MemoryMappedAudioFormatReader Class Reference

OpenShot Audio Library | OpenShotAudio 1.0.0

Loading...
Searching...
No Matches
juce::MemoryMappedAudioFormatReader Class Referenceabstract

`#include <juce_MemoryMappedAudioFormatReader.h>`

Inheritance diagram for juce::MemoryMappedAudioFormatReader:

## Public Member Functions
const File & | getFile () const noexcept
bool | mapEntireFile ()
virtual bool | mapSectionOfFile (Range< int64 > samplesToMap)
Range< int64 > | getMappedSection () 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 juce::AudioFormatReader
virtual | ~AudioFormatReader ()
const String & | getFormatName () const noexcept
bool | read (float *const *destChannels, int numDestChannels, int64 startSampleInSource, int numSamplesToRead)
bool | read (int *const *destChannels, int numDestChannels, int64 startSampleInSource, int numSamplesToRead, bool fillLeftoverChannelsWithCopies)
bool | read (AudioBuffer< float > *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 AudioChannelSet | getChannelLayout ()
virtual bool | readSamples (int *const *destChannels, 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 juce::AudioFormatReader
| AudioFormatReader (InputStream *sourceStream, const String &formatName)

## Protected Attributes
File | file
Range< int64 > | mappedSection
std::unique_ptr< MemoryMappedFile > | map
int64 | dataChunkStart
int64 | dataLength
int | bytesPerFrame

## Additional Inherited Members
Public Attributes inherited from juce::AudioFormatReader
double | sampleRate = 0
unsigned int | bitsPerSample = 0
int64 | lengthInSamples = 0
unsigned int | numChannels = 0
bool | usesFloatingPointData = false
StringPairArray | metadataValues
InputStream * | input
Static Protected Member Functions inherited from juce::AudioFormatReader
static void | clearSamplesBeyondAvailableLength (int *const *destChannels, 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

Definition at line 46 of file juce_MemoryMappedAudioFormatReader.h.

## Constructor & Destructor Documentation

## ◆ MemoryMappedAudioFormatReader()

juce::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.

Definition at line 404 of file juce_AudioFormatReader.cpp.

## Member Function Documentation

## ◆ filePosToSample()

int64 juce::MemoryMappedAudioFormatReader::filePosToSample | ( | int64 | filePos | ) | const
| inlineprotectednoexcept

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

Definition at line 95 of file juce_MemoryMappedAudioFormatReader.h.

Referenced by mapSectionOfFile().

## ◆ getFile()

const File & juce::MemoryMappedAudioFormatReader::getFile | ( |  | ) | const
| inlinenoexcept

Returns the file that is being mapped

Definition at line 61 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ getMappedSection()

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

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

Definition at line 70 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ getNumBytesUsed()

size_t juce::MemoryMappedAudioFormatReader::getNumBytesUsed | ( |  | ) | const
| inline

Returns the number of bytes currently being mapped

Definition at line 82 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ getSample()

virtual void juce::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.

## ◆ mapEntireFile()

bool juce::MemoryMappedAudioFormatReader::mapEntireFile | ( |  | ) |

Attempts to map the entire file into memory.

Definition at line 417 of file juce_AudioFormatReader.cpp.

## ◆ mapSectionOfFile()

bool juce::MemoryMappedAudioFormatReader::mapSectionOfFile | ( | Range< int64 > | samplesToMap | ) |
| virtual

Attempts to map a section of the file into memory.

Definition at line 422 of file juce_AudioFormatReader.cpp.

Referenced by mapEntireFile().

## ◆ sampleToFilePos()

int64 juce::MemoryMappedAudioFormatReader::sampleToFilePos | ( | int64 | sample | ) | const
| inlineprotectednoexcept

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

Definition at line 92 of file juce_MemoryMappedAudioFormatReader.h.

Referenced by mapSectionOfFile(), and sampleToPointer().

## ◆ sampleToPointer()

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

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

Definition at line 98 of file juce_MemoryMappedAudioFormatReader.h.

Referenced by scanMinAndMaxInterleaved(), and touchSample().

## ◆ scanMinAndMaxInterleaved()

template<typename SampleType, typename Endianness>

Range< float > juce::MemoryMappedAudioFormatReader::scanMinAndMaxInterleaved | ( | int | channel,
|  | int64 | startSampleInFile,
|  | int64 | numSamples ) const
| inlineprotectednoexcept

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

Definition at line 102 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ touchSample()

void juce::MemoryMappedAudioFormatReader::touchSample | ( | int64 | sample | ) | const
| noexcept

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

Definition at line 445 of file juce_AudioFormatReader.cpp.

## Member Data Documentation

## ◆ bytesPerFrame

int juce::MemoryMappedAudioFormatReader::bytesPerFrame
| protected

Definition at line 89 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ dataChunkStart

int64 juce::MemoryMappedAudioFormatReader::dataChunkStart
| protected

Definition at line 88 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ dataLength

int64 juce::MemoryMappedAudioFormatReader::dataLength
| protected

Definition at line 88 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ file

File juce::MemoryMappedAudioFormatReader::file
| protected

Definition at line 85 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ map

std::unique_ptr<MemoryMappedFile> juce::MemoryMappedAudioFormatReader::map
| protected

Definition at line 87 of file juce_MemoryMappedAudioFormatReader.h.

## ◆ mappedSection

Range<int64> juce::MemoryMappedAudioFormatReader::mappedSection
| protected

Definition at line 86 of file juce_MemoryMappedAudioFormatReader.h.

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

- juce_MemoryMappedAudioFormatReader.h
- juce_AudioFormatReader.cpp