MidiBuffer Class Reference

Holds a sequence of time-stamped midi events. More...

List of all members.

Classes

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

Public Member Functions

 MidiBuffer () throw ()
 Creates an empty MidiBuffer.
 MidiBuffer (const MidiMessage &message) throw ()
 Creates a MidiBuffer containing a single midi message.
 MidiBuffer (const MidiBuffer &other) throw ()
 Creates a copy of another MidiBuffer.
MidiBufferoperator= (const MidiBuffer &other) throw ()
 Makes a copy of another MidiBuffer.
 ~MidiBuffer () throw ()
 Destructor.
void clear () throw ()
 Removes all events from the buffer.
void clear (const int start, const int numSamples) throw ()
 Removes all events between two times from the buffer.
bool isEmpty () const throw ()
 Returns true if the buffer is empty.
int getNumEvents () const throw ()
 Counts the number of events in the buffer.
void addEvent (const MidiMessage &midiMessage, const int sampleNumber) throw ()
 Adds an event to the buffer.
void addEvent (const uint8 *const rawMidiData, const int maxBytesOfMidiData, const int sampleNumber) throw ()
 Adds an event to the buffer from raw midi data.
void addEvents (const MidiBuffer &otherBuffer, const int startSample, const int numSamples, const int sampleDeltaToAdd) throw ()
 Adds some events from another buffer to this one.
int getFirstEventTime () const throw ()
 Returns the sample number of the first event in the buffer.
int getLastEventTime () const throw ()
 Returns the sample number of the last event in the buffer.
void swapWith (MidiBuffer &other)
 Exchanges the contents of this buffer with another one.
void ensureSize (size_t minimumNumBytes)
 Preallocates some memory for the buffer to use.

Detailed Description

Holds a sequence of time-stamped midi events.

Analogous to the AudioSampleBuffer, this holds a set of midi events with integer time-stamps. The buffer is kept sorted in order of the time-stamps.

See also:
MidiMessage

Constructor & Destructor Documentation

MidiBuffer::MidiBuffer (  )  throw ()

Creates an empty MidiBuffer.

MidiBuffer::MidiBuffer ( const MidiMessage message  )  throw () [explicit]

Creates a MidiBuffer containing a single midi message.

MidiBuffer::MidiBuffer ( const MidiBuffer other  )  throw ()

Creates a copy of another MidiBuffer.

MidiBuffer::~MidiBuffer (  )  throw ()

Destructor.


Member Function Documentation

MidiBuffer& MidiBuffer::operator= ( const MidiBuffer other  )  throw ()

Makes a copy of another MidiBuffer.

void MidiBuffer::clear (  )  throw ()

Removes all events from the buffer.

void MidiBuffer::clear ( const int  start,
const int  numSamples 
) throw ()

Removes all events between two times from the buffer.

All events for which (start <= event position < start + numSamples) will be removed.

bool MidiBuffer::isEmpty (  )  const throw ()

Returns true if the buffer is empty.

To actually retrieve the events, use a MidiBuffer::Iterator object

int MidiBuffer::getNumEvents (  )  const throw ()

Counts the number of events in the buffer.

This is actually quite a slow operation, as it has to iterate through all the events, so you might prefer to call isEmpty() if that's all you need to know.

void MidiBuffer::addEvent ( const MidiMessage midiMessage,
const int  sampleNumber 
) throw ()

Adds an event to the buffer.

The sample number will be used to determine the position of the event in the buffer, which is always kept sorted. The MidiMessage's timestamp is ignored.

If an event is added whose sample position is the same as one or more events already in the buffer, the new event will be placed after the existing ones.

To retrieve events, use a MidiBuffer::Iterator object

void MidiBuffer::addEvent ( const uint8 *const   rawMidiData,
const int  maxBytesOfMidiData,
const int  sampleNumber 
) throw ()

Adds an event to the buffer from raw midi data.

The sample number will be used to determine the position of the event in the buffer, which is always kept sorted.

If an event is added whose sample position is the same as one or more events already in the buffer, the new event will be placed after the existing ones.

The event data will be inspected to calculate the number of bytes in length that the midi event really takes up, so maxBytesOfMidiData may be longer than the data that actually gets stored. E.g. if you pass in a note-on and a length of 4 bytes, it'll actually only store 3 bytes. If the midi data is invalid, it might not add an event at all.

To retrieve events, use a MidiBuffer::Iterator object

void MidiBuffer::addEvents ( const MidiBuffer otherBuffer,
const int  startSample,
const int  numSamples,
const int  sampleDeltaToAdd 
) throw ()

Adds some events from another buffer to this one.

Parameters:
otherBuffer the buffer containing the events you want to add
startSample the lowest sample number in the source buffer for which events should be added. Any source events whose timestamp is less than this will be ignored
numSamples the valid range of samples from the source buffer for which events should be added - i.e. events in the source buffer whose timestamp is greater than or equal to (startSample + numSamples) will be ignored. If this value is less than 0, all events after startSample will be taken.
sampleDeltaToAdd a value which will be added to the source timestamps of the events that are added to this buffer
int MidiBuffer::getFirstEventTime (  )  const throw ()

Returns the sample number of the first event in the buffer.

If the buffer's empty, this will just return 0.

int MidiBuffer::getLastEventTime (  )  const throw ()

Returns the sample number of the last event in the buffer.

If the buffer's empty, this will just return 0.

void MidiBuffer::swapWith ( MidiBuffer other  ) 

Exchanges the contents of this buffer with another one.

This is a quick operation, because no memory allocating or copying is done, it just swaps the internal state of the two buffers.

void MidiBuffer::ensureSize ( size_t  minimumNumBytes  ) 

Preallocates some memory for the buffer to use.

This helps to avoid needing to reallocate space when the buffer has messages added to it.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Mon Apr 26 11:42:13 2010 for JUCE by  doxygen 1.6.3