BASS.NET API for the Un4seen BASS Audio Library

BassMidiBASS_MIDI_StreamEvent Method (Int32, Int32, BASSMIDIEvent, Int32)

BASS.NET API for the Un4seen BASS Audio Library
Applies an event to a MIDI stream.

Namespace:  Un4seen.Bass.AddOn.Midi
Assembly:  Bass.Net (in Bass.Net.dll) Version: 2.4.17.5
Syntax

[DllImportAttribute("bassmidi")]
public static bool BASS_MIDI_StreamEvent(
	int handle,
	int chan,
	BASSMIDIEvent eventtype,
	int param
)

Parameters

handle
Type: SystemInt32
The MIDI stream to apply the event to (as returned by BASS_MIDI_StreamCreate(Int32, BASSFlag, Int32)).
chan
Type: SystemInt32
The MIDI channel to apply the event to... 0 = channel 1.
eventtype
Type: Un4seen.Bass.AddOn.MidiBASSMIDIEvent
The event to apply (see BASSMIDIEvent for details).
param
Type: SystemInt32
The event parameter (see BASSMIDIEvent for details).

Return Value

Type: Boolean
If successful, is returned, else is returned. Use BASS_ErrorGetCode to get the error code.
Remarks

Apart from the "global" events, all events apply only to the specified MIDI channel.

Except for the "non-MIDI" events, events applied to a MIDI file stream can subsequently be overridden by events in the file itself, and will also be overridden when seeking or looping. That can be avoided by using additional channels, allocated via the BASS_ATTRIB_MIDI_CHANS attribute.

Event syncs (BASS_SYNC_MIDI_xxx, see BASSSync) are not triggered by this function. If sync triggering is wanted, BASS_MIDI_StreamEvents(Int32, BASSMIDIEventMode, BASS_MIDI_EVENT, Int32) can be used instead.

If the MIDI stream is being played (it's not a decoding channel), then there will be some delay in the effect of the event being heard. This latency can be reduced by making use of the BASS_CONFIG_BUFFER and BASS_CONFIG_UPDATEPERIOD config options when creating the stream.

If multiple events need to be applied at the same time, BASS_MIDI_StreamEvents(Int32, BASSMIDIEventMode, BASS_MIDI_EVENT, Int32) can be used instead of this function.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_ILLPARAMOne of the other parameters is invalid.

Examples

Play the middle C note (key 60) with a velocity of 100, on channel 1 for 2 seconds:
// press the key
BassMidi.BASS_MIDI_StreamEvent(handle, 0, BASSMIDIEvent.MIDI_EVENT_NOTE, 60, 100);
// wait 2 seconds
Thread.Sleep(2000);
// release the key
BassMidi.BASS_MIDI_StreamEvent(handle, 0, BASSMIDIEvent.MIDI_EVENT_NOTE, 60);
See Also

Reference