Skip to content

Commit fb045c1

Browse files
ArthurGibertchmanie
authored andcommitted
fix(faderpunk): fix hanging notes when pausing clock (#448)
1 parent 8da8bb1 commit fb045c1

File tree

5 files changed

+48
-13
lines changed

5 files changed

+48
-13
lines changed

faderpunk/src/apps/clk_div.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,11 @@ pub async fn run(
191191
note_on = false;
192192
jack.set_low().await;
193193
}
194+
ClockEvent::Stop => {
195+
midi.send_note_off(note).await;
196+
note_on = false;
197+
jack.set_low().await;
198+
}
194199
ClockEvent::Tick => {
195200
let muted = glob_muted.get();
196201
let div = div_glob.get();

faderpunk/src/apps/euclid.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,17 @@ pub async fn run(
220220
midi.send_note_off(note).await;
221221
midi.send_note_off(note2).await;
222222
note_on = false;
223+
aux_on = false;
223224
jack[0].set_low().await;
225+
jack[1].set_low().await;
226+
}
227+
ClockEvent::Stop => {
228+
midi.send_note_off(note).await;
229+
midi.send_note_off(note2).await;
230+
note_on = false;
231+
aux_on = false;
232+
jack[0].set_low().await;
233+
jack[1].set_low().await;
224234
}
225235
ClockEvent::Tick => {
226236
let muted = glob_muted.get();

faderpunk/src/apps/notefader.rs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,16 @@ pub async fn run(
233233
clkn = 0;
234234
midi.send_note_off(note).await;
235235
note_on = false;
236+
if outmode == 1 {
237+
jack.set_value(0);
238+
}
239+
}
240+
ClockEvent::Stop => {
241+
midi.send_note_off(note).await;
242+
note_on = false;
243+
if outmode == 1 {
244+
jack.set_value(0);
245+
}
236246
}
237247
ClockEvent::Tick => {
238248
let muted = glob_muted.get();

faderpunk/src/apps/probatrigger.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,11 @@ pub async fn run(
187187
note_on = false;
188188
jack.set_low().await;
189189
}
190+
ClockEvent::Stop => {
191+
midi.send_note_off(note).await;
192+
note_on = false;
193+
jack.set_low().await;
194+
}
190195
ClockEvent::Tick => {
191196
let muted = glob_muted.get();
192197
let val = storage.query(|s| s.prob_saved);

faderpunk/src/apps/seq8.rs

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,12 @@ pub async fn run(
504504
gate_out[n].set_low().await;
505505
}
506506
}
507+
ClockEvent::Stop => {
508+
for n in 0..4 {
509+
midi[n].send_note_off(lastnote[n]).await;
510+
gate_out[n].set_low().await;
511+
}
512+
}
507513
ClockEvent::Tick => {
508514
for n in 0..=3 {
509515
if clockn.is_multiple_of(clockres[n]) {
@@ -520,8 +526,7 @@ pub async fn run(
520526
as u32)
521527
* 410
522528
/ 4095) as u16
523-
+ (storage.query(|s| s.oct_fader[n]) / 1000)
524-
* 410,
529+
+ (storage.query(|s| s.oct_fader[n]) / 1000) * 410,
525530
)
526531
.await;
527532
lastnote[n] = out.as_midi();
@@ -634,23 +639,20 @@ struct AltUpdateContext<'a> {
634639
resolution: &'a [usize; 8],
635640
}
636641

637-
fn apply_alt_update(
638-
chan: usize,
639-
seq_idx: usize,
640-
value: u16,
641-
ctx: &AltUpdateContext,
642-
) {
642+
fn apply_alt_update(chan: usize, seq_idx: usize, value: u16, ctx: &AltUpdateContext) {
643643
match chan {
644644
0 => {
645645
// Sequence length
646-
ctx.storage.modify_and_save(|s| s.length_fader[seq_idx] = value);
646+
ctx.storage
647+
.modify_and_save(|s| s.length_fader[seq_idx] = value);
647648
let mut arr = ctx.seq_length_glob.get();
648649
arr[seq_idx] = (value / 256 + 1) as u8;
649650
ctx.seq_length_glob.set(arr);
650651
}
651652
1 => {
652653
// Gate length
653-
ctx.storage.modify_and_save(|s| s.gate_fader[seq_idx] = value);
654+
ctx.storage
655+
.modify_and_save(|s| s.gate_fader[seq_idx] = value);
654656
let clockres = ctx.clockres_glob.get();
655657
let mut arr = ctx.gatelength_glob.get();
656658
arr[seq_idx] = (clockres[seq_idx] * (value as usize) / 4096) as u8;
@@ -659,15 +661,18 @@ fn apply_alt_update(
659661
}
660662
2 => {
661663
// Octave
662-
ctx.storage.modify_and_save(|s| s.oct_fader[seq_idx] = value);
664+
ctx.storage
665+
.modify_and_save(|s| s.oct_fader[seq_idx] = value);
663666
}
664667
3 => {
665668
// Range
666-
ctx.storage.modify_and_save(|s| s.range_fader[seq_idx] = value);
669+
ctx.storage
670+
.modify_and_save(|s| s.range_fader[seq_idx] = value);
667671
}
668672
4 => {
669673
// Resolution
670-
ctx.storage.modify_and_save(|s| s.res_fader[seq_idx] = value);
674+
ctx.storage
675+
.modify_and_save(|s| s.res_fader[seq_idx] = value);
671676
let res_index = (value / 512) as usize;
672677
let mut arr = ctx.clockres_glob.get();
673678
arr[seq_idx] = ctx.resolution[res_index];

0 commit comments

Comments
 (0)