Define constants for VST3 note expression types
This commit is contained in:
parent
83f9ce3608
commit
3361c4454b
|
@ -12,6 +12,19 @@ type NoteId = i32;
|
||||||
/// The number of notes we'll keep track of for mapping note IDs to channel+note combinations.
|
/// The number of notes we'll keep track of for mapping note IDs to channel+note combinations.
|
||||||
const NOTE_IDS_LEN: usize = 32;
|
const NOTE_IDS_LEN: usize = 32;
|
||||||
|
|
||||||
|
/// `kVolumeTypeID`
|
||||||
|
pub const VOLUME_EXPRESSION_ID: u32 = 0;
|
||||||
|
/// `kPanTypeId`
|
||||||
|
pub const PAN_EXPRESSION_ID: u32 = 1;
|
||||||
|
/// `kTuningTypeID`
|
||||||
|
pub const TUNING_EXPRESSION_ID: u32 = 2;
|
||||||
|
/// `kVibratoTypeID`
|
||||||
|
pub const VIBRATO_EXPRESSION_ID: u32 = 3;
|
||||||
|
/// `kExpressionTypeID`
|
||||||
|
pub const EXPRESSION_EXPRESSION_ID: u32 = 4;
|
||||||
|
/// `kBrightnessTypeID`
|
||||||
|
pub const BRIGHTNESS_EXPRESSION_ID: u32 = 5;
|
||||||
|
|
||||||
/// VST3 has predefined note expressions just like CLAP, but unlike the other note events these
|
/// VST3 has predefined note expressions just like CLAP, but unlike the other note events these
|
||||||
/// expressions are identified only with a note ID. To account for that, we'll keep track of the
|
/// expressions are identified only with a note ID. To account for that, we'll keep track of the
|
||||||
/// most recent note IDs we've encountered so we can later map those IDs back to a note and channel
|
/// most recent note IDs we've encountered so we can later map those IDs back to a note and channel
|
||||||
|
@ -48,8 +61,7 @@ impl NoteExpressionController {
|
||||||
.find(|(note_id, _, _)| *note_id == event.note_id)?;
|
.find(|(note_id, _, _)| *note_id == event.note_id)?;
|
||||||
|
|
||||||
match event.type_id {
|
match event.type_id {
|
||||||
// kVolumeTypeID
|
VOLUME_EXPRESSION_ID => Some(NoteEvent::PolyVolume {
|
||||||
0 => Some(NoteEvent::PolyVolume {
|
|
||||||
timing,
|
timing,
|
||||||
channel,
|
channel,
|
||||||
note,
|
note,
|
||||||
|
@ -57,16 +69,14 @@ impl NoteExpressionController {
|
||||||
// 4x scaling factor here to allow the values to go from -infinity to +12 dB
|
// 4x scaling factor here to allow the values to go from -infinity to +12 dB
|
||||||
gain: event.value as f32 * 4.0,
|
gain: event.value as f32 * 4.0,
|
||||||
}),
|
}),
|
||||||
// kPanTypeId
|
PAN_EXPRESSION_ID => Some(NoteEvent::PolyPan {
|
||||||
1 => Some(NoteEvent::PolyPan {
|
|
||||||
timing,
|
timing,
|
||||||
channel,
|
channel,
|
||||||
note,
|
note,
|
||||||
// Our panning expressions are symmetrical around 0
|
// Our panning expressions are symmetrical around 0
|
||||||
pan: (event.value as f32 * 2.0) - 1.0,
|
pan: (event.value as f32 * 2.0) - 1.0,
|
||||||
}),
|
}),
|
||||||
// kTuningTypeID
|
TUNING_EXPRESSION_ID => Some(NoteEvent::PolyTuning {
|
||||||
2 => Some(NoteEvent::PolyTuning {
|
|
||||||
timing,
|
timing,
|
||||||
channel,
|
channel,
|
||||||
note,
|
note,
|
||||||
|
@ -74,22 +84,19 @@ impl NoteExpressionController {
|
||||||
// events
|
// events
|
||||||
tuning: 240.0 * (event.value as f32 - 0.5),
|
tuning: 240.0 * (event.value as f32 - 0.5),
|
||||||
}),
|
}),
|
||||||
// kVibratoTypeID
|
VIBRATO_EXPRESSION_ID => Some(NoteEvent::PolyVibrato {
|
||||||
3 => Some(NoteEvent::PolyVibrato {
|
|
||||||
timing,
|
timing,
|
||||||
channel,
|
channel,
|
||||||
note,
|
note,
|
||||||
vibrato: event.value as f32,
|
vibrato: event.value as f32,
|
||||||
}),
|
}),
|
||||||
// kExpressionTypeID
|
EXPRESSION_EXPRESSION_ID => Some(NoteEvent::PolyBrightness {
|
||||||
4 => Some(NoteEvent::PolyBrightness {
|
|
||||||
timing,
|
timing,
|
||||||
channel,
|
channel,
|
||||||
note,
|
note,
|
||||||
brightness: event.value as f32,
|
brightness: event.value as f32,
|
||||||
}),
|
}),
|
||||||
// kBrightnessTypeID
|
BRIGHTNESS_EXPRESSION_ID => Some(NoteEvent::PolyExpression {
|
||||||
5 => Some(NoteEvent::PolyExpression {
|
|
||||||
timing,
|
timing,
|
||||||
channel,
|
channel,
|
||||||
note,
|
note,
|
||||||
|
@ -108,32 +115,32 @@ impl NoteExpressionController {
|
||||||
) -> Option<NoteExpressionValueEvent> {
|
) -> Option<NoteExpressionValueEvent> {
|
||||||
match &event {
|
match &event {
|
||||||
NoteEvent::PolyVolume { gain, .. } => Some(NoteExpressionValueEvent {
|
NoteEvent::PolyVolume { gain, .. } => Some(NoteExpressionValueEvent {
|
||||||
type_id: 0, // kVolumeTypeID
|
type_id: VOLUME_EXPRESSION_ID,
|
||||||
note_id,
|
note_id,
|
||||||
value: *gain as f64 / 4.0,
|
value: *gain as f64 / 4.0,
|
||||||
}),
|
}),
|
||||||
NoteEvent::PolyPan { pan, .. } => Some(NoteExpressionValueEvent {
|
NoteEvent::PolyPan { pan, .. } => Some(NoteExpressionValueEvent {
|
||||||
type_id: 1, // kPanTypeId
|
type_id: PAN_EXPRESSION_ID,
|
||||||
note_id,
|
note_id,
|
||||||
value: (*pan as f64 + 1.0) / 2.0,
|
value: (*pan as f64 + 1.0) / 2.0,
|
||||||
}),
|
}),
|
||||||
NoteEvent::PolyTuning { tuning, .. } => Some(NoteExpressionValueEvent {
|
NoteEvent::PolyTuning { tuning, .. } => Some(NoteExpressionValueEvent {
|
||||||
type_id: 2, // kTuningTypeID
|
type_id: TUNING_EXPRESSION_ID,
|
||||||
note_id,
|
note_id,
|
||||||
value: (*tuning as f64 / 240.0) + 0.5,
|
value: (*tuning as f64 / 240.0) + 0.5,
|
||||||
}),
|
}),
|
||||||
NoteEvent::PolyVibrato { vibrato, .. } => Some(NoteExpressionValueEvent {
|
NoteEvent::PolyVibrato { vibrato, .. } => Some(NoteExpressionValueEvent {
|
||||||
type_id: 3, // kVibratoTypeID
|
type_id: VIBRATO_EXPRESSION_ID,
|
||||||
note_id,
|
note_id,
|
||||||
value: *vibrato as f64,
|
value: *vibrato as f64,
|
||||||
}),
|
}),
|
||||||
NoteEvent::PolyExpression { expression, .. } => Some(NoteExpressionValueEvent {
|
NoteEvent::PolyExpression { expression, .. } => Some(NoteExpressionValueEvent {
|
||||||
type_id: 4, // kExpressionTypeID
|
type_id: EXPRESSION_EXPRESSION_ID,
|
||||||
note_id,
|
note_id,
|
||||||
value: *expression as f64,
|
value: *expression as f64,
|
||||||
}),
|
}),
|
||||||
NoteEvent::PolyBrightness { brightness, .. } => Some(NoteExpressionValueEvent {
|
NoteEvent::PolyBrightness { brightness, .. } => Some(NoteExpressionValueEvent {
|
||||||
type_id: 5, // kBrightnessTypeID
|
type_id: BRIGHTNESS_EXPRESSION_ID,
|
||||||
note_id,
|
note_id,
|
||||||
value: *brightness as f64,
|
value: *brightness as f64,
|
||||||
}),
|
}),
|
||||||
|
|
Loading…
Reference in a new issue