From 445050f6ad1603bbd778f29be7b5503c2a455873 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Sun, 27 Feb 2022 22:05:59 -0500 Subject: Fix square wave duty cycle to 50% --- src/synth.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/synth.c b/src/synth.c index 082a383..86990e8 100644 --- a/src/synth.c +++ b/src/synth.c @@ -28,7 +28,9 @@ static int16_t sample_square(xas_synth *synth) { static float tau = 2.0f * M_PI; if (synth->state == XAS_SYNTH_ACTIVE) { - ret = synth->phase > 0.0? INT16_MAX / 4: INT16_MIN / 4; + ret = (synth->phase - M_PI) > 0.0? + INT16_MAX / 4: + INT16_MIN / 4; synth->phase += tau / (synth->format.sample_rate / synth->frequency); -- cgit v1.2.3