User defined callback function to filter events.
BOOL CALLBACK MidiFilterProc( HSTREAM handle, int track, BASS_MIDI_EVENT *event, BOOL seeking, void *user );
handle | The MIDI stream handle. |
track | The track that the event is from... 0 = 1st track, -1 = no track. |
event | Pointer to the event structure. |
seeking | TRUE = the event is being processed while seeking, FALSE = the event is being played. |
user | The user instance data given when BASS_MIDI_StreamSetFilter was called. |
MIDI_EVENT_NOTE, MIDI_EVENT_NOTESOFF, and MIDI_EVENT_SOUNDOFF events are ignored while seeking so they will not be received by a filtering function then. MIDI_EVENT_TEMPO events can be changed while seeking but doing so when seeking in bytes (BASS_POS_BYTE) will result in reaching a different position. Seeking in ticks (BASS_POS_MIDI_TICK) is unaffected by tempo changes. The MIDI_EVENT_SPEED event can be used to modify the tempo without affecting seeking.
BOOL CALLBACK MidiFilterProc(HSTREAM handle, int track, BASS_MIDI_EVENT *event, BOOL seeking, void *user) { if (event->event == MIDI_EVENT_NOTE) { // got a note int vel = HIBYTE(event->param); // extract the velocity if (vel < 10 && vel > 0) return FALSE; // drop the note if velocity is below 10 and not 0 (note off) } return TRUE; // process the event }
A filtering function that changes bank 2 to bank 1.
BOOL CALLBACK MidiFilterProc(HSTREAM handle, int track, BASS_MIDI_EVENT *event, BOOL seeking, void *user) { if (event->event == MIDI_EVENT_BANK && event->param == 2) // got a bank 2 request event->param = 1; // change it to bank 1 return TRUE; // process the event }