|
Gin
|
Combined audio and MIDI buffer for synchronized processing within a single thread. More...
#include <gin_audiomidififo.h>
Public Member Functions | |
| AudioMidiFifo (int channels=2, int maxSize=1024) | |
| Creates an AudioMidiFifo with the specified capacity. | |
| void | setSize (int channels, int maxSize) |
| Resizes the FIFO to a new capacity. | |
| void | clear () |
| Clears all audio and MIDI data from the FIFO, resetting it to an empty state. | |
| int | getNumSamplesAvailable () |
| Returns the number of audio samples available to read. | |
| int | getNumSamplesFree () |
| Returns the number of audio samples that can be written before the FIFO is full. | |
| void | writeSilence (int numSamples) |
| Writes silence (zeros) to the audio portion of the FIFO. | |
| void | write (const juce::AudioBuffer< float > &audioSrc, const juce::MidiBuffer &midiSrc) |
| Writes audio and MIDI data to the FIFO. | |
| void | read (juce::AudioBuffer< float > &audioDst, juce::MidiBuffer &midiDst) |
| Reads audio and MIDI data from the FIFO. | |
Combined audio and MIDI buffer for synchronized processing within a single thread.
AudioMidiFifo provides a circular buffer that handles both audio samples and MIDI messages together, maintaining their temporal relationship. This is NOT thread-safe and should only be used within a single thread for operations that need synchronized audio and MIDI buffering.
Key Features:
Thread Safety:
The MIDI timestamps are automatically adjusted to maintain correct timing relative to the audio samples when reading and writing.
Usage:
| AudioMidiFifo::AudioMidiFifo | ( | int | channels = 2, |
| int | maxSize = 1024 ) |
Creates an AudioMidiFifo with the specified capacity.
| channels | Number of audio channels (default: 2) |
| maxSize | Maximum number of audio samples the FIFO can hold (default: 1024) |
References setSize().
| void AudioMidiFifo::setSize | ( | int | channels, |
| int | maxSize ) |
Resizes the FIFO to a new capacity.
This clears any existing data in the FIFO.
| channels | New number of audio channels |
| maxSize | New maximum number of audio samples |
References clear().
Referenced by AudioMidiFifo().
| void AudioMidiFifo::clear | ( | ) |
Clears all audio and MIDI data from the FIFO, resetting it to an empty state.
Referenced by setSize().
| int AudioMidiFifo::getNumSamplesAvailable | ( | ) |
Returns the number of audio samples available to read.
Referenced by read().
| int AudioMidiFifo::getNumSamplesFree | ( | ) |
Returns the number of audio samples that can be written before the FIFO is full.
Referenced by write(), and writeSilence().
| void AudioMidiFifo::writeSilence | ( | int | numSamples | ) |
Writes silence (zeros) to the audio portion of the FIFO.
No MIDI events are added.
| numSamples | Number of silent samples to write |
References getNumSamplesFree().
| void AudioMidiFifo::write | ( | const juce::AudioBuffer< float > & | audioSrc, |
| const juce::MidiBuffer & | midiSrc ) |
Writes audio and MIDI data to the FIFO.
MIDI event timestamps are automatically adjusted to maintain correct timing within the FIFO's internal timeline.
| audioSrc | Source audio buffer to write |
| midiSrc | Source MIDI buffer to write (timestamps relative to audioSrc) |
References getNumSamplesFree().
| void AudioMidiFifo::read | ( | juce::AudioBuffer< float > & | audioDst, |
| juce::MidiBuffer & | midiDst ) |
Reads audio and MIDI data from the FIFO.
MIDI event timestamps are automatically adjusted to be relative to the start of the destination audio buffer.
| audioDst | Destination audio buffer to read into |
| midiDst | Destination MIDI buffer to read into (timestamps will be relative to audioDst) |
References getNumSamplesAvailable().