JUCE v8.0.9
JUCE API
 
Loading...
Searching...
No Matches
juce::ARAAudioSourceReader Class Reference

Subclass of AudioFormatReader that reads samples from a single ARA audio source. More...

#include <juce_ARAAudioReaders.h>

Inheritance diagram for juce::ARAAudioSourceReader:
Collaboration diagram for juce::ARAAudioSourceReader:

Public Member Functions

 ARAAudioSourceReader (ARAAudioSource *audioSource)
 Use an ARAAudioSource to construct an audio source reader for the given audioSource.
 
 ~ARAAudioSourceReader () override
 
void didEnableAudioSourceSamplesAccess (ARAAudioSource *audioSource, bool enable) override
 Called after access to an audio source's samples is enabled or disabled.
 
void doUpdateAudioSourceContent (ARAAudioSource *audioSource, ARAContentUpdateScopes scopeFlags) override
 Called when the audio source's content (i.e.
 
virtual AudioChannelSet getChannelLayout ()
 Get the channel layout of the audio stream.
 
const StringgetFormatName () const noexcept
 Returns a description of what type of format this is.
 
void invalidate ()
 Invalidate the reader - the reader will call this internally if needed, but can also be invalidated from the outside (from message thread only!).
 
bool isValid () const
 Returns true as long as the reader's underlying ARAAudioSource remains accessible and its sample content is not changed.
 
bool read (AudioBuffer< float > *buffer, int startSampleInDestBuffer, int numSamples, int64 readerStartSample, bool useReaderLeftChan, bool useReaderRightChan)
 Fills a section of an AudioBuffer from this reader.
 
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.
 
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.
 
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.
 
bool readSamples (int *const *destSamples, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int numSamples) override
 Subclasses must implement this method to perform the low-level read operation.
 
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.
 
void willDestroyAudioSource (ARAAudioSource *audioSource) override
 Called before the audio source is destroyed.
 
void willEnableAudioSourceSamplesAccess (ARAAudioSource *audioSource, bool enable) override
 Called before access to an audio source's samples is enabled or disabled.
 
void willUpdateAudioSourceProperties (ARAAudioSource *audioSource, ARAAudioSource::PropertiesPtr newProperties) override
 Called before the audio source's properties are updated.
 

Public Attributes

unsigned int bitsPerSample = 0
 The number of bits per sample, e.g.
 
InputStreaminput
 The input stream, for use by subclasses.
 
int64 lengthInSamples = 0
 The total number of samples in the audio stream.
 
StringPairArray metadataValues
 A set of metadata values that the reader has pulled out of the stream.
 
unsigned int numChannels = 0
 The total number of channels in the audio stream.
 
double sampleRate = 0
 The sample-rate of the stream.
 
bool usesFloatingPointData = false
 Indicates whether the data is floating-point or fixed.
 

Static Protected Member Functions

static void clearSamplesBeyondAvailableLength (int *const *destChannels, int numDestChannels, int startOffsetInDestBuffer, int64 startSampleInFile, int &numSamples, int64 fileLengthInSamples)
 Used by AudioFormatReader subclasses to clear any parts of the data blocks that lie beyond the end of their available length.
 

Private Member Functions

virtual void didAddAudioModificationToAudioSource (ARAAudioSource *audioSource, ARAAudioModification *audioModification)
 Called after an audio modification is added to the audio source.
 
virtual void didDeactivateAudioSourceForUndoHistory (ARAAudioSource *audioSource, bool deactivate)
 Called after an audio source is activated or deactivated when being removed / added from the host's undo history.
 
virtual void didUpdateAudioSourceAnalysisProgress (ARAAudioSource *audioSource, ARA::ARAAnalysisProgressState state, float progress)
 Called to notify progress when an audio source is being analyzed.
 
virtual void didUpdateAudioSourceProperties (ARAAudioSource *audioSource)
 Called after the audio source's properties are updated.
 
virtual void willDeactivateAudioSourceForUndoHistory (ARAAudioSource *audioSource, bool deactivate)
 Called before an audio source is activated or deactivated when being removed / added from the host's undo history.
 
