From a3ef6e6661ceb23647ee03d1799f488af04f18ff Mon Sep 17 00:00:00 2001 From: Dan Ellis Date: Sat, 7 Sep 2024 23:19:59 -0400 Subject: [PATCH 1/2] src/pcm.c: PCM_INDEX_BITS, not FRAC_BITS, when warping to end in note_off. --- src/pcm.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/pcm.c b/src/pcm.c index 2ca013c..5ca9d66 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -17,7 +17,7 @@ void pcm_init() { void pcm_note_on(uint16_t osc) { //printf("pcm_note_on: osc=%d patch=%d logfreq=%f amp=%f\n", - // osc, synth[osc].patch, synth[osc].logfreq, synth[osc].amp); + // osc, synth[osc].patch, synth[osc].logfreq_coefs[0], synth[osc].amp_coefs[0]); if(synth[osc].patch >= pcm_samples) synth[osc].patch = 0; // if no freq given, just play it at midinote if(synth[osc].logfreq_coefs[COEF_CONST] <= 0) { @@ -34,9 +34,11 @@ void pcm_mod_trigger(uint16_t osc) { } void pcm_note_off(uint16_t osc) { + //printf("pcm_note_off: osc=%d feedback=%f phase=%f\n", + // osc, synth[osc].feedback, P2F(synth[osc].phase)); if(msynth[osc].feedback == 0) { // Non-looping note: Set phase to the end to cause immediate stop. - synth[osc].phase = F2P(pcm_map[synth[osc].patch].length / (float)(1 << PCM_INDEX_FRAC_BITS)); + synth[osc].phase = F2P(pcm_map[synth[osc].patch].length / (float)(1 << PCM_INDEX_BITS)); } else { // Looping is requested, disable future looping, sample will play through to end. // (sending a second note-off will stop it immediately). From 4b9d398fbe76f91606b06cfc94cb756fb90dcfca Mon Sep 17 00:00:00 2001 From: Dan Ellis Date: Sat, 7 Sep 2024 23:27:51 -0400 Subject: [PATCH 2/2] src/pcm.c: Actually fix it this time. --- src/pcm.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/pcm.c b/src/pcm.c index 5ca9d66..f1698b5 100644 --- a/src/pcm.c +++ b/src/pcm.c @@ -17,7 +17,7 @@ void pcm_init() { void pcm_note_on(uint16_t osc) { //printf("pcm_note_on: osc=%d patch=%d logfreq=%f amp=%f\n", - // osc, synth[osc].patch, synth[osc].logfreq_coefs[0], synth[osc].amp_coefs[0]); + // osc, synth[osc].patch, synth[osc].logfreq, synth[osc].amp); if(synth[osc].patch >= pcm_samples) synth[osc].patch = 0; // if no freq given, just play it at midinote if(synth[osc].logfreq_coefs[COEF_CONST] <= 0) { @@ -34,8 +34,6 @@ void pcm_mod_trigger(uint16_t osc) { } void pcm_note_off(uint16_t osc) { - //printf("pcm_note_off: osc=%d feedback=%f phase=%f\n", - // osc, synth[osc].feedback, P2F(synth[osc].phase)); if(msynth[osc].feedback == 0) { // Non-looping note: Set phase to the end to cause immediate stop. synth[osc].phase = F2P(pcm_map[synth[osc].patch].length / (float)(1 << PCM_INDEX_BITS));