diff options
-rw-r--r-- | examples/test.c | 7 |
1 files changed, 6 insertions, 1 deletions
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; } |