virtual void willRemoveAudioModificationFromAudioSource (ARAAudioSource *audioSource, ARAAudioModification *audioModification)
 Called before an audio modification is removed from the audio source.
 

Private Attributes

ARAAudioSourceaudioSourceBeingRead
 
String formatName
 
std::unique_ptr< ARA::PlugIn::HostAudioReader > hostReader
 
ReadWriteLock lock
 
std::vector< void * > tmpPtrs
 

Detailed Description

Subclass of AudioFormatReader that reads samples from a single ARA audio source.

Plug-Ins typically use this from their rendering code, wrapped in a BufferingAudioReader to bridge between realtime rendering and non-realtime audio reading.

The reader becomes invalidated if

  • the audio source content is updated in a way that affects its samples,
  • the audio source sample access is disabled, or
  • the audio source being read is destroyed.

@tags{ARA}

Constructor & Destructor Documentation

◆ ARAAudioSourceReader()

juce::ARAAudioSourceReader::ARAAudioSourceReader ( ARAAudioSource audioSource)
explicit

Use an ARAAudioSource to construct an audio source reader for the given audioSource.

◆ ~ARAAudioSourceReader()

juce::ARAAudioSourceReader::~ARAAudioSourceReader ( )
override

Member Function Documentation

◆ clearSamplesBeyondAvailableLength()

static void juce::AudioFormatReader::clearSamplesBeyondAvailableLength ( int *const *  destChannels,
int  numDestChannels,
int  startOffsetInDestBuffer,
int64  startSampleInFile,
int &  numSamples,
int64  fileLengthInSamples 
)
inlinestaticprotectedinherited

Used by AudioFormatReader subclasses to clear any parts of the data blocks that lie beyond the end of their available length.

References jassertfalse, and juce::zeromem().

◆ didAddAudioModificationToAudioSource()

virtual void juce::ARAAudioSourceListener::didAddAudioModificationToAudioSource ( ARAAudioSource audioSource,
ARAAudioModification audioModification 
)
virtualinherited

Called after an audio modification is added to the audio source.

Parameters
audioSourceThe region sequence that audioModification was added to.
audioModificationThe playback region that was added to audioSource.

◆ didDeactivateAudioSourceForUndoHistory()

virtual void juce::ARAAudioSourceListener::didDeactivateAudioSourceForUndoHistory ( ARAAudioSource audioSource,
bool  deactivate 
)
virtualinherited

Called after an audio source is activated or deactivated when being removed / added from the host's undo history.

Parameters
audioSourceThe audio source that was activated or deactivated
deactivateA bool indicating whether audioSource was deactivated or activated.

◆ didEnableAudioSourceSamplesAccess()

void juce::ARAAudioSourceReader::didEnableAudioSourceSamplesAccess ( ARAAudioSource audioSource,
bool  enable 
)
overridevirtual

Called after access to an audio source's samples is enabled or disabled.

Parameters
audioSourceThe audio source whose sample access state was changed.
enableA bool indicating whether or not sample access was enabled or disabled.

Reimplemented from juce::ARAAudioSourceListener.

◆ didUpdateAudioSourceAnalysisProgress()

virtual void juce::ARAAudioSourceListener::didUpdateAudioSourceAnalysisProgress ( ARAAudioSource audioSource,
ARA::ARAAnalysisProgressState  state,
float  progress 
)
virtualinherited

Called to notify progress when an audio source is being analyzed.

Parameters
audioSourceThe audio source being analyzed.
stateIndicates start, intermediate update or completion of the analysis.
progressProgress normalized to the 0..1 range.

◆ didUpdateAudioSourceProperties()

virtual void juce::ARAAudioSourceListener::didUpdateAudioSourceProperties ( ARAAudioSource audioSource)
virtualinherited

Called after the audio source's properties are updated.

Parameters
audioSourceThe audio source whose properties were updated.

◆ doUpdateAudioSourceContent()

void juce::ARAAudioSourceReader::doUpdateAudioSourceContent ( ARAAudioSource audioSource,
ARAContentUpdateScopes  scopeFlags 
)
overridevirtual

