From ba45cfe089c6430ab80bc8652dc88a837a59fc9a Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Tue, 8 Mar 2022 20:28:13 -0500 Subject: Fix duty cycle term in square wave synthesis --- src/synth.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/synth.c b/src/synth.c index 0be572d..9c974e5 100644 --- a/src/synth.c +++ b/src/synth.c @@ -30,7 +30,7 @@ static int16_t sample_square(xas_synth *synth) { float duty = synth->duty; if (synth->state == XAS_SYNTH_ACTIVE) { - ret = ((duty * synth->phase) - M_PI) > 0.0? + ret = (synth->phase - (duty * tau)) > 0.0? (int16_t)roundf(synth->gain * (INT16_MAX / 4)): (int16_t)roundf(synth->gain * (INT16_MIN / 4)); -- cgit v1.2.3