summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorXANTRONIX Development2022-02-27 22:05:59 -0500
committerXANTRONIX Development2022-02-27 22:05:59 -0500
commit445050f6ad1603bbd778f29be7b5503c2a455873 (patch)
tree63639e44a865c173418e0952518cd113be0b2004 /src
parent04c034b4fd722e4003b36c963533854a4654da1f (diff)
downloadxas-445050f6ad1603bbd778f29be7b5503c2a455873.tar.gz
xas-445050f6ad1603bbd778f29be7b5503c2a455873.tar.bz2
xas-445050f6ad1603bbd778f29be7b5503c2a455873.zip
Fix square wave duty cycle to 50%
Diffstat (limited to 'src')
-rw-r--r--src/synth.c4
1 files changed, 3 insertions, 1 deletions
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);