Skip to main content

PluginNoteEvent

Type Alias PluginNoteEvent 

Source
pub type PluginNoteEvent<P> = NoteEvent<<P as Plugin>::SysExMessage>;
Expand description

A plugin-specific note event type.

The reason why this is defined like this instead of parameterizing NoteEvent with P is because deriving trait bounds requires all of the plugin’s generic parameters to implement those traits. And we can’t require P to implement things like Clone.

https://github.com/rust-lang/rust/issues/26925

Aliased Type§

pub enum PluginNoteEvent<P> {
Show 18 variants NoteOn { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, velocity: f32, }, NoteOff { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, velocity: f32, }, Choke { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, }, VoiceTerminated { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, }, PolyModulation { timing: u32, voice_id: i32, poly_modulation_id: u32, normalized_offset: f32, }, MonoAutomation { timing: u32, poly_modulation_id: u32, normalized_value: f32, }, PolyPressure { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, pressure: f32, }, PolyVolume { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, gain: f32, }, PolyPan { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, pan: f32, }, PolyTuning { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, tuning: f32, }, PolyVibrato { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, vibrato: f32, }, PolyExpression { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, expression: f32, }, PolyBrightness { timing: u32, voice_id: Option<i32>, channel: u8, note: u8, brightness: f32, }, MidiChannelPressure { timing: u32, channel: u8, pressure: f32, }, MidiPitchBend { timing: u32, channel: u8, value: f32, }, MidiCC { timing: u32, channel: u8, cc: u8, value: f32, }, MidiProgramChange { timing: u32, channel: u8, program: u8, }, MidiSysEx { timing: u32, message: <P as Plugin>::SysExMessage, },
}

Variants§

§

NoteOn

A note on event, available on MidiConfig::Basic and up.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§velocity: f32

The note’s velocity, in [0, 1]. Some plugin APIs may allow higher precision than the 128 levels available in MIDI.

§

NoteOff

A note off event, available on MidiConfig::Basic and up. Bitwig Studio does not provide a voice ID for this event.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§velocity: f32

The note’s velocity, in [0, 1]. Some plugin APIs may allow higher precision than the 128 levels available in MIDI.

§

Choke

A note choke event, available on MidiConfig::Basic and up. When the host sends this to the plugin, it indicates that a voice or all sound associated with a note should immediately stop playing.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§

VoiceTerminated

Sent by the plugin to the host to indicate that a voice has ended. This needs to be sent when a voice terminates when using polyphonic modulation. Otherwise you can ignore this event.

Fields

§timing: u32
§voice_id: Option<i32>

The voice’s unique identifier. Setting this allows a single voice to be terminated if the plugin allows multiple overlapping voices for a single key.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§

PolyModulation

A polyphonic modulation event, available on MidiConfig::Basic and up. This will only be sent for parameters that were decorated with the .with_poly_modulation_id() modifier, and only by supported hosts. This event contains a normalized offset value for the parameter’s current, unmodulated value. That is, an offset for the current value before monophonic modulation is applied, as polyphonic modulation overrides monophonic modulation. There are multiple ways to incorporate this polyphonic modulation into a synthesizer, but a simple way to incorporate this would work as follows:

  • By default, a voice uses the parameter’s global value, which may or may not include monophonic modulation. This is parameter.value for unsmoothed parameters, and smoothed parameters should use block smoothing so the smoothed values can be reused by multiple voices.
  • If a PolyModulation event is emitted for the voice, that voice should use the the normalized offset contained within the event to compute the voice’s modulated value and use that in place of the global value.
    • This value can be obtained by calling param.preview_plain(param.normalized_value() + event.normalized_offset). These functions automatically clamp the values as necessary.
    • If the parameter uses smoothing, then the parameter’s smoother can be copied to the voice. Smoother::set_target() can then be used to have the smoother use the modulated value.
    • One caveat with smoothing is that copying the smoother like this only works correctly if it last produced a value during the sample before the PolyModulation event. Otherwise there may still be an audible jump in parameter values. A solution for this would be to first call the Smoother::reset() with the current sample’s global value before calling set_target().
    • Finally, if the polyphonic modulation happens on the same sample as the NoteOn event, then the smoothing should not start at the current global value. In this case, reset() should be called with the voice’s modulated value.
  • If a MonoAutomation event is emitted for a parameter, then the values or target values (if the parameter uses smoothing) for all voices must be updated. The normalized value from the MonoAutomation and the voice’s normalized modulation offset must be added and converted back to a plain value. This value can be used directly for unsmoothed parameters, or passed to set_target() for smoothed parameters. The global value will have already been updated, so this event only serves as a notification to update polyphonic modulation.
  • When a voice ends, either because the amplitude envelope has hit zero or because the voice was stolen, the plugin must send a VoiceTerminated to the host to let it know that it can reuse the resources it used to modulate the value.

