Initializes a soundfont.
|file||The soundfont filename.
|flags||Any combination of these flags.|
|BASS_MIDI_FONT_LINATTMOD||Use a linear attack phase in SF2 modulation (pitch/filter) envelopes. Otherwise a convex curve is used. The attack phase is always linear in SFZ envelopes.
|BASS_MIDI_FONT_MMAP||Map the file into memory. This flag is ignored if the soundfont is packed as the sample data cannot be played directly from a mapping; it needs to be decoded. This flag is also ignored if the file is too large to be mapped into memory.
|BASS_MIDI_FONT_NOFX||Ignore the reverb/chorus levels of the presets in the soundfont (only use the levels in the MIDI events).
|BASS_MIDI_FONT_XGDRUMS||Use bank 127 in the soundfont for XG drum kits. When an XG drum kit is needed, bank 127 in soundfonts that have this flag set will be checked first, before falling back to bank 128 (the standard SF2 drum kit bank) if it is not available there.
|BASS_UNICODE||file is in UTF-16 form. Otherwise it is ANSI on Windows, and UTF-8 on other platforms.
If successful, the soundfont's handle is returned, else 0 is returned. Use BASS_ErrorGetCode to get the error code.
|BASS_ERROR_FILEOPEN||The file could not be opened.
|BASS_ERROR_FILEFORM||The file's format is not recognised/supported.
|BASS_ERROR_MEM||There is insufficient memory.
|BASS_ERROR_MIDI_INCLUDE||An SFZ #include directive file could not be opened.
BASSMIDI uses SF2 and/or SFZ soundfonts to provide the sounds to use in the rendering of MIDI files. Several soundfonts can be found on the internet, including a couple on the BASS website.
A soundfont needs to be initialized before it can be used to render MIDI streams. Once initialized, a soundfont can be assigned to MIDI streams via the BASS_MIDI_StreamSetFonts function. A single soundfont can be shared by multiple MIDI streams. If a soundfont is initialized multiple times, each instance will have its own handle but share the same data. Information on the initialized soundfont can be retrieved using BASS_MIDI_FontGetInfo.
Soundfonts use PCM sample data as standard, but BASSMIDI can accept any format that is supported by BASS or its add-ons (the add-ons need to be loaded via BASS_PluginLoad). The BASS_MIDI_FontPack function can be used to compress the sample data in SF2 files. SFZ samples are in separate files and can be compressed using standard encoding tools.
Using soundfonts that are located somewhere other than the file system is possible via BASS_MIDI_FontInitUser.
The SF2 synthesis model is fully supported, as are all SF2 generators. Basic support for the note velocity to attenuation (initialAttenuation), note velocity to filter cutoff (initialFilterFc) and note velocity to volume envelope attack (attackVolEnv) modulators is also included. In each case, multiple modulators in the global/instrument/preset zones is supported but only if they are identical (eg. all negative unipolar linear). If different types are present on a preset then the last one (with a non-zero amount) will be used. In the note velocity to attenuation modulator case, only the negative unipolar concave curve is supported. The SF2 spec's slightly strange default note velocity to filter cutoff modulator is not used.
The following SFZ opcodes are supported: ampeg_attack, ampeg_decay, ampeg_delay, ampeg_hold, ampeg_release, ampeg_sustain, ampeg_vel2attack, ampeg_vel2decay, amplfo_delay, amplfo_depth, amplfo_fade, amplfo_freq, amp_veltrack, cutoff, default_path, delay, effect1, effect2, end, fileg_attack/pitcheg_attack, fileg_decay/pitcheg_decay, fileg_delay/pitcheg_delay, fileg_depth, fileg_hold/pitcheg_hold, fileg_release/pitcheg_release, fileg_sustain/pitcheg_sustain, fileg_vel2depth, fillfo_delay, fillfo_depth, fillfo_fade, fillfo_freq, fil_veltrack, group, hicc1, hicc64, hikey, hirand, hivel, key, locc1, locc64, lokey, loop_end, loop_mode, loop_start, lorand, lovel, offset, off_by, off_mode, pan, pitcheg_depth, pitchlfo_delay, pitchlfo_depth, pitchlfo_fade, pitchlfo_freq, pitch_keycenter, pitch_keytrack, pitch_random, pitch_veltrack, resonance, rt_decay, sample, seq_length, seq_position, transpose, trigger, tune, volume. The fil_type opcode is also supported, but only to confirm that a low pass filter is wanted (the filter will be disabled otherwise). The combined fileg/pitcheg entries in the opcode list reflect that there is a shared envelope generator for pitch and filter, as is the case in SF2 soundfonts. Information on these (and other) SFZ opcodes can be found at www.sfzformat.com. The #include directive is also supported.
Samples can also be loaded from memory by setting the "sample" opcode to "mem:<address>:<length>", where address and length are both in hexadecimal. The memory should remain valid until the font is freed via BASS_MIDI_FontFree.
SFZ files do not have a defined preset or bank number, so they are nominally assigned to preset 0 in bank 0 when loaded, but can be assigned to other presets/banks via BASS_MIDI_StreamSetFonts.
The BASS_MIDI_FONT_MMAP option is not available on big-endian systems (eg. PowerPC) as a soundfont's little-endian sample data cannot be played directly from a mapping; its byte order needs to be reversed.
Initialize a soundfont.
HSOUNDFONT sfont=BASS_MIDI_FontInit("blah.sf2", 0);
BASS_MIDI_FontFree, BASS_MIDI_FontGetInfo, BASS_MIDI_FontGetPresets, BASS_MIDI_FontInitUser, BASS_MIDI_FontPack, BASS_MIDI_FontLoad, BASS_MIDI_FontSetVolume, BASS_MIDI_StreamSetFonts, BASS_CONFIG_MIDI_COMPACT