Called when the audio source's content (i.e.

samples or notes) changes.

Parameters
audioSourceThe audio source with updated content.
scopeFlagsThe scope of the content update.

Reimplemented from juce::ARAAudioSourceListener.

◆ getChannelLayout()

virtual AudioChannelSet juce::AudioFormatReader::getChannelLayout ( )
virtualinherited

Get the channel layout of the audio stream.

◆ getFormatName()

const String & juce::AudioFormatReader::getFormatName ( ) const
inlinenoexceptinherited

Returns a description of what type of format this is.

E.g. "AIFF"

◆ invalidate()

void juce::ARAAudioSourceReader::invalidate ( )

Invalidate the reader - the reader will call this internally if needed, but can also be invalidated from the outside (from message thread only!).

◆ isValid()

bool juce::ARAAudioSourceReader::isValid ( ) const
inline

Returns true as long as the reader's underlying ARAAudioSource remains accessible and its sample content is not changed.

◆ read() [1/3]

bool juce::AudioFormatReader::read ( AudioBuffer< float > *  buffer,
int  startSampleInDestBuffer,
int  numSamples,
int64  readerStartSample,
bool  useReaderLeftChan,
bool  useReaderRightChan 
)
inherited

Fills a section of an AudioBuffer from this reader.

This will convert the reader's fixed- or floating-point data to the buffer's floating-point format, and will try to intelligently cope with mismatches between the number of channels in the reader and the buffer.

Returns
true if the operation succeeded, false if there was an error. Note that reading sections of data beyond the extent of the stream isn't an error - the reader should just return zeros for these regions

◆ read() [2/3]

bool juce::AudioFormatReader::read ( float *const *  destChannels,
int  numDestChannels,
int64  startSampleInSource,
int  numSamplesToRead 
)
inherited

Reads samples from the stream.

Parameters
destChannelsan array of float buffers into which the sample data for each channel will be written. Channels that aren't needed can be null
numDestChannelsthe number of array elements in the destChannels array
startSampleInSourcethe position in the audio file or stream at which the samples should be read, as a number of samples from the start of the stream. It's ok for this to be beyond the start or end of the available data - any samples that are out-of-range will be returned as zeros.
numSamplesToReadthe number of samples to read. If this is greater than the number of samples that the file or stream contains. the result will be padded with zeros
Returns
true if the operation succeeded, false if there was an error. Note that reading sections of data beyond the extent of the stream isn't an error - the reader should just return zeros for these regions
See also
readMaxLevels

◆ read() [3/3]

bool juce::AudioFormatReader::read ( int *const *  destChannels,
int  numDestChannels,
int64  startSampleInSource,
int  numSamplesToRead,
bool  fillLeftoverChannelsWithCopies 
)
inherited

Reads samples from the stream.

Parameters
destChannelsan array of buffers into which the sample data for each channel will be written. If the format is fixed-point, each channel will be written as an array of 32-bit signed integers using the full range -0x80000000 to 0x7fffffff, regardless of the source's bit-depth. If it is a floating-point format, you should cast the resulting array to a (float**) to get the values (in the range -1.0 to 1.0 or beyond) If the format is stereo, then destChannels[0] is the left channel data, and destChannels[1] is the right channel. The numDestChannels parameter indicates how many pointers this array contains, but some of these pointers can be null if you don't want to read data for some of the channels
numDestChannelsthe number of array elements in the destChannels array
startSampleInSourcethe position in the audio file or stream at which the samples should be read, as a number of samples from the start of the stream. It's ok for this to be beyond the start or end of the available data - any samples that are out-of-range will be returned as zeros.
numSamplesToReadthe number of samples to read. If this is greater than the number of samples that the file or stream contains. the result will be padded with zeros
fillLeftoverChannelsWithCopiesif true, this indicates that if there's no source data available for some of the channels that you pass in, then they should be filled with copies of valid source channels. E.g. if you're reading a mono file and you pass 2 channels to this method, then if fillLeftoverChannelsWithCopies is true, both destination channels will be filled with the same data from the file's single channel. If fillLeftoverChannelsWithCopies was false, then only the first channel would be filled with the file's contents, and the second would be cleared. If there are many channels, e.g. you try to read 4 channels from a stereo file, then the last 3 would all end up with copies of the same data.
Returns
true if the operation succeeded, false if there was an error. Note that reading sections of data beyond the extent of the stream isn't an error - the reader should just return zeros for these regions
See also
readMaxLevels

