From 70847edb61d362fcf394c21ef689f04f9b28778f Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Fri, 15 Mar 2019 13:20:46 +0100 Subject: [PATCH] tutorial: fix a signedness bug in the sound tutorial. --- doc/tutorial/09_sound.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/tutorial/09_sound.cpp b/doc/tutorial/09_sound.cpp index 4eb59de3..ac113115 100644 --- a/doc/tutorial/09_sound.cpp +++ b/doc/tutorial/09_sound.cpp @@ -41,16 +41,16 @@ public: void synth(int mode, void *buf, int bytes) { - uint16_t *stream = (uint16_t *)buf; + int16_t *stream = (int16_t *)buf; for (int i = 0; i < bytes / 2; ++i) { switch (mode) { case 0: // sine wave - stream[i] = 400 * lol::sin(8 * i * F_TAU / bytes); + stream[i] = lol::sin(4 * i * F_TAU / bytes) > 0 ? 800 : -800; break; case 1: // white noise - stream[i] = lol::rand(-120, 120); + stream[i] = lol::rand(-200, 200); break; } }