From fbfa7294cbdff0dd49a768fffbcba1d1721786a6 Mon Sep 17 00:00:00 2001 From: XANTRONIX Development Date: Mon, 31 Jan 2022 22:30:19 -0500 Subject: this is sensible --- examples/test.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/test.c b/examples/test.c index d03b8b2..36ba034 100644 --- a/examples/test.c +++ b/examples/test.c @@ -40,11 +40,16 @@ static void usage(int argc, char **argv, const char *message, ...) { static int16_t sine_sample(xas_synth *synth, synth_sine *sine) { int16_t ret; + static float tau = 2.0f * M_PI; if (sine->flags & SYNTH_STATUS_ON) { ret = (int16_t)roundf((INT16_MAX >> 2) * sinf(sine->phase)); - sine->phase += (2.0f * M_PI) / (synth->sample_rate / sine->frequency); + sine->phase += tau / (synth->sample_rate / sine->frequency); + + if (sine->phase > tau) { + sine->phase -= tau; + } } else { ret = 0; } -- cgit v1.2.3