DSPark 1.9.0
Header-only C++20 DSP for real-time and offline audio
Loading...
Searching...
No Matches
dspark::plugin::MidiEvent Struct Reference

One incoming MIDI-ish event, normalised across formats. More...

#include <DSParkPlugin.h>

Public Types

enum class  Type : uint8_t {
  NoteOn , NoteOff , PitchBend , ControlChange ,
  ChannelPressure , PolyPressure , NoteExpression , NoteModulation
}
 
enum class  ExpressionType : uint8_t {
  Volume , Pan , Tuning , Vibrato ,
  Expression , Brightness , Pressure
}
 The per-voice expressions of Type::NoteExpression. More...
 

Public Attributes

Type type = Type::NoteOn
 
uint8_t channel = 0
 0..15.
 
uint8_t note = 0
 Key 0..127, or controller number for CC.
 
float value = 0.0f
 Velocity / CC / pressure 0..1; bend -1..+1.
 
int sampleOffset = 0
 Frames into the NEXT processBlock call.
 
bool choke = false
 NoteOff only: end the voice now, no release.
 
ExpressionType expression = ExpressionType::Volume
 NoteExpression only.
 
int16_t param = -1
 NoteModulation only: the parameter index.
 
int32_t noteId = -1
 Host voice id of the note (-1: none given).
 

Detailed Description

One incoming MIDI-ish event, normalised across formats.

VST3 delivers notes as native events and pitch bend / CC / pressure through its controller-mapping scheme; CLAP delivers note events plus raw MIDI; AU delivers raw MIDI bytes or, from hosts that send event lists, MIDI 2.0 messages (16-bit velocity, 32-bit controllers and bend, kept at that resolution in value). The wrapper translates ALL of them into this one struct so the plugin handles a single vocabulary.

sampleOffset is the event's position in frames RELATIVE TO THE NEXT processBlock call: events are always delivered (in time order) right before the block that contains them. A simple plugin may ignore the offset (worst error: one automation quantum); a sample-accurate synth starts its voice exactly sampleOffset frames into the block.

A NoteOff with choke set asks for the voice to stop at once, with no release phase (a CLAP NOTE_CHOKE, sent by hosts for choke groups such as an open hi-hat cut by a closed one). It is still a NoteOff, so a plugin that never reads the flag releases the voice exactly as before.

Two event types address ONE voice, by its channel, key and noteId (the id the host gave the voice's NoteOn, -1 when it gave none): the wrapper resolves the host's wildcards (every voice of a key, of a channel, of the port) against the voices it delivered, so the plugin always sees an exact voice.

  • NoteExpression: a per-voice expression, expression (an ExpressionType) says which and value carries it - Volume a linear gain 0..4, Pan 0..1 (0.5 centre), Tuning semitones -120..+120, the others 0..1. A statement of value, not an increment; a voice starts from its neutral value (gain 1, pan 0.5, tuning 0) until one arrives. CLAP hosts send every type; VST3 hosts send the ones the class declares (see HasNoteExpressions).
  • NoteModulation: the value one voice hears for a perVoice() parameter, in PLAIN units, clamped and snapped like any value: the voice's own value when the host automates the parameter per note (else the parameter's value), plus the host's modulation of this voice (else the global modulation setParameter carries). Delivered again whenever a value that reaches the voice moves. param is the parameter index. Comes from CLAP hosts. Ignore the types you do not use (a default: in the switch keeps working as types are added).

Definition at line 633 of file DSParkPlugin.h.

Member Enumeration Documentation

◆ ExpressionType

enum class dspark::plugin::MidiEvent::ExpressionType : uint8_t
strong

The per-voice expressions of Type::NoteExpression.

Enumerator
Volume 

Linear gain 0..4 (1 = unchanged).

Pan 

0 left, 0.5 centre, 1 right.

Tuning 

Semitones, -120..+120.

Vibrato 

0..1.

Expression 

0..1 (a generic per-note intensity).

Brightness 

0..1.

Pressure 

0..1.

Definition at line 648 of file DSParkPlugin.h.

◆ Type

enum class dspark::plugin::MidiEvent::Type : uint8_t
strong
Enumerator
NoteOn 

note = key, value = velocity 0..1.

NoteOff 

note = key, value = release velocity 0..1.

PitchBend 

value = bend -1..+1 (note unused).

ControlChange 

note = controller number, value = 0..1.

ChannelPressure 

value = pressure 0..1 (note unused).

PolyPressure 

note = key, value = pressure 0..1.

NoteExpression 

One voice: expression, value (see above).

NoteModulation 

One voice: parameters[param] heard, plain units.

Definition at line 635 of file DSParkPlugin.h.

Member Data Documentation

◆ channel

uint8_t dspark::plugin::MidiEvent::channel = 0

0..15.

Definition at line 660 of file DSParkPlugin.h.

◆ choke

bool dspark::plugin::MidiEvent::choke = false

NoteOff only: end the voice now, no release.

Definition at line 664 of file DSParkPlugin.h.

◆ expression

ExpressionType dspark::plugin::MidiEvent::expression = ExpressionType::Volume

NoteExpression only.

Definition at line 665 of file DSParkPlugin.h.

◆ note

uint8_t dspark::plugin::MidiEvent::note = 0

Key 0..127, or controller number for CC.

Definition at line 661 of file DSParkPlugin.h.

◆ noteId

int32_t dspark::plugin::MidiEvent::noteId = -1

Host voice id of the note (-1: none given).

Definition at line 667 of file DSParkPlugin.h.

◆ param

int16_t dspark::plugin::MidiEvent::param = -1

NoteModulation only: the parameter index.

Definition at line 666 of file DSParkPlugin.h.

◆ sampleOffset

int dspark::plugin::MidiEvent::sampleOffset = 0

Frames into the NEXT processBlock call.

Definition at line 663 of file DSParkPlugin.h.

◆ type

Type dspark::plugin::MidiEvent::type = Type::NoteOn

Definition at line 659 of file DSParkPlugin.h.

◆ value

float dspark::plugin::MidiEvent::value = 0.0f

Velocity / CC / pressure 0..1; bend -1..+1.

Definition at line 662 of file DSParkPlugin.h.


The documentation for this struct was generated from the following file: