Expand description
A SoundFont (.sf2 and, behind the sf3 feature, .sf3) MIDI synthesizer
written in pure Rust.
A SoundFont is loaded once and shared behind an Arc, and a Synthesizer
built from it renders the waveform into a pair of f32 buffers, either played
directly with Synthesizer::note_on and friends or driven by a MidiFile
through a MidiFileSequencer.
use std::fs::File;
use std::sync::Arc;
use rustysynth_ext::{SoundFont, Synthesizer, SynthesizerSettings};
let mut sf2 = File::open("TimGM6mb.sf2").unwrap();
let sound_font = Arc::new(SoundFont::new(&mut sf2).unwrap());
let settings = SynthesizerSettings::new(44100);
let mut synthesizer = Synthesizer::new(&sound_font, &settings).unwrap();
synthesizer.note_on(0, 60, 100);
let mut left = vec![0.0_f32; 44100];
let mut right = vec![0.0_f32; 44100];
synthesizer.render(&mut left, &mut right);Structs§
- Instrument
- Represents an instrument in the SoundFont.
- Instrument
Region - Represents an instrument region. An instrument region contains all the parameters necessary to synthesize a note.
- Midi
File - Represents a standard MIDI file.
- Midi
File Sequencer - An instance of the MIDI file sequencer.
- Preset
- Represents a preset in the SoundFont.
- Preset
Region - Represents a preset region. A preset region indicates how the parameters of the instrument should be modified in the preset.
- Sample
Header - Represents a sample in the SoundFont.
- Sound
Font - Represents a SoundFont.
- Sound
Font Info - The information of a SoundFont.
- Sound
Font Version - Represents the version of a SoundFont.
- Synthesizer
- An instance of the SoundFont synthesizer.
- Synthesizer
Settings - Specifies a set of parameters for synthesis.
Enums§
- Loop
Mode - Specifies how the sample loops during playback.
- Midi
File Error - Represents an error when loading a MIDI file.
- Midi
File Loop Type - Specifies the type of the loop extension to use when playing back a MIDI file.
- Midi
Message - A single event of a merged MIDI file.
- Sound
Font Error - Represents an error when loading a SoundFont.
- Synthesizer
Error - Represents an error when initializing a synthesizer.