simple explanation please

in Propeller 2
QSIN(length, angle, twopi) : y Rotate (length,0) by (angle / twopi) * 2Pi and return y. Use 0 for twopi = $1_0000_0000. Twopi is unsigned.
QCOS(length, angle, twopi) : x Rotate (length,0) by (angle / twopi) * 2Pi and return x. Use 0 for twopi = $1_0000_0000. Twopi is unsigned.
I was looking at this code so as to attempt to out put three different pulsed sounds that increase and decrease in loudness. Need three different frequencies. Found this code but do not understand the twopi. Can any one reference me to some simple explanations please.
Thank you in advance.
Plus some relatively simple example code with good comments.
Thanks
Comments
Twopi is just the value that represents an entire circumference. If it is 4, then angles 0..3 would be 0, 90, 180, and 270 degrees.
Chip: Its actually a (badly named) function in this case instead of a value (per that PDF). The twopi function uses two sins 90 degrees out of phase in cartesian space to create a circle upon which the graph data is imposed. I think.
Oh, okay. I was just thinking about the QSIN and QCOS methods in Spin2, and their third argument called 'twopi'. I hadn't even looked at the pdf because I didn't think it was necessary.
Here is an example in Spin2 to generate an audio sine frequency:
https://forums.parallax.com/discussion/comment/1496551/#Comment_1496551
You can do this 3 times in the loop to generate 3 frequencies. To modulate the amplitude make the $7FFF a variable and change it from 0 to $7FFF and back to 0 to increase / decrease the loudness.
Andy
The example modified for two frequencies and the amplitude modulated by a triangle waveform:
CON _clkfreq = 180_000_000 smprate = 44100 sinfreq1 = 440 sinfreq2 = 734 dacpin1 = 36 dacpin2 = 37 lforate = 3 VAR long vol, lfo pub sine_out() | smp, phs1, phs2 pinstart(dacpin1, P_DAC_DITHER_RND | P_DAC_600R_2V | P_OE, clkfreq/smprate, 0) 'smartpin DAC 16bits pinstart(dacpin2, P_DAC_DITHER_RND | P_DAC_600R_2V | P_OE, clkfreq/smprate, 0) repeat phs1 += sinfreq1 FRAC smprate 'rotate phase by one step angle for sine freq _,smp := polxy(vol, phs1) 'cordic sine with rotating phase and modulated volume wypin(dacpin1, smp+$8000) 'write sine sample to dac phs2 += sinfreq2 FRAC smprate _,smp := polxy(vol, phs2) 'the same for the second frequency wypin(dacpin2, smp+$8000) repeat until pinread(dacpin1) 'wait for dac sample period lfo := (lfo + lforate) & $FFFF 'low freq. Oscillator (sawtooth) vol := abs(lfo - $8000) 'saw to triangle = up/down ramp
Andy
Just for clarity: the "twopi" variable mentioned in the QSIN and QCOS documentation has nothing at all to do with the "twopi" function described in your linked PDF file. They just happen to share a name.
Thanks to all.
@ersmith
Thanks for the explanation.
@Ariba
I will try your code.
Thanks