Skip to content

Commit

Permalink
fw: pitch shifting works e2e polyvec :)
Browse files Browse the repository at this point in the history
  • Loading branch information
vk2seb committed Dec 13, 2023
1 parent f0e1c38 commit 1691bb5
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
6 changes: 3 additions & 3 deletions firmware/polyvec-lib/src/voice.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pub struct Voice {
pub note: u8,
pub start_time_ms: u32,
pub state: VoiceState,
pub pitch: i16,
pub pitch: f32,
pub amplitude: f32,
pub velocity: u8,
pub adsr: Option<AdsrParams>,
Expand Down Expand Up @@ -75,9 +75,9 @@ impl VoiceManager {
}
}

pub fn note_to_pitch(note: u8) -> i16 {
pub fn note_to_pitch(note: u8) -> f32 {
let scale = 2.0f32.powf(((note as i16) - 60) as f32 / 12.0f32);
((1.0f32 - scale) * 32768.0f32) as i16
1.0f32 - scale
}


Expand Down
6 changes: 1 addition & 5 deletions firmware/polyvec/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ impl State {
}
} else {
*/
/*
let pmod1 = &peripherals.EURORACK_PMOD1;
let pmod2 = &peripherals.EURORACK_PMOD2;
let pmod3 = &peripherals.EURORACK_PMOD3;
Expand Down Expand Up @@ -302,8 +301,7 @@ impl State {
let mut update_hw_voice = |n_voice: usize, midi_note: u8, touch_raw: u8| {
let ampl = (touch_raw as f32) / 256.0f32;
let pitch = note_to_pitch(midi_note);
//shifter[n_voice].set_pitch(pitch);
shifter[n_voice].set_pitch(FixedI32::<U16>::from_num(0.0f32));
shifter[n_voice].set_pitch(FixedI32::<U16>::from_num(pitch));

// Low-pass filter to smooth touch on/off
let ampl_old: f32 = lpf[n_voice].cutoff().to_num();
Expand Down Expand Up @@ -353,8 +351,6 @@ impl State {
update_hw_voice(n_voice, voices_old[n_voice].note, 0);
}
}
*/
/*
}
*/
Expand Down

0 comments on commit 1691bb5

Please sign in to comment.