Crate oxcable_subtractive_synth [] [src]

A polyphonic subtractive synthesizer.

This synthesizer uses building blocks from oxcable to perform basic subtractive synthesis. The synth is controlled via MIDI and packaged as an AudioDevice.

Signal Chain

The synthesizer is polyphonic. The signal chain is composed of:

  1. Two oscillators, operating independently. The oscillators may be transposed relative to each other.
  2. Independent ADSR envelopes for each voice.
  3. The signal is then passed through a multimode filter.

Additionally, the synthesizer has an internal low frequency oscillator. This LFO may be used to add vibrato to the oscillators, or tremolo to the output.

Controlling Tone

The synthesizer provides three ways to configure its tone:

  1. At initialization, using the builder pattern.
  2. During runtime, by passing it a Message.
  3. With MIDI control signals, using a control map...

MIDI Control Signals

Many MIDI controllers feature additional knobs and sliders. These use a special type of MIDI signal that is left open to instrument makers to use as they desire. To use these knobs for tone control, the synth uses an optional closure to convert these control signals to synthesizer messages. This closure takes the form:

fn control_map(controller: u8, value: u8) -> Option<Message>;

The exact values used can vary from device to device, but controller will always specify which knob is being used, and the value will range from 0 to 127.

If Some(msg) is returned, it will be used to update the synth immediately; if None is returned, the MIDI message is ignored.

The following example uses knobs on the Alesis QX49 keyboard to adjust the ADSR envelope and vibrato:

use oxcable_subtractive_synth as subsynth;
fn qx49_controls(controller: u8, value: u8) -> Option<subsynth::Message> {
    let range = value as f32 / 127.0; // normalize to range [0.0, 1.0]
    match controller {
        22 => Some(subsynth::SetAttack(5.0*range)),
        23 => Some(subsynth::SetDecay(5.0*range)),
        24 => Some(subsynth::SetSustain(range)),
        25 => Some(subsynth::SetRelease(5.0*range)),
        26 => Some(subsynth::SetLFOFreq(10.0*range)),
        27 => Some(subsynth::SetVibrato(range)),
        _ => None
    }
}

Reexports

pub use self::Message::*;

Structs

SubtractiveSynth

A polyphonic subtractive synthesizer.

Enums

Message

Defines the messages that the synthesizer supports.