JUCE  v6.1.6 (6.0.8-1114)
JUCE API
Looking for a senior C++ dev?
I'm looking for work. Hire me!
juce::MidiBufferIterator Class Reference

An iterator to move over contiguous raw MIDI data, which Allows iterating over a MidiBuffer using C++11 range-for syntax. More...

#include <juce_MidiBuffer.h>

Collaboration diagram for juce::MidiBufferIterator:

Public Types

using difference_type = std::iterator_traits< Ptr >::difference_type
 
using iterator_category = std::input_iterator_tag
 
using pointer = void
 
using reference = MidiMessageMetadata
 
using value_type = MidiMessageMetadata
 

Public Member Functions

 MidiBufferIterator ()=default
 
 MidiBufferIterator (const uint8 *dataIn) noexcept
 Constructs an iterator pointing at the message starting at the byte dataIn. More...
 
bool operator!= (const MidiBufferIterator &other) const noexcept
 Return false if this iterator points to the same message as another iterator instance, otherwise returns true. More...
 
reference operator* () const noexcept
 Return an instance of MidiMessageMetadata which describes the message to which the iterator is currently pointing. More...
 
MidiBufferIteratoroperator++ () noexcept
 Make this iterator point to the next message in the buffer. More...
 
MidiBufferIterator operator++ (int) noexcept
 Create a copy of this object, make this iterator point to the next message in the buffer, then return the copy. More...
 
bool operator== (const MidiBufferIterator &other) const noexcept
 Return true if this iterator points to the same message as another iterator instance, otherwise return false. More...
 

Private Types

using Ptr = const uint8 *
 

Private Attributes

Ptr data = nullptr
 

Detailed Description

An iterator to move over contiguous raw MIDI data, which Allows iterating over a MidiBuffer using C++11 range-for syntax.

In the following example, we log all three-byte messages in a midi buffer.

void processBlock (AudioBuffer<float>&, MidiBuffer& midiBuffer) override
{
for (const MidiMessageMetadata metadata : midiBuffer)
if (metadata.numBytes == 3)
Logger::writeToLog (metadata.getMessage().getDescription());
}

@tags{Audio}

Member Typedef Documentation

◆ difference_type

◆ iterator_category

using juce::MidiBufferIterator::iterator_category = std::input_iterator_tag

◆ pointer

◆ Ptr

using juce::MidiBufferIterator::Ptr = const uint8*
private

◆ reference

◆ value_type

Constructor & Destructor Documentation

◆ MidiBufferIterator() [1/2]

juce::MidiBufferIterator::MidiBufferIterator ( )
default

◆ MidiBufferIterator() [2/2]

juce::MidiBufferIterator::MidiBufferIterator ( const uint8 dataIn)
inlineexplicitnoexcept

Constructs an iterator pointing at the message starting at the byte dataIn.

dataIn must point to the start of a valid MIDI message. If it does not, calling other member functions on the iterator will result in undefined behaviour.

Member Function Documentation

◆ operator!=()

bool juce::MidiBufferIterator::operator!= ( const MidiBufferIterator other) const
inlinenoexcept

Return false if this iterator points to the same message as another iterator instance, otherwise returns true.

References juce::operator==().

◆ operator*()

reference juce::MidiBufferIterator::operator* ( ) const
noexcept

Return an instance of MidiMessageMetadata which describes the message to which the iterator is currently pointing.

◆ operator++() [1/2]

MidiBufferIterator& juce::MidiBufferIterator::operator++ ( )
noexcept

Make this iterator point to the next message in the buffer.

◆ operator++() [2/2]

MidiBufferIterator juce::MidiBufferIterator::operator++ ( int  )
noexcept

Create a copy of this object, make this iterator point to the next message in the buffer, then return the copy.

◆ operator==()

bool juce::MidiBufferIterator::operator== ( const MidiBufferIterator other) const
inlinenoexcept

Return true if this iterator points to the same message as another iterator instance, otherwise return false.

References juce::gl::data.

Member Data Documentation

◆ data

Ptr juce::MidiBufferIterator::data = nullptr
private

The documentation for this class was generated from the following file:
juce::Logger::writeToLog
static void writeToLog(const String &message)
Writes a string to the current logger.