How to peek~ a sinewave into buffer~ for waveshaping

I suck at math, so an easy solution where I understand what is going on would be great. Im using uzi to pack an index number together with 0 – 511 "converted" to a sine wave for the lookup~. If I use some math object? (cos?) for the values (the second integer in the list)

edit: scaling 0 511 to 0.1 made a sinewave in the buffer~, but I dont have a clue whats going on really…

this patch will make it a bit clearer.
the [sin] object works with radians, so you need to give it values from 0 to 2*PI (6.283) to get one period of a sinewave.

[uzi]‘s count will start from 1. So you subtract 1 and divide by the number of samples in the buffer.
Note, that this will give you a range from 0 to 0.9999, not reaching 1.
This is fine, because you don’t want _both_ the first and last sample in the buffer to be 0.

Then simply multiply by 2*PI and you’re done.

– Pasted Max Patch, click to expand. –

Copy all of the following text. Then, in Max, select New From Clipboard.