Guest User

Untitled

a guest
Jun 21st, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. f32 PI = 3.14159265f;
  2. u32 k;
  3. for (k = 0; k < buffer_size/2; k++) {
  4. // sounds[0] is 16-bit signed 48,000Hz PCM
  5. // I want a 220Hz tone. 48,000Hz / 220Hz is roughly 218
  6. // 48,000 samples/s / 218 samples = 220Hz
  7. // 0 to PI/2 -> 1 wavelength. (sin(0) == 0, sin(PI/2) == 0)
  8. // we want 1 wavelength to fit in 218 samples, so
  9. // (PI/2) * (k/218.0f) should do that.... right?
  10. // 16-bit signed samples range from -32768 to 32767 (0x7FFF)
  11. sounds[0][k] = 0x7FFF * sin((PI/2) * (k/218.0f)); // attempting 220Hz sine wave.
  12. }
Add Comment
Please, Sign In to add comment