瀏覽代碼

tutorial: fix a signedness bug in the sound tutorial.

legacy
Sam Hocevar 5 年之前
父節點
當前提交
70847edb61
共有 1 個檔案被更改,包括 3 行新增3 行删除
  1. +3
    -3
      doc/tutorial/09_sound.cpp

+ 3
- 3
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;
}
}


Loading…
取消
儲存