Sine wave integer number generator, how???
Hello everyone. I need to generate numbers in the interval 0 to 255 in a sine wave oscillation, where I can adjust the frequency of the sine wave, so in effect "converting" a sine wave to integers in the interval. However, also avoiding using audio devices, so without using cycle~ or similar ~ devices.
Can anyone help please? I'm desperate as it's for a uni project to be presented in 3 days and I'm stuck!
[toggle]
[ metro 2000.]
[ t b 0. ] . . . . . . . . . .(0. into line, b into list)
[ list 1. 2000. ]
[ line 10. ]
[ * 6.238185 ]
[ cos ]
[ / 2. ]
[ + 0.5 ]
[ * 255. ]
[ + 0.5 ]
[i ]
and next time eventually start earlier?
if you use Roman's solution you should be prepared to be able to explain the reasoning of the patch to your teacher, ie :
what is the [t] object for? why do you add 0.5 and then put it through an [i] box at the end there? What do the /2. and + 0.5 operations achieve? And how is the frequency adjusted?
You should be able to figure out the answer those questions over the next 3 days for yourself.
[110.phasor 2000.]
[epxr int((((cos($f1*6.238185)/2)+0.5)*$f2)+0.5)]
^^ ^^ ^^