Retrieves the events in a MIDI stream.
DWORD BASS_MIDI_StreamGetEvents( HSTREAM handle, int track, DWORD filter, BASS_MIDI_EVENT *events );
handle | The MIDI stream to get the events from. |
track | The track to get the events from... 0 = 1st track, -1 = all tracks. |
filter | The type of events to retrieve... 0 = all events. See BASS_MIDI_StreamEvent for a list of possible event types. A special MIDI_EVENT_NOTES event type is also available to get only note-on events (MIDI_EVENT_NOTE events with a non-0 velocity). |
events | Pointer to an array to receive the events... NULL = get the number of events without getting the events themselves. |
BASS_ERROR_HANDLE | handle is not valid. |
BASS_ERROR_NOTAVAIL | The stream does not have an event sequence. |
BASS_ERROR_ILLPARAM | track is not valid. |
BASS_MIDI_StreamGetEventsEx can be used to get a portion of the events instead of all of them.
DWORD eventc = BASS_MIDI_StreamGetEvents(handle, 0, 0, NULL); // get number of events in 1st track BASS_MIDI_EVENT *events = (BASS_MIDI_EVENT*)malloc(eventc * sizeof(BASS_MIDI_EVENT)); // allocate event array BASS_MIDI_StreamGetEvents(handle, 0, 0, events); // get the events
Retrieve all note events in the 2nd track.
DWORD eventc = BASS_MIDI_StreamGetEvents(handle, 1, MIDI_EVENT_NOTE, NULL); // get number of note events in 2nd track BASS_MIDI_EVENT *events = (BASS_MIDI_EVENT*)malloc(eventc * sizeof(BASS_MIDI_EVENT)); // allocate event array BASS_MIDI_StreamGetEvents(handle, 1, MIDI_EVENT_NOTE, events); // get the events