JUCE  v5.4.1-191-g0ab5e696f
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::MidiBuffer::Iterator Class Reference

Used to iterate through the events in a MidiBuffer. More...

#include <juce_MidiBuffer.h>

Collaboration diagram for juce::MidiBuffer::Iterator:

Public Member Functions

 Iterator (const MidiBuffer &) noexcept
 Creates an Iterator for this MidiBuffer. More...
 
 Iterator (const Iterator &)=default
 Creates a copy of an iterator. More...
 
 ~Iterator () noexcept
 Destructor. More...
 
bool getNextEvent (MidiMessage &result, int &samplePosition) noexcept
 Retrieves a copy of the next event from the buffer. More...
 
bool getNextEvent (const uint8 *&midiData, int &numBytesOfMidiData, int &samplePosition) noexcept
 Retrieves the next event from the buffer. More...
 
Iteratoroperator= (const Iterator &)=delete
 
void setNextSamplePosition (int samplePosition) noexcept
 Repositions the iterator so that the next event retrieved will be the first one whose sample position is at greater than or equal to the given position. More...
 

Private Attributes

const MidiBufferbuffer
 
const uint8data
 

Detailed Description

Used to iterate through the events in a MidiBuffer.

Note that altering the buffer while an iterator is using it will produce undefined behaviour.

See also
MidiBuffer

Constructor & Destructor Documentation

◆ Iterator() [1/2]

juce::MidiBuffer::Iterator::Iterator ( const MidiBuffer )
noexcept

Creates an Iterator for this MidiBuffer.

◆ Iterator() [2/2]

juce::MidiBuffer::Iterator::Iterator ( const Iterator )
default

Creates a copy of an iterator.

◆ ~Iterator()

juce::MidiBuffer::Iterator::~Iterator ( )
noexcept

Destructor.

Member Function Documentation

◆ getNextEvent() [1/2]

bool juce::MidiBuffer::Iterator::getNextEvent ( MidiMessage result,
int samplePosition 
)
noexcept

Retrieves a copy of the next event from the buffer.

Parameters
resulton return, this will be the message. The MidiMessage's timestamp is set to the same value as samplePosition.
samplePositionon return, this will be the position of the event, as a sample index in the buffer
Returns
true if an event was found, or false if the iterator has reached the end of the buffer

◆ getNextEvent() [2/2]

bool juce::MidiBuffer::Iterator::getNextEvent ( const uint8 *&  midiData,
int numBytesOfMidiData,
int samplePosition 
)
noexcept

Retrieves the next event from the buffer.

Parameters
midiDataon return, this pointer will be set to a block of data containing the midi message. Note that to make it fast, this is a pointer directly into the MidiBuffer's internal data, so is only valid temporarily until the MidiBuffer is altered.
numBytesOfMidiDataon return, this is the number of bytes of data used by the midi message
samplePositionon return, this will be the position of the event, as a sample index in the buffer
Returns
true if an event was found, or false if the iterator has reached the end of the buffer

◆ operator=()

Iterator& juce::MidiBuffer::Iterator::operator= ( const Iterator )
delete

◆ setNextSamplePosition()

void juce::MidiBuffer::Iterator::setNextSamplePosition ( int  samplePosition)
noexcept

Repositions the iterator so that the next event retrieved will be the first one whose sample position is at greater than or equal to the given position.

Member Data Documentation

◆ buffer

const MidiBuffer& juce::MidiBuffer::Iterator::buffer
private

◆ data

const uint8* juce::MidiBuffer::Iterator::data
private

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