1
0
Fork 0

Store velocity as a float

Instead of converting this to a 0-127 value. We may be throwing away
precision otherwise.
This commit is contained in:
Robbert van der Helm 2022-04-07 20:12:30 +02:00
parent 5b03ae8d0e
commit 8f359feadb
3 changed files with 16 additions and 6 deletions

View file

@ -311,17 +311,27 @@ pub enum ProcessStatus {
/// TODO: Add more events as needed
#[derive(Debug, Copy, Clone, PartialEq, Eq)]
pub enum NoteEvent {
/// A note on event.
NoteOn {
timing: u32,
/// The note's channel, from 0 to 16.
channel: u8,
/// The note's MIDI key number, from 0 to 127.
note: u8,
velocity: u8,
/// The note's velocity, from 0 to 1. Some plugin APIs may allow higher precision than the
/// 127 levels available in MIDI.
velocity: f32,
},
/// A note off event.
NoteOff {
timing: u32,
/// The note's channel, from 0 to 16.
channel: u8,
/// The note's MIDI key number, from 0 to 127.
note: u8,
velocity: u8,
/// The note's velocity, from 0 to 1. Some plugin APIs may allow higher precision than the
/// 127 levels available in MIDI.
velocity: f32,
},
}

View file

@ -875,7 +875,7 @@ impl<P: ClapPlugin> Wrapper<P> {
timing: raw_event.time - current_sample_idx as u32,
channel: event.channel as u8,
note: event.key as u8,
velocity: (event.velocity * 127.0).round() as u8,
velocity: event.velocity as f32,
});
}
@ -888,7 +888,7 @@ impl<P: ClapPlugin> Wrapper<P> {
timing: raw_event.time - current_sample_idx as u32,
channel: event.channel as u8,
note: event.key as u8,
velocity: (event.velocity * 127.0).round() as u8,
velocity: event.velocity as f32,
});
}

View file

@ -770,7 +770,7 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
timing,
channel: event.channel as u8,
note: event.pitch as u8,
velocity: (event.velocity * 127.0).round() as u8,
velocity: event.velocity,
});
} else if event.type_ == vst3_sys::vst::EventTypes::kNoteOffEvent as u16
{
@ -779,7 +779,7 @@ impl<P: Vst3Plugin> IAudioProcessor for Wrapper<P> {
timing,
channel: event.channel as u8,
note: event.pitch as u8,
velocity: (event.velocity * 127.0).round() as u8,
velocity: event.velocity,
});
}
}