There is a way to generate sounds according to an algorithm. It's very weird, but interesting. At the link below you can take a look at the principle with a little example (beware! the sound is too loud). I have no clue what it means. Is there a way to know what this algo generates as chars?
A sound is just a pressure wave (through the air). You create one by telling the speaker how to push (or pull) the air by energizing an electro magnet attached to the back of the speaker membrane.
This translates to an electrical signal. For the simplest (i.e. old PC speaker noise) that is just an on/off switch.
The frequency of the sound changes its pitch — the note you hear. For example, a wave that oscillates at roughly 440 hz — that is, 440 times on and off per second — is A4, the Stuttgart tuning note. https://en.wikipedia.org/wiki/A440_(pitch_standard)
It’s really closer to A-sharp, but meh, whatever, right?
That equation you see is an interval for time measured in seconds. You see that by playing with it in weird ways (using bit shifts and bit masks) you can get a weird little tune.
Hello. I could not answer because of a bug on the forum, but thank you for your comment. Just another question. A bitwise left or right has a logical limit. I saw in the previous example >> 10, but after 8 I restart the loop no? Why they use a number which is more than the number of the bits?
The behavior is undefined if the right operand is negative, or greater than or equal to the width of the promoted left operand. https://eel.is/c++draft/expr.shift#1
> Why they use a number which is more than the number of the bits?
Yes, but I am working on a C++ class which does the work.
It works as expected (funny), but in order to develop some readable algorithm I have to understand all these operands. Thank you for your explanations ++