◆ readMaxLevels() [1/2]

virtual void juce::AudioFormatReader::readMaxLevels ( int64  startSample,
int64  numSamples,
float lowestLeft,
float highestLeft,
float lowestRight,
float highestRight 
)
virtualinherited

Finds the highest and lowest sample levels from a section of the audio stream.

This will read a block of samples from the stream, and measure the highest and lowest sample levels from the channels in that section, returning these as normalised floating-point levels.

Parameters
startSamplethe offset into the audio stream to start reading from. It's ok for this to be beyond the start or end of the stream.
numSampleshow many samples to read
lowestLefton return, this is the lowest absolute sample from the left channel
highestLefton return, this is the highest absolute sample from the left channel
lowestRighton return, this is the lowest absolute sample from the right channel (if there is one)
highestRighton return, this is the highest absolute sample from the right channel (if there is one)
See also
read

Reimplemented in juce::AudioSubsectionReader.

◆ readMaxLevels() [2/2]

virtual void juce::AudioFormatReader::readMaxLevels ( int64  startSample,
int64  numSamples,
Range< float > *  results,
int  numChannelsToRead 
)
virtualinherited

Finds the highest and lowest sample levels from a section of the audio stream.

This will read a block of samples from the stream, and measure the highest and lowest sample levels from the channels in that section, returning these as normalised floating-point levels.

Parameters
startSamplethe offset into the audio stream to start reading from. It's ok for this to be beyond the start or end of the stream.
numSampleshow many samples to read
resultsthis array will be filled with Range values for each channel. The array must contain numChannels elements.
numChannelsToReadthe number of channels of data to scan. This must be more than zero, but not more than the total number of channels that the reader contains
See also
read

Reimplemented in juce::AudioSubsectionReader, and juce::AudioSubsectionReader.

◆ readSamples()

bool juce::ARAAudioSourceReader::readSamples ( int *const *  destChannels,
int  numDestChannels,
int  startOffsetInDestBuffer,
int64  startSampleInFile,
int  numSamples 
)
overridevirtual

Subclasses must implement this method to perform the low-level read operation.

Callers should use read() instead of calling this directly.

Parameters
destChannelsthe array of destination buffers to fill. Some of these pointers may be null
numDestChannelsthe number of items in the destChannels array. This value is guaranteed not to be greater than the number of channels that this reader object contains
startOffsetInDestBufferthe number of samples from the start of the dest data at which to begin writing
startSampleInFilethe number of samples into the source data at which to begin reading. This value is guaranteed to be >= 0.
numSamplesthe number of samples to read

Implements juce::AudioFormatReader.

◆ searchForLevel()

int64 juce::AudioFormatReader::searchForLevel ( int64  startSample,
int64  numSamplesToSearch,
double  magnitudeRangeMinimum,
double  magnitudeRangeMaximum,
int  minimumConsecutiveSamples 
)
inherited

Scans the source looking for a sample whose magnitude is in a specified range.

This will read from the source, either forwards or backwards between two sample positions, until it finds a sample whose magnitude lies between two specified levels.

If it finds a suitable sample, it returns its position; if not, it will return -1.

There's also a minimumConsecutiveSamples setting to help avoid spikes or zero-crossing points when you're searching for a continuous range of samples

Parameters
startSamplethe first sample to look at
numSamplesToSearchthe number of samples to scan. If this value is negative, the search will go backwards
magnitudeRangeMinimumthe lowest magnitude (inclusive) that is considered a hit, from 0 to 1.0
magnitudeRangeMaximumthe highest magnitude (inclusive) that is considered a hit, from 0 to 1.0
minimumConsecutiveSamplesif this is > 0, the method will only look for a sequence of this many consecutive samples, all of which lie within the target range. When it finds such a sequence, it returns the position of the first in-range sample it found (i.e. the earliest one if scanning forwards, the latest one if scanning backwards)

