summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorXANTRONIX Development2022-03-08 20:28:13 -0500
committerXANTRONIX Development2022-03-08 20:28:13 -0500
commitba45cfe089c6430ab80bc8652dc88a837a59fc9a (patch)
treedcb64a3528eef8ff50bcba19d1dc425b9efbe925
parent60241cb0856bc7deafb052c0665de91878153de4 (diff)
downloadxas-ba45cfe089c6430ab80bc8652dc88a837a59fc9a.tar.gz
xas-ba45cfe089c6430ab80bc8652dc88a837a59fc9a.tar.bz2
xas-ba45cfe089c6430ab80bc8652dc88a837a59fc9a.zip
Fix duty cycle term in square wave synthesis
-rw-r--r--src/synth.c2
1 files changed, 1 insertions, 1 deletions
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));