User defined callback function to filter events.
Namespace: Un4seen.Bass.AddOn.Midi
Assembly: Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax
public delegate bool MIDIFILTERPROC( int handle, int track, IntPtr eventPtr, bool seeking, IntPtr user )
Parameters
- handle
- Type: SystemInt32
The MIDI stream handle. - track
- Type: SystemInt32
The track that the event is from... 0 = 1st track. - eventPtr
- Type: SystemIntPtr
Pointer to the BASS_MIDI_EVENT structure. - seeking
- Type: SystemBoolean
= the event is being processed while seeking, = the event is being played. - user
- Type: SystemIntPtr
The user instance data given when BASS_MIDI_StreamSetFilter(Int32, Boolean, MIDIFILTERPROC, IntPtr) was called.
Return Value
Type: BooleanReturn to process the event, and to drop the event.
Remarks
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.
Examples
C#
private void MidiFilterProc(int handle, int track, IntPtr eventPtr, bool seeking, IntPtr user) { var midievent = BASS_MIDI_EVENT.FromIntPtr(eventPtr); if (midievent.eventtype == BASSMIDIEvent.MIDI_EVENT_NOTE) { // got a note int vel = Utils.HighWord32(midievent.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 }
C#
private void MidiFilterProc(int handle, int track, IntPtr eventPtr, bool seeking, IntPtr user) { var midievent = BASS_MIDI_EVENT.FromIntPtr(eventPtr); if (midievent.eventtype == BASSMIDIEvent.MIDI_EVENT_BANK && midievent.param == 2) { // got a bank 2 request midievent.param = 1; // change it to bank 1 } return true; // process the event }
See Also