/// <summary> /// Initializes a soundfont from a file (unicode). /// </summary> /// <param name="File">The file name of the sound font (e.g. an .sf2 file).</param> /// <param name="Flags">Any combination of <see cref="FontInitFlags"/>.</param> /// <returns>If successful, the soundfont's handle is returned, else 0 is returned. Use <see cref="Bass.LastError" /> to get the error code.</returns> /// <remarks> /// <para> /// 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. /// </para> /// <para> /// 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 using the <see cref="StreamSetFonts(int,MidiFont[],int)" /> function. /// A single soundfont can be shared by multiple MIDI streams. /// </para> /// <para>Information on the initialized soundfont can be retrieved using <see cref="FontGetInfo(int,out MidiFontInfo)" />.</para> /// <para>If a soundfont is initialized multiple times, each instance will have its own handle but share the same sample/etc data.</para> /// <para> /// Soundfonts use PCM sample data as standard, but BASSMIDI can accept any format that is supported by BASS or its add-ons. /// The 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. /// </para> /// <para>Using soundfonts that are located somewhere other than the file system is possible via <see cref="FontInit(FileProcedures,IntPtr,BassFlags)" />.</para> /// <para><b>SFZ support</b></para> /// <para> /// The following SFZ opcodes are supported: ampeg_attack, ampeg_decay, ampeg_delay, ampeg_hold, ampeg_release, ampeg_sustain, ampeg_vel2attack, ampeg_vel2decay, amplfo_delay/fillfo_delay/pitchlfo_delay, amplfo_depth, amplfo_freq/fillfo_freq/pitchlfo_freq, amp_veltrack, cutoff, 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_depth, fil_veltrack, group, hikey, hivel, key, lokey, loop_end, loop_mode, loop_start, lovel, offset, off_by, pan, pitcheg_depth, pitchlfo_depth, pitch_keycenter, pitch_keytrack, pitch_veltrack, resonance, sample, seq_length, seq_position, transpose, 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 EG and LFO entries in the opcode list reflect that there is a shared EG for pitch/filter and a shared LFO for amplitude/pitch/filter, as is the case in SF2. /// Information on these (and other) SFZ opcodes can be found at www.sfzformat.com. /// </para> /// <para><b>Platform-specific</b></para> /// <para>The <see cref="BassFlags.MidiFontMemoryMap"/> 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.</para> /// </remarks> /// <exception cref="Errors.FileOpen">The <paramref name="File" /> could not be opened.</exception> /// <exception cref="Errors.FileFormat">The file's format is not recognised/supported.</exception> public static int FontInit(string File, FontInitFlags Flags) => BASS_MIDI_FontInit(File, Flags | FontInitFlags.Unicode);
public static extern int FontInit([In, Out] FileProcedures Procedures, IntPtr User, FontInitFlags Flags);
static extern int BASS_MIDI_FontInit(string File, FontInitFlags flags);