Expand description
Soundfont-backed fill sources: one SynthVoice per soundfont, mixed.
A voice lives in the audio world with the OnAudioFill that renders it,
so it sounds by existing. Its synthesizer waits for the first fill, which
reports the rate the stream really runs at: nothing has to know that rate
before the device opens.
Gameplay never touches the synthesizer. A live note is a midi_job; a
sequence is a MidiSequencer in the gameplay world, advanced once a
frame, which sends the same jobs at the moments its events come due. The
audio thread only turns messages into samples and sums every source into
the streamโs interleaved frames.
Re-exportsยง
use std::sync::Arc;๐use rustysynth_ext::MidiFileError;๐use rustysynth_ext::SoundFontError;๐use rustysynth_ext::SynthesizerError;๐use rustysynth_ext::SynthesizerSettings;๐use unlit_ecs::Bundle;๐use unlit_ecs::DynamicBundle;๐use unlit_ecs::Entity;๐use unlit_ecs::World;๐use unlit_ecs::bundle;๐use crate::audio::AudioChunk;๐use crate::audio::AudioFillOrder;๐use crate::audio::OnAudioFill;๐use crate::job::Job;๐use crate::job::JobSender;๐
Structsยง
- Midi
File - Represents a standard MIDI file.
- Midi
Sequencer - One sequence, its clock and where it loops.
- Sound
Font - Represents a SoundFont.
- Synth
Voice - A loaded soundfont and the synthesizer playing it, as one object.
- Synthesizer
- An instance of the SoundFont synthesizer.
Enumsยง
- Midi
Event Kind - A MIDI message the synthesizer acts on.
- 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.
- Voice
Error - Why a soundfont or a MIDI file could not be built.
Constantsยง
- BLOCK_
FRAMES ๐ - The synthesizerโs block size, and how finely a fill places a message inside itself: a note lands on a block boundary, so this is the timing resolution below one fill.
Functionsยง
- add_
stereo ๐ - Adds a stereo block onto the chunkโs interleaved frames.
- fill_
voice ๐ - Builds the voiceโs synthesizer if it has none, adds the queueโs messages at their offsets, and renders the whole fill into the chunk.
- load_
midi_ file_ with_ loop_ type - Parses a standard MIDI file from
bytes, reading its loop markers the wayloop_typedescribes. - load_
soundfont - Parses the soundfont in
bytes. - midi_
file - Builds a MIDI file from timed messages, ready for
MidiSequencer::new. - midi_
job - A job that sends
kindtovoice,delayseconds from the next fillโs start. A negative delay is treated as zero. - synthesizer ๐
- The synthesizer
fontplays through atrate, set up the way a voice wants it: full scale out of the box, because the libraryโs default of 0.5 is a -6 dB cut that every caller would otherwise have to undo.
Type Aliasesยง
- Midi
Event - One MIDI message and when to send it: seconds since the sequence starts, then the message.