Expand description
Rsynth
A crate for developing audio plugins and applications in Rust, with a focus on software synthesis. Rsynth is well suited as a bootstrap for common audio plugin generators. It handles voices, voice-stealing, polyphony, etc. so the programmer’s main focus can be DSP.
Deprecation notice
This crate has been deprecated. See its README.md for more details.
Back-ends
rsynth
currently supports the following back-ends:
combined
combine different back-ends for audio input, audio output, midi input and midi output, mostly for offline rendering and testing (behind various features)jack
(behind thebackend-jack
feature)vst
(behind thebackend-vst
feature)
See the documentation of each back-end for more information.
Rendering audio
Audio can be rendered by using a number of traits:
- the
AudioRenderer
trait - the
ContextualAudioRenderer
trait
The difference between these traits is that the ContextualAudioRenderer
trait adds one extra
parameter that defines a “context” that can be passed to the implementor of the trait, so that
the implementor of the trait does not need to own all data that is needed for rendering the
audio; it can also borrow some data with additional the context
parameter.
Both traits are generic over the data type that represents the sample. For which specific data-type an application or plugin needs to implement the trait, depends on the back-end. Because the trait is generic, the application or plugin can have a generic implementation as well that can be used by different back-ends.
Meta-data
There are a number of traits that an application or plugin needs to implement in order to define meta-data.
Every plugin should implement these, but it can be tedious, so you can implement these
traits in a more straightforward way by implementing the Meta
trait.
However, you can also implement these trait “by hand”:
CommonPluginMeta
- Name of the plugin etc
AudioHandlerMeta
- Number of audio ports
MidiHandlerMeta
- Number of midi ports
CommonAudioPortMeta
- Names of the audio in and out ports
CommonPluginMeta
- Name of the plugin or application
Additionally, back-ends can require extra trait related to meta-data.
Handling events
Plugins or application can handle events by implementing a number of traits:
Both traits are generic over the event type.
These traits are very similar, the ContextualEventHandler
trait adds one extra parameter
that defines a “context” that can be passed to the implementor of the trait, so that the
implementor of the trait does not need to own all data that is needed for handling the event;
it can also borrow some data with additional the context
parameter.
Events
rsynth
defines a number of event types:
RawMidiEvent
: a raw MIDI eventSysExEvent
: a system exclusive eventTimed<T>
: a generic timed eventIndexed<T>
: a generic event that associates a timestamp with the event
Utilities
Utilities are are types that you can include to perform several common tasks for the plugin or application:
- polyphony: managing of different voices
Modules
- Backends.
- Audio buffers.
- envelopeDeprecatedThis module has not been thoroughly tested, so expect some rough edges here and there.
- Event handling
- Mechanisms for defining the meta-data of a plugin or application.
- Utilities for testing.
- utilitiesDeprecated
Macros
- Create an audio chunk.
- A wrapper around the
plugin_main!
macro from thevst
crate. You call this with one parameter, which is the function declaration of a function that creates your plugin. This function may also do some setup (e.g. initialize logging).
Traits
- Define how sample-rate changes are handled.
- Define the maximum number of audio inputs and the maximum number of audio outputs.
- Defines how audio is rendered.
- Provides some meta-data of the audio-ports used by the plugin or application to the host. This trait can be more conveniently implemented by implementing the
Meta
trait. - Provides some meta-data of the midi-ports used by the plugin or application to the host. This trait can be more conveniently implemented by implementing the
Meta
trait. - Provides common meta-data of the plugin or application to the host. This trait is common for all backends that need this info. This trait can be more conveniently implemented by implementing the
Meta
trait. - Defines how audio is rendered, similar to the
AudioRenderer
trait. The extra parametercontext
can be used by the backend to provide extra information. - Define the maximum number of midi inputs and the maximum number of midi outputs. This trait can be more conveniently implemented by implementing the
Meta
trait.