From c76dcd182c3d6933d064db4a1eed820fdb09eff7 Mon Sep 17 00:00:00 2001 From: Brian Whitman Date: Thu, 13 Jun 2024 07:51:50 -0400 Subject: [PATCH 1/4] adding amy.millis() that works on computers and tulip --- amy.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/amy.py b/amy.py index 5b60759..2ad54a5 100644 --- a/amy.py +++ b/amy.py @@ -63,6 +63,19 @@ def preset(which,osc=0, **kwargs): send(wave=ALGO, patch=62, filter_freq="125,0,0,4", resonance=2.5, filter_type=FILTER_LPF, bp0="1,1,500,0,0,0") +# Return a millis() epoch number for use in AMY timing +# On most computers, this uses ms since midnight using datetime +# On things like Tulip, this use ms since boot +def millis(): + try: + import datetime + d = datetime.datetime.now() + return int((datetime.datetime.utcnow() - datetime.datetime(d.year, d.month, d.day)).total_seconds()*1000) + except ImportError: + import tulip + return tulip.ticks_ms() + + # Removes trailing 0s and x.0000s from floating point numbers to trim wire message size # Fun historical trivia: this function caused a bug so bad that Dan had to file a week-long PR for micropython # https://github.com/micropython/micropython/pull/8905 From 62d8ee5125221e33dfdadf64d149279f3faa18db Mon Sep 17 00:00:00 2001 From: Dan Ellis Date: Thu, 13 Jun 2024 21:51:15 -0400 Subject: [PATCH 2/4] amy.c: Preserve unset algo_source oscs under voice translation. --- src/amy.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/amy.c b/src/amy.c index 5338971..4297962 100644 --- a/src/amy.c +++ b/src/amy.c @@ -468,7 +468,11 @@ void amy_add_event_internal(struct event e, uint16_t base_osc) { parse_algorithm_source(&t, e.algo_source); for(uint8_t i=0;i Date: Fri, 14 Jun 2024 11:03:53 -0400 Subject: [PATCH 3/4] amy.c: Fix AMY_HPF_OUTPUT for floating point mode. --- src/amy.c | 3 ++- src/amy_config.h | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/amy.c b/src/amy.c index 4297962..ab5a34f 100644 --- a/src/amy.c +++ b/src/amy.c @@ -1336,7 +1336,8 @@ int16_t * amy_fill_buffer() { // some FM patches. b = [1 -1]; a = [1 -0.995] //SAMPLE new_state = fsample + SMULR6(F2S(0.995f), amy_global.hpf_state); // High-output-range, rounded MUL is critical here. #ifdef AMY_HPF_OUTPUT - SAMPLE new_state = fsample + amy_global.hpf_state - SHIFTR(amy_global.hpf_state + (1 << 7), 8); // i.e. 0.9961*hpf_state + SAMPLE new_state = fsample + amy_global.hpf_state + - SHIFTR(amy_global.hpf_state + SHIFTR(F2S(1.0), 16), 8); // i.e. 0.9961*hpf_state fsample = new_state - amy_global.hpf_state; amy_global.hpf_state = new_state; #endif diff --git a/src/amy_config.h b/src/amy_config.h index 574b2f5..33f9c83 100644 --- a/src/amy_config.h +++ b/src/amy_config.h @@ -32,6 +32,8 @@ extern const uint16_t pcm_samples; #define PCM_AMY_SAMPLE_RATE 22050 #define AMY_EVENT_FIFO_LEN 2400 +//#define AMY_HPF_OUTPUT 1 // To remove large DC excursions from some FM voices. + //If using an ESP, tell us how to allocate ram here. Not used on other platforms. #ifdef ESP_PLATFORM #include From 05550c01b3ac449e57f694195500890b6f377baf Mon Sep 17 00:00:00 2001 From: Dan Ellis Date: Fri, 14 Jun 2024 14:00:42 -0400 Subject: [PATCH 4/4] patches.c: Add debug printout. --- src/amy.c | 3 +++ src/amy.h | 1 + src/patches.c | 22 ++++++++++++++++++++++ 3 files changed, 26 insertions(+) diff --git a/src/amy.c b/src/amy.c index ab5a34f..8972d3f 100644 --- a/src/amy.c +++ b/src/amy.c @@ -770,6 +770,9 @@ void show_debug(uint8_t type) { fprintf(stderr,"mod osc %d: amp: %f, logfreq %f duty %f filter_logfreq %f resonance %f fb/bw %f pan %f \n", i, msynth[i].amp, msynth[i].logfreq, msynth[i].duty, msynth[i].filter_logfreq, msynth[i].resonance, msynth[i].feedback, msynth[i].pan); } } + if (type > 4) { + patches_debug(); + } fprintf(stderr, "\n"); } } diff --git a/src/amy.h b/src/amy.h index 1173fe5..e3d5f13 100644 --- a/src/amy.h +++ b/src/amy.h @@ -481,6 +481,7 @@ extern void partials_note_off(uint16_t osc); extern void patches_load_patch(struct event e); extern void patches_event_has_voices(struct event e); extern void patches_reset(); +extern void patches_debug(); extern void patches_store_patch(char * message); extern SAMPLE render_partials(SAMPLE *buf, uint16_t osc); diff --git a/src/patches.c b/src/patches.c index e284fc0..c80d2e1 100644 --- a/src/patches.c +++ b/src/patches.c @@ -26,6 +26,28 @@ uint16_t memory_patch_oscs[MEMORY_PATCHES]; uint8_t osc_to_voice[AMY_OSCS]; uint16_t voice_to_base_osc[MAX_VOICES]; +void patches_debug() { + for(uint8_t v=0;v= AMY_OSCS) break; + fprintf(stderr, "%d ", osc_to_voice[i + j]); + } + i += j; + fprintf(stderr, "\n"); + } + for(uint8_t i=0;i