Fields

§timing: u32
§voice_id: i32

The identifier of the voice this polyphonic modulation event should affect. This voice should use the values from this and subsequent polyphonic modulation events instead of the global value.

§poly_modulation_id: u32

The ID that was set for the modulated parameter using the .with_poly_modulation_id() method.

§normalized_offset: f32

The normalized offset value. See the event’s docstring for more information.

§

MonoAutomation

A notification to inform the plugin that a polyphonically modulated parameter has received a new automation value. This is used in conjunction with the PolyModulation event. See that event’s documentation for more details. The parameter’s global value has already been updated when this event is emitted.

Fields

§timing: u32
§poly_modulation_id: u32

The ID that was set for the modulated parameter using the .with_poly_modulation_id() method.

§normalized_value: f32

The parameter’s new normalized value. This needs to be added to a voice’s normalized offset to get that voice’s modulated normalized value. See the PolyModulation event’s docstring for more information.

§

PolyPressure

A polyphonic note pressure/aftertouch event, available on MidiConfig::Basic and up. Not all hosts may support polyphonic aftertouch.

§Note

When implementing MPE support you should use MIDI channel pressure instead as polyphonic key pressure + MPE is undefined as per the MPE specification. Or as a more generic catch all, you may manually combine the polyphonic key pressure and MPE channel pressure.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§pressure: f32

The note’s pressure, in [0, 1].

§

PolyVolume

A volume expression event, available on MidiConfig::Basic and up. Not all hosts may support these expressions.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§gain: f32

The note’s voltage gain ratio, where 1.0 is unity gain.

§

PolyPan

A panning expression event, available on MidiConfig::Basic and up. Not all hosts may support these expressions.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§pan: f32

The note’s panning from, in [-1, 1], with -1 being panned hard left, and 1 being panned hard right.

§

PolyTuning

A tuning expression event, available on MidiConfig::Basic and up. Not all hosts may support these expressions.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§tuning: f32

The note’s tuning in semitones, in [-128, 128].

§

PolyVibrato

A vibrato expression event, available on MidiConfig::Basic and up. Not all hosts may support these expressions.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§vibrato: f32

The note’s vibrato amount, in [0, 1].

§

PolyExpression

A expression expression (yes, expression expression) event, available on MidiConfig::Basic and up. Not all hosts may support these expressions.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§expression: f32

The note’s expression amount, in [0, 1].

§

PolyBrightness

A brightness expression event, available on MidiConfig::Basic and up. Not all hosts may support these expressions.

Fields

§timing: u32
§voice_id: Option<i32>

A unique identifier for this note, if available. Using this to refer to a note is required when allowing overlapping voices for CLAP plugins.

§channel: u8

The note’s channel, in 0..16.

§note: u8

The note’s MIDI key number, in 0..128.

§brightness: f32

The note’s brightness amount, in [0, 1].

§

MidiChannelPressure

A MIDI channel pressure event, available on MidiConfig::MidiCCs and up.

Fields

§timing: u32
§channel: u8

The affected channel, in 0..16.

§pressure: f32

The pressure, normalized to [0, 1] to match the poly pressure event.

§

MidiPitchBend

A MIDI pitch bend, available on MidiConfig::MidiCCs and up.

Fields

§timing: u32
§channel: u8

The affected channel, in 0..16.

§value: f32

The pressure, normalized to [0, 1]. 0.5 means no pitch bend.

§

MidiCC

A MIDI control change event, available on MidiConfig::MidiCCs and up.

§Note

The wrapper does not perform any special handling for two message 14-bit CCs (where the CC number is in 0..32, and the next CC is that number plus 32) or for four message RPN messages. For now you will need to handle these CCs yourself.

Fields

§timing: u32
§channel: u8

The affected channel, in 0..16.

§cc: u8

The control change number. See control_change for a list of CC numbers.

§value: f32

The CC’s value, normalized to [0, 1]. Multiply by 127 to get the original raw value.

§

MidiProgramChange

A MIDI program change event, available on MidiConfig::MidiCCs and up. VST3 plugins cannot receive these events.

Fields

§timing: u32
§channel: u8

The affected channel, in 0..16.

§program: u8

The program number, in 0..128.

§

MidiSysEx

A MIDI SysEx message supported by the plugin’s SysExMessage type, available on MidiConfig::Basic and up. If the conversion from the raw byte array fails (e.g. the plugin doesn’t support this kind of message), then this will be logged during debug builds of the plugin, and no event is emitted.

Fields

§timing: u32
§message: <P as Plugin>::SysExMessage