From b46f9864e7bf94d6c5f2eb37e5478455753560e5 Mon Sep 17 00:00:00 2001 From: Stuart Longland Date: Sun, 23 May 2021 10:22:16 +1000 Subject: [PATCH] attiny861: Port to new API --- ports/attiny861/main.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/ports/attiny861/main.c b/ports/attiny861/main.c index 109826f..06ec70a 100644 --- a/ports/attiny861/main.c +++ b/ports/attiny861/main.c @@ -62,6 +62,20 @@ static volatile uint16_t amp_powerdown = 0; /*! Number of I/O channels */ #define CHANNELS (8) +/*! + * Voice definitions for all the channels. + */ +const struct adsr_env_def_t voice_def = { + .time_scale = 100, + .delay_time = 0, + .attack_time = 10, + .decay_time = 10, + .sustain_time = ADSR_INFINITE, + .release_time = 10, + .peak_amp = 255, + .sustain_amp = 192 +}; + /*! * I/O channel frequencies, note frequencies * from http://www.phy.mtu.edu/~suits/notefreqs.html @@ -101,9 +115,7 @@ static void trigger_button(uint8_t b) { if (voice) { uint16_t freq = pgm_read_dword(&button_freq[b]); - adsr_config(&voice->adsr, - 100, 0, 10, 10, - ADSR_INFINITE, 10, 255, 192); + adsr_config(&voice->adsr, &voice_def); voice_wf_set_triangle(&voice->wf, freq, 127); synth.enable |= (1 << b);