BASS MIDI

BASS_MIDI_StreamGetPreset


Retrieves the preset currently in use on a channel of a MIDI stream.

BOOL BASS_MIDI_StreamGetPreset(
    HSTREAM handle,
    DWORD chan,
    BASS_MIDI_FONT *font
);

Parameters

handleThe MIDI stream to retrieve the soundfont configuration of... 0 = get default soundfont configuration.
chanThe MIDI channel... 0 = channel 1.
fontsPointer to a structure to receive the preset information.

Return value

If successful, TRUE is returned, else FALSE is returned. Use BASS_ErrorGetCode to get the error code.

Error codes

BASS_ERROR_HANDLEhandle is not valid.
BASS_ERROR_ILLPARAMchan is not valid.
BASS_ERROR_NOTAVAILNo preset is currently in use on the specified MIDI channel.

Remarks

This function tells what preset from what soundfont is currently being used on a particular MIDI channel. That information can be used to get the preset's name from BASS_MIDI_FontGetPreset.

No preset information will be available for a MIDI channel until a note is played in that channel. The present and bank numbers will not necessarily match the channel's current MIDI_EVENT_PROGRAM and MIDI_EVENT_BANK event values, but rather what the MIDI stream's soundfont configuration maps those event values to.

Example

List the presets in use on all 16 MIDI channels.
BASS_MIDI_FONT font;
int ch;
for (ch=0; ch<16; ch++) {
    if (BASS_MIDI_StreamGetPreset(handle, ch, &font;)) // get preset information for the MIDI channel
        printf("%d: %s\n", ch+1, BASS_MIDI_FontGetPreset(font.font, font.preset, font.bank)); // display the preset name
}

See also

BASS_MIDI_FontGetPreset, BASS_MIDI_FONT structure