feat: improve velocity curves

velocity now has a steeper downwards curve.
this should make the keys feel heavier
This commit is contained in:
dogeystamp 2024-10-13 22:48:09 -04:00
parent 700bfcb4fd
commit 10fd3bae41
Signed by: dogeystamp
GPG Key ID: 7225FE3592EFFA38
4 changed files with 6 additions and 6 deletions

2
Cargo.lock generated
View File

@ -772,7 +772,7 @@ dependencies = [
[[package]]
name = "geode_piano"
version = "0.2.0"
version = "0.2.1"
dependencies = [
"byte-slice-cast 1.2.2",
"cortex-m",

View File

@ -1,6 +1,6 @@
[package]
name = "geode_piano"
version = "0.2.0"
version = "0.2.1"
edition = "2021"
license = "GPL-3.0-only"

View File

@ -115,10 +115,10 @@ impl<const N_ROWS: usize, const N_COLS: usize> KeyMatrix<N_ROWS, N_COLS> {
// millisecond duration of keypress
let dur =
note_first[note as usize].unwrap().elapsed().as_millis();
let velocity: u8 = if dur <= 80 {
(127 - dur) as u8
let velocity: u8 = if dur <= 60 {
(127 - dur * 6 / 5) as u8
} else {
(127 - min(dur, 250) / 5 - 70) as u8
(127 - min(dur, 240) / 4 - 60) as u8
};
defmt::debug!("{} velocity {} from dur {}ms", note, velocity, dur);
note_on[note as usize] = true;

View File

@ -50,7 +50,7 @@ pub async fn usb_task(
let mut config = Config::new(0xdead, 0xbeef);
config.manufacturer = Some("dogeystamp");
config.product = Some("Geode-Piano MIDI keyboard");
config.serial_number = Some("0.2.0");
config.serial_number = Some("0.2.1");
config.max_power = 100;
config.max_packet_size_0 = 64;