-
Notifications
You must be signed in to change notification settings - Fork 355
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Signed/unsigned is reversed #39
Comments
How large were the fluctuations in frequency? Around 30-40hz? If they were small fluctuations, they might be because of the phase's resolution (32-bit floating point) changing to a f64 might fix this? As for the signed/unsigned, I'm not sure (don't have time to check atm). |
I don’t know how big the fluctuations are in Hz, but it is all pretty much in the range of one note difference. Thinking about it again, I now know exactly what the problem is: it is indeed a floating-point problem. You get rounding errors, because the accumulator grows very rapidly, so |
This has been fixed in #51. |
I believe signed and unsigned samples are handled in precisely the opposite way of how they should be handled. For instance, the
beep
example produces a very sharp sound, whereas it should produce a sine wave of exactly one frequency, which sounds very soft.On the other hand, I modified the example to produce signed samples instead:
This again produces the sharp sound that sounds like a square wave. When the last two occurences of
i16
are replaced byu16
— effectively rendering a signed sine wave but casting it tou16
— the sound sounds like a sine again. I verified the above code on Windows as well as Linux.On a side note, when I ran the
beep
example on Windows I could sometimes hear large fluctuations in the frequency, even though it should be constant. The frequency would jump abrubtly after a few seconds.The text was updated successfully, but these errors were encountered: