diff options
author | XANTRONIX Development | 2022-02-27 22:05:59 -0500 |
---|---|---|
committer | XANTRONIX Development | 2022-02-27 22:05:59 -0500 |
commit | 445050f6ad1603bbd778f29be7b5503c2a455873 (patch) | |
tree | 63639e44a865c173418e0952518cd113be0b2004 | |
parent | 04c034b4fd722e4003b36c963533854a4654da1f (diff) | |
download | xas-445050f6ad1603bbd778f29be7b5503c2a455873.tar.gz xas-445050f6ad1603bbd778f29be7b5503c2a455873.tar.bz2 xas-445050f6ad1603bbd778f29be7b5503c2a455873.zip |
Fix square wave duty cycle to 50%
-rw-r--r-- | src/synth.c | 4 |
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); |