41 if (
newSource !=
nullptr && bufferSize > 0 && sampleRate > 0)
67 jassert (sampleRate > 0 && bufferSize > 0);
71 if (source !=
nullptr)
97 if (numInputs > numOutputs)
102 tempBuffer.
setSize (numInputs - numOutputs, numSamples,
105 for (
int i = 0; i < numOutputs; ++i)
112 for (
int i = numOutputs; i < numInputs; ++i)
121 for (
int i = 0; i < numInputs; ++i)
128 for (
int i = numInputs; i < numOutputs; ++i)
164 zeromem (channels,
sizeof (channels));
166 if (source !=
nullptr)
172 if (source !=
nullptr)
A multi-channel buffer containing floating point audio samples.
void setSize(int newNumChannels, int newNumSamples, bool keepExistingContent=false, bool clearExtraSpace=false, bool avoidReallocating=false)
Changes the buffer's size or number of channels.
Type * getWritePointer(int channelNumber) noexcept
Returns a writeable pointer to one of the buffer's channels.
int getNumChannels() const noexcept
Returns the number of channels of audio data that this buffer contains.
void applyGainRamp(int channel, int startSample, int numSamples, Type startGain, Type endGain) noexcept
Applies a range of gains to a region of a channel.
Base class for an audio device with synchronised input and output channels.
virtual double getCurrentSampleRate()=0
Returns the sample rate that the device is currently using.
virtual int getCurrentBufferSizeSamples()=0
Returns the buffer size that the device is currently using.
void setGain(float newGain) noexcept
Sets a gain to apply to the audio data.
void setSource(AudioSource *newSource)
Changes the current audio source to play from.
void audioDeviceIOCallbackWithContext(const float *const *inputChannelData, int totalNumInputChannels, float *const *outputChannelData, int totalNumOutputChannels, int numSamples, const AudioIODeviceCallbackContext &context) override
Implementation of the AudioIODeviceCallbackWithContext method.
AudioSourcePlayer()
Creates an empty AudioSourcePlayer.
void audioDeviceStopped() override
Implementation of the AudioIODeviceCallback method.
~AudioSourcePlayer() override
Destructor.
void prepareToPlay(double sampleRate, int blockSize)
An alternative method for initialising the source without an AudioIODevice.
void audioDeviceAboutToStart(AudioIODevice *device) override
Implementation of the AudioIODeviceCallback method.
Base class for objects that can produce a continuous stream of audio.
virtual void releaseResources()=0
Allows the source to release anything it no longer needs after playback has stopped.
virtual void prepareToPlay(int samplesPerBlockExpected, double sampleRate)=0
Tells the source to prepare for playing.
virtual void getNextAudioBlock(const AudioSourceChannelInfo &bufferToFill)=0
Called repeatedly to fetch subsequent blocks of audio data.
Automatically locks and unlocks a mutex object.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
constexpr int numElementsInArray(Type(&)[N]) noexcept
Handy function for getting the number of elements in a simple const C array.
void zeromem(void *memory, size_t numBytes) noexcept
Fills a block of memory with zeros.
Additional information that may be passed to the AudioIODeviceCallback.
Used by AudioSource::getNextAudioBlock().
int numSamples
The number of samples in the buffer which the callback is expected to fill with data.
AudioBuffer< float > * buffer
The destination buffer to fill with audio data.
int startSample
The first sample in the buffer from which the callback is expected to write data.