BASS.NET API for the Un4seen BASS Audio LibraryBassMidiBASS_MIDI_StreamSetFonts Method (Int32, BASS_MIDI_FONTEX, 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: 2.4.12.0
Syntax

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

Parameters

handle
Type: SystemInt32
The MIDI stream to apply the soundfonts to... 0 = set default soundfont configuration.
fonts
Type: Un4seen.Bass.AddOn.MidiBASS_MIDI_FONTEX
The pointer to an array of BASS_MIDI_FONTEX soundfonts to apply.
count
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.
Remarks

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.

Examples

Set a MIDI stream to use preset 20 from one soundfont for program 10 on bank 0, and all available presets from another soundfont:
VB
' first initialize the fonts
Dim font1 As Integer =  BassMidi.BASS_MIDI_FontInit("afont.sf2") 
Dim font2 As Integer =  BassMidi.BASS_MIDI_FontInit("bfont.sf2") 
Dim fonts As BASS_MIDI_FONTEX() = New BASS_MIDI_FONTEX(1) {}
fonts(0).font = font1
fonts(0).spreset = 10 ' soundfont preset 20
fonts(0).sbank = 0 ' soundfont bank 0
fonts(0).dpreset = 10 ' destination preset 10
fonts(0).dbank = 0 ' destination bank 0
fonts(0).dbanklsb = 0 ' destination bank LSB 0
fonts(1).font = font2
fonts(1).spreset = -1 ' all presets
fonts(1).sbank = -1 ' all banks
fonts(1).dpreset = -1 ' all presets
fonts(1).dbank = 0 ' default banks
fonts(1).dbanklsb = 0 ' destination bank LSB 0
BASS_MIDI_StreamSetFonts(handle, fonts, 2) ' apply it to the stream
int font1 = BassMidi.BASS_MIDI_FontInit("afont.sf2");
int font2 = BassMidi.BASS_MIDI_FontInit("bfont.sf2");
BASS_MIDI_FONTEX[] fonts = new BASS_MIDI_FONTEX[2];
fonts[0].font = font1;
fonts[0].spreset = 10; // soundfont preset 20
fonts[0].sbank = 0; // soundfont bank 0
fonts[0].dpreset = 10; // destination preset 10
fonts[0].dbank = 0; // destination bank 0
fonts[0].dbanklsb = 0; // destination bank LSB 0
fonts[1].font = font2;
fonts[1].spreset = -1; // all presets
fonts[1].sbank = -1; // all banks
fonts[1].dpreset = -1; // all presets
fonts[1].dbank = 0; // default banks
fonts[1].dbanklsb = 0; // destination bank LSB 0
BASS_MIDI_StreamSetFonts(handle, fonts, 2); // apply it to the stream
See Also

Reference