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.
|
||||
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
|
||||
/// 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
|
||||
|
@ -48,8 +61,7 @@ impl NoteExpressionController {
|
|||
.find(|(note_id, _, _)| *note_id == event.note_id)?;
|
||||
|
||||
match event.type_id {
|
||||
// kVolumeTypeID
|
||||
0 => Some(NoteEvent::PolyVolume {
|
||||
VOLUME_EXPRESSION_ID => Some(NoteEvent::PolyVolume {
|
||||
timing,
|
||||
channel,
|
||||
note,
|
||||
|
@ -57,16 +69,14 @@ impl NoteExpressionController {
|
|||
// 4x scaling factor here to allow the values to go from -infinity to +12 dB
|
||||
gain: event.value as f32 * 4.0,
|
||||
}),
|
||||
// kPanTypeId
|
||||
1 => Some(NoteEvent::PolyPan {
|
||||
PAN_EXPRESSION_ID => Some(NoteEvent::PolyPan {
|
||||
timing,
|
||||
channel,
|
||||
note,
|
||||
// Our panning expressions are symmetrical around 0
|
||||
pan: (event.value as f32 * 2.0) - 1.0,
|
||||
}),
|
||||
// kTuningTypeID
|
||||
2 => Some(NoteEvent::PolyTuning {
|
||||
TUNING_EXPRESSION_ID => Some(NoteEvent::PolyTuning {
|
||||
timing,
|
||||
channel,
|
||||
note,
|
||||
|
@ -74,22 +84,19 @@ impl NoteExpressionController {
|
|||
// events
|
||||
tuning: 240.0 * (event.value as f32 - 0.5),
|
||||
}),
|
||||
// kVibratoTypeID
|
||||
3 => Some(NoteEvent::PolyVibrato {
|
||||
VIBRATO_EXPRESSION_ID => Some(NoteEvent::PolyVibrato {
|
||||
timing,
|
||||
channel,
|
||||
note,
|
||||
vibrato: event.value as f32,
|
||||
}),
|
||||
// kExpressionTypeID
|
||||
4 => Some(NoteEvent::PolyBrightness {
|
||||
EXPRESSION_EXPRESSION_ID => Some(NoteEvent::PolyBrightness {
|
||||
timing,
|
||||
channel,
|
||||
note,
|
||||
brightness: event.value as f32,
|
||||
}),
|
||||
// kBrightnessTypeID
|
||||
5 => Some(NoteEvent::PolyExpression {
|
||||
BRIGHTNESS_EXPRESSION_ID => Some(NoteEvent::PolyExpression {
|
||||
timing,
|
||||
channel,
|
||||
note,
|
||||
|
@ -108,32 +115,32 @@ impl NoteExpressionController {
|
|||
) -> Option<NoteExpressionValueEvent> {
|
||||
match &event {
|
||||
NoteEvent::PolyVolume { gain, .. } => Some(NoteExpressionValueEvent {
|
||||
type_id: 0, // kVolumeTypeID
|
||||
type_id: VOLUME_EXPRESSION_ID,
|
||||
note_id,
|
||||
value: *gain as f64 / 4.0,
|
||||
}),
|
||||
NoteEvent::PolyPan { pan, .. } => Some(NoteExpressionValueEvent {
|
||||
type_id: 1, // kPanTypeId
|
||||
type_id: PAN_EXPRESSION_ID,
|
||||
note_id,
|
||||
value: (*pan as f64 + 1.0) / 2.0,
|
||||
}),
|
||||
NoteEvent::PolyTuning { tuning, .. } => Some(NoteExpressionValueEvent {
|
||||
type_id: 2, // kTuningTypeID
|
||||
type_id: TUNING_EXPRESSION_ID,
|
||||
note_id,
|
||||
value: (*tuning as f64 / 240.0) + 0.5,
|
||||
}),
|
||||
NoteEvent::PolyVibrato { vibrato, .. } => Some(NoteExpressionValueEvent {
|
||||
type_id: 3, // kVibratoTypeID
|
||||
type_id: VIBRATO_EXPRESSION_ID,
|
||||
note_id,
|
||||
value: *vibrato as f64,
|
||||
}),
|
||||
NoteEvent::PolyExpression { expression, .. } => Some(NoteExpressionValueEvent {
|
||||
type_id: 4, // kExpressionTypeID
|
||||
type_id: EXPRESSION_EXPRESSION_ID,
|
||||
note_id,
|
||||
value: *expression as f64,
|
||||
}),
|
||||
NoteEvent::PolyBrightness { brightness, .. } => Some(NoteExpressionValueEvent {
|
||||
type_id: 5, // kBrightnessTypeID
|
||||
type_id: BRIGHTNESS_EXPRESSION_ID,
|
||||
note_id,
|
||||
value: *brightness as f64,
|
||||
}),
|
||||
|
|
Loading…
Reference in a new issue