#audio #synth #soundfont #sf2 #sf3

fluidlite

Safe bindings to fluidlite library

5 releases

0.2.1 Aug 21, 2021
0.2.0 Mar 31, 2021
0.1.3 Jun 14, 2020
0.1.2 Feb 14, 2020
0.1.0 Feb 11, 2020

#48 in Audio

Download history 25/week @ 2021-08-15 42/week @ 2021-08-22 12/week @ 2021-08-29 7/week @ 2021-09-05 18/week @ 2021-09-12 27/week @ 2021-09-19 13/week @ 2021-09-26 41/week @ 2021-10-03 32/week @ 2021-10-10 3/week @ 2021-10-17 13/week @ 2021-10-24 15/week @ 2021-10-31 14/week @ 2021-11-07 21/week @ 2021-11-14 16/week @ 2021-11-21 73/week @ 2021-11-28

125 downloads per month
Used in 4 crates (3 directly)

LGPL-2.1

3MB
64K SLoC

Rust 35K SLoC // 0.0% comments C 29K SLoC // 0.2% comments Perl 110 SLoC // 0.0% comments

Rust fluidlite bindings

github crate docs LGPL-2.1 CI

This project aims provide safe Rust bindings to fluidlite C library.

FluidLite is a very light version of FluidSynth designed to be hardware, platform and external dependency independant. It only uses standard C libraries.

It also adds support for SF3 files (SF2 files compressed with ogg vorbis) and an additional setting to remove the constraint of channel 9 (drums): fluid_settings_setstr(settings, "synth.drums-channel.active", "no"); you can still select bank 128 on any channel to use drum kits.

FluidLite keeps very minimal functionnalities (settings and synth), therefore MIDI file reading, realtime MIDI events and audio output must be implemented externally.

Crates

Features

  • bindgen Force generate bindings itself instead of use pre-generated
  • builtin Force compile builtin fluidlite C-library
  • pkg-config Use pkg-config to find installed libraries
  • with-sf3 Enable SoundFont3 support (SF2 with vorbis-encoded samples)
  • with-stb Use stb-vorbis decoder instead of libvorbis/libogg.
  • shared Build shared fluidlite C-library
  • static Build static fluidlite C-library

When pkg-config feature is used the installed fluidlite library will be used if found. To force build and link builtin version you can use builtin feature.

Example

use std::{fs::File, io::Write};
use byte_slice_cast::AsByteSlice;
use fluidlite::{Settings, Synth};

let settings = Settings::new().unwrap();

let synth = Synth::new(settings).unwrap();
synth.sfload("sf_/Boomwhacker.sf3", true).unwrap();

let mut buffer = [0i16; 44100 * 2];
let mut file = File::create("soundfont-sample.pcm").unwrap();

synth.note_on(0, 60, 127).unwrap();
synth.write(buffer.as_mut()).unwrap();
file.write(buffer.as_byte_slice()).unwrap();

synth.note_off(0, 60).unwrap();
synth.write(buffer.as_mut()).unwrap();
file.write(buffer.as_byte_slice()).unwrap();

Dependencies