summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorXANTRONIX Development2022-01-31 22:30:19 -0500
committerXANTRONIX Development2022-01-31 22:30:19 -0500
commitfbfa7294cbdff0dd49a768fffbcba1d1721786a6 (patch)
tree3d25348efcec505d4c48fe7c11c62aeb68321b02 /examples
parent71226d22f2d92c53a35f395b04807c761f1e564a (diff)
downloadxas-fbfa7294cbdff0dd49a768fffbcba1d1721786a6.tar.gz
xas-fbfa7294cbdff0dd49a768fffbcba1d1721786a6.tar.bz2
xas-fbfa7294cbdff0dd49a768fffbcba1d1721786a6.zip
this is sensible
Diffstat (limited to 'examples')
-rw-r--r--examples/test.c7
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;
}