JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
Public Member Functions | List of all members
juce::AudioBufferSource Class Referencefinal
Inheritance diagram for juce::AudioBufferSource:
juce::PositionableAudioSource juce::AudioSource

Public Member Functions

 AudioBufferSource (AudioBuffer< float > *audioBuffer, bool ownBuffer, bool playOnAllChannels)
 
void setNextReadPosition (int64 newPosition) override
 Tells the stream to move to a new position.
 
int64 getNextReadPosition () const override
 Returns the position from which the next block will be returned.
 
int64 getTotalLength () const override
 Returns the total length of the stream (in samples).
 
bool isLooping () const override
 Returns true if this source is actually playing in a loop.
 
void setLooping (bool shouldLoop) override
 Tells the source whether you'd like it to play in a loop.
 
void prepareToPlay (int, double) override
 Tells the source to prepare for playing.
 
void releaseResources () override
 Allows the source to release anything it no longer needs after playback has stopped.
 
void getNextAudioBlock (const AudioSourceChannelInfo &bufferToFill) override
 Called repeatedly to fetch subsequent blocks of audio data.
 
- Public Member Functions inherited from juce::PositionableAudioSource
 ~PositionableAudioSource () override=default
 Destructor.
 
- Public Member Functions inherited from juce::AudioSource
virtual ~AudioSource ()=default
 Destructor.
 

Additional Inherited Members

- Protected Member Functions inherited from juce::PositionableAudioSource
 PositionableAudioSource ()=default
 Creates the PositionableAudioSource.
 
- Protected Member Functions inherited from juce::AudioSource
 AudioSource ()=default
 Creates an AudioSource.
 

Detailed Description

Definition at line 88 of file juce_SoundPlayer.cpp.

Constructor & Destructor Documentation

◆ AudioBufferSource()

juce::AudioBufferSource::AudioBufferSource ( AudioBuffer< float > *  audioBuffer,
bool  ownBuffer,
bool  playOnAllChannels 
)

Definition at line 91 of file juce_SoundPlayer.cpp.

Member Function Documentation

◆ getNextAudioBlock()

void juce::AudioBufferSource::getNextAudioBlock ( const AudioSourceChannelInfo bufferToFill)
overridevirtual

Called repeatedly to fetch subsequent blocks of audio data.

After calling the prepareToPlay() method, this callback will be made each time the audio playback hardware (or whatever other destination the audio data is going to) needs another block of data.

It will generally be called on a high-priority system thread, or possibly even an interrupt, so be careful not to do too much work here, as that will cause audio glitches!

See also
AudioSourceChannelInfo, prepareToPlay, releaseResources

Implements juce::AudioSource.

Definition at line 117 of file juce_SoundPlayer.cpp.

◆ getNextReadPosition()

int64 juce::AudioBufferSource::getNextReadPosition ( ) const
overridevirtual

Returns the position from which the next block will be returned.

See also
setNextReadPosition

Implements juce::PositionableAudioSource.

Definition at line 107 of file juce_SoundPlayer.cpp.

◆ getTotalLength()

int64 juce::AudioBufferSource::getTotalLength ( ) const
overridevirtual

Returns the total length of the stream (in samples).

Implements juce::PositionableAudioSource.

Definition at line 108 of file juce_SoundPlayer.cpp.

◆ isLooping()

bool juce::AudioBufferSource::isLooping ( ) const
overridevirtual

Returns true if this source is actually playing in a loop.

Implements juce::PositionableAudioSource.

Definition at line 110 of file juce_SoundPlayer.cpp.

◆ prepareToPlay()

void juce::AudioBufferSource::prepareToPlay ( int  samplesPerBlockExpected,
double  sampleRate 
)
overridevirtual

Tells the source to prepare for playing.

An AudioSource has two states: prepared and unprepared.

The prepareToPlay() method is guaranteed to be called at least once on an 'unprepared' source to put it into a 'prepared' state before any calls will be made to getNextAudioBlock(). This callback allows the source to initialise any resources it might need when playing.

Once playback has finished, the releaseResources() method is called to put the stream back into an 'unprepared' state.

Note that this method could be called more than once in succession without a matching call to releaseResources(), so make sure your code is robust and can handle that kind of situation.

Parameters
samplesPerBlockExpectedthe number of samples that the source will be expected to supply each time its getNextAudioBlock() method is called. This number may vary slightly, because it will be dependent on audio hardware callbacks, and these aren't guaranteed to always use a constant block size, so the source should be able to cope with small variations.
sampleRatethe sample rate that the output will be used at - this is needed by sources such as tone generators.
See also
releaseResources, getNextAudioBlock

Implements juce::AudioSource.

Definition at line 114 of file juce_SoundPlayer.cpp.

◆ releaseResources()

void juce::AudioBufferSource::releaseResources ( )
overridevirtual

Allows the source to release anything it no longer needs after playback has stopped.

This will be called when the source is no longer going to have its getNextAudioBlock() method called, so it should release any spare memory, etc. that it might have allocated during the prepareToPlay() call.

Note that there's no guarantee that prepareToPlay() will actually have been called before releaseResources(), and it may be called more than once in succession, so make sure your code is robust and doesn't make any assumptions about when it will be called.

See also
prepareToPlay, getNextAudioBlock

Implements juce::AudioSource.

Definition at line 115 of file juce_SoundPlayer.cpp.

◆ setLooping()

void juce::AudioBufferSource::setLooping ( bool  shouldLoop)
overridevirtual

Tells the source whether you'd like it to play in a loop.

Reimplemented from juce::PositionableAudioSource.

Definition at line 111 of file juce_SoundPlayer.cpp.

◆ setNextReadPosition()

void juce::AudioBufferSource::setNextReadPosition ( int64  newPosition)
overridevirtual

Tells the stream to move to a new position.

Calling this indicates that the next call to AudioSource::getNextAudioBlock() should return samples from this position.

Note that this may be called on a different thread to getNextAudioBlock(), so the subclass should make sure it's synchronised.

Implements juce::PositionableAudioSource.

Definition at line 97 of file juce_SoundPlayer.cpp.


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