◆ willDeactivateAudioSourceForUndoHistory()

virtual void juce::ARAAudioSourceListener::willDeactivateAudioSourceForUndoHistory ( ARAAudioSource audioSource,
bool  deactivate 
)
virtualinherited

Called before an audio source is activated or deactivated when being removed / added from the host's undo history.

Parameters
audioSourceThe audio source that will be activated or deactivated
deactivateA bool indicating whether audioSource was deactivated or activated.

◆ willDestroyAudioSource()

void juce::ARAAudioSourceReader::willDestroyAudioSource ( ARAAudioSource audioSource)
overridevirtual

Called before the audio source is destroyed.

Parameters
audioSourceThe audio source that will be destroyed.

Reimplemented from juce::ARAAudioSourceListener.

◆ willEnableAudioSourceSamplesAccess()

void juce::ARAAudioSourceReader::willEnableAudioSourceSamplesAccess ( ARAAudioSource audioSource,
bool  enable 
)
overridevirtual

Called before access to an audio source's samples is enabled or disabled.

Parameters
audioSourceThe audio source whose sample access state will be changed.
enableA bool indicating whether or not sample access will be enabled or disabled.

Reimplemented from juce::ARAAudioSourceListener.

◆ willRemoveAudioModificationFromAudioSource()

virtual void juce::ARAAudioSourceListener::willRemoveAudioModificationFromAudioSource ( ARAAudioSource audioSource,
ARAAudioModification audioModification 
)
virtualinherited

Called before an audio modification is removed from the audio source.

Parameters
audioSourceThe audio source that audioModification will be removed from.
audioModificationThe audio modification that will be removed from audioSource.

◆ willUpdateAudioSourceProperties()

void juce::ARAAudioSourceReader::willUpdateAudioSourceProperties ( ARAAudioSource audioSource,
ARAAudioSource::PropertiesPtr  newProperties 
)
overridevirtual

Called before the audio source's properties are updated.

Parameters
audioSourceThe audio source whose properties will be updated.
newPropertiesThe audio source properties that will be assigned to audioSource.

Reimplemented from juce::ARAAudioSourceListener.

Member Data Documentation

◆ audioSourceBeingRead

ARAAudioSource* juce::ARAAudioSourceReader::audioSourceBeingRead
private

◆ bitsPerSample

unsigned int juce::AudioFormatReader::bitsPerSample = 0
inherited

The number of bits per sample, e.g.

16, 24, 32.

◆ formatName

String juce::AudioFormatReader::formatName
privateinherited

◆ hostReader

std::unique_ptr<ARA::PlugIn::HostAudioReader> juce::ARAAudioSourceReader::hostReader
private

◆ input

InputStream* juce::AudioFormatReader::input
inherited

The input stream, for use by subclasses.

◆ lengthInSamples

int64 juce::AudioFormatReader::lengthInSamples = 0
inherited

The total number of samples in the audio stream.

◆ lock

ReadWriteLock juce::ARAAudioSourceReader::lock
private

◆ metadataValues

StringPairArray juce::AudioFormatReader::metadataValues
inherited

A set of metadata values that the reader has pulled out of the stream.

Exactly what these values are depends on the format, so you can check out the format implementation code to see what kind of stuff they understand.

◆ numChannels

unsigned int juce::AudioFormatReader::numChannels = 0
inherited

The total number of channels in the audio stream.

◆ sampleRate

double juce::AudioFormatReader::sampleRate = 0
inherited

The sample-rate of the stream.

◆ tmpPtrs

std::vector<void*> juce::ARAAudioSourceReader::tmpPtrs
private

◆ usesFloatingPointData

bool juce::AudioFormatReader::usesFloatingPointData = false
inherited

Indicates whether the data is floating-point or fixed.


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