Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f32 PI = 3.14159265f;
- u32 k;
- for (k = 0; k < buffer_size/2; k++) {
- // sounds[0] is 16-bit signed 48,000Hz PCM
- // I want a 220Hz tone. 48,000Hz / 220Hz is roughly 218
- // 48,000 samples/s / 218 samples = 220Hz
- // 0 to PI/2 -> 1 wavelength. (sin(0) == 0, sin(PI/2) == 0)
- // we want 1 wavelength to fit in 218 samples, so
- // (PI/2) * (k/218.0f) should do that.... right?
- // 16-bit signed samples range from -32768 to 32767 (0x7FFF)
- sounds[0][k] = 0x7FFF * sin((PI/2) * (k/218.0f)); // attempting 220Hz sine wave.
- }
Add Comment
Please, Sign In to add comment