Skip to main content

Module synth

Module synth 

Source
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ยง

MidiFile
Represents a standard MIDI file.
MidiSequencer
One sequence, its clock and where it loops.
SoundFont
Represents a SoundFont.
SynthVoice
A loaded soundfont and the synthesizer playing it, as one object.
Synthesizer
An instance of the SoundFont synthesizer.

Enumsยง

MidiEventKind
A MIDI message the synthesizer acts on.
MidiFileLoopType
Specifies the type of the loop extension to use when playing back a MIDI file.
MidiMessage
A single event of a merged MIDI file.
VoiceError
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 way loop_type describes.
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 kind to voice, delay seconds from the next fillโ€™s start. A negative delay is treated as zero.
synthesizer ๐Ÿ”’
The synthesizer font plays through at rate, 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ยง

MidiEvent
One MIDI message and when to send it: seconds since the sequence starts, then the message.