BASS MIDI

BASS_MIDI_FontUnpack


Produces a decompressed version of a packed soundfont.

BOOL BASS_MIDI_FontUnpack(
    HSOUNDFONT handle,
    void *outfile,
    DWORD flags
);

Parameters

handleThe soundfont to unpack.
outfileFilename for the unpacked soundfont.
flagsAny combination of these flags.
BASS_UNICODEoutfile is in UTF-16 form. Otherwise it is ANSI on Windows, and UTF-8 on other platforms.

Return value

If successful, the 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_NOTAVAILThe soundfont is not packed.
BASS_ERROR_INITBASS_Init has not been successfully called - it needs to be to decode the samples.
BASS_ERROR_CODECThe appropriate add-on to decode the samples is not loaded.
BASS_ERROR_CREATECould not create the output file, outfile.
BASS_ERROR_UNKNOWNSome other mystery problem!

Remarks

To unpack a soundfont, the appropriate BASS add-on needs to be loaded (via BASS_PluginLoad) to decode the samples. For example, if the samples are FLAC encoded, BASSFLAC would need to be loaded. BASS also needs to have been initialized, using BASS_Init. For just unpacking a soundfont, the "no sound" device could be used.

A soundfont should not be unpacked while it is being used to render any MIDI streams, as that could delay the rendering.

BASS_MIDI_FontGetInfo can be used to check if a soundfont is packed.

Example

Unpack a FLAC encoded soundfont.
BASS_PluginLoad("bassflac.dll", 0); // load FLAC plugin
HSOUNDFONT handle=BASS_MIDI_FontInit("afile.sf2pack", 0); // open soundfont
BASS_MIDI_FontUnpack(handle, "afile.sf2", 0); // produce unpacked version

See also

BASS_MIDI_FontInit, BASS_MIDI_FontPack