BASS.NET API for the Un4seen BASS Audio Library

BassMidiBASS_MIDI_StreamSetFonts Method (Int32, BASS_MIDI_FONT, Int32)

BASS.NET API for the Un4seen BASS Audio Library
Applies a soundfont configuration to a MIDI stream, or sets the default soundfont configuration.

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

public static bool BASS_MIDI_StreamSetFonts(
	int handle,
	BASS_MIDI_FONT[] fonts,
	int count


Type: SystemInt32
The MIDI stream to apply the soundfonts to... 0 = set default soundfont configuration.
Type: Un4seen.Bass.AddOn.MidiBASS_MIDI_FONT
The pointer to an array of BASS_MIDI_FONT soundfonts to apply.
Type: SystemInt32
The number of elements in the fonts array.

Return Value

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

Multiple soundfonts can be stacked, each providing different presets, for example. When a preset is present in multiple soundfonts, the earlier soundfont in the array has priority. When a soundfont matching the MIDI file is loaded, that remains loaded when calling this function, and has priority over all other soundfonts. When a preset is not available on a non-0 bank in any soundfont, BASSMIDI will try to fall back to bank 0; first the LSB and then the MSB if still unsuccessful.

Changing the default configuration only affects subsequently created MIDI streams. Existing streams that are using the previous default configuration will continue to use that previous configuration.

On Windows, the default default configuration will be to use the Creative 4MB (CT4MGM.SF2) or 2MB (CT2MGM.SF2) soundfont when present in the Windows system directory.

ERROR CODEDescription
BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_ILLPARAMSomething in the fonts array is invalid, check the soundfont handles.


// first initialize the fonts
int font1 = BassMidi.BASS_MIDI_FontInit("afont.sf2");
int font2 = BassMidi.BASS_MIDI_FontInit("bfont.sf2");
BASS_MIDI_FONT[] newfonts = { new BASS_MIDI_FONT(font1, -1, 0), new BASS_MIDI_FONT(font2, -1, 0) };
// now set them
BassMidi.BASS_MIDI_StreamSetFonts(_stream, newfonts, newfonts.Length);
See Also