MAKING BASIC WAVEFORMS FROM A [phasor~]
**************************************
[phasor~] is just a recurring ramp from 0 to 1...a basic sawtooth wave.
so, if you just imagine counting from 0 to 1, in small increments, that's what [phasor~] does. 0, 0.001, 0.002, and so on, all the way up to 1, and then it drops straight back to zero.
Now, the interesting part, is that if you have this type of recurring line from 0 to 1, then you can shape it to do all sorts of things. For example, you might say, that when the values are below 0.5, then the output wave should be -1... and then when the values are equal to or above 0.5, then the output wave should be +1. Here's one way to do that:
[phasor~]
|
[expr~ $v1>0.5]
|
[*~ 2]
|
[-~ 1]
now, how that works, is that you have you 0->1 ramp from the [phasor~], going into the expression [expr~ $v1>0.5]. If your signal is above 0.5, it will output 'true' (which has a signal value of 1) or 'false' (which has a signal value of 0). So, with every cycle of the original [phasor~], you now have an alternating 0/1 signal with 50% duty (it's 0 half the time, and 1 half the time). To make that into a proper synth waveform, you just have to do the remaining basic arithmetic of [*~ 2] and [-~ 1] to get it into the -1 to 1 range that audio waveforms should oscillate between.
ok, lets next make a synth sawtooth wave. That's even easier, because the [phasor~] already outputs that exact waveform, but just needs scaling. So it's the same as the squarewave construction, but without the [expr~] bit, ie:
[phasor~]
|
[*~ 2]
|
[-~ 1]
ok, what else do you need for classic synth waves: PWM wave is always popular.
Let's go back to our square wave, and make one small modification:
[phasor~] [r pulsewidth]
| |
[expr~ $v1>$f2]
|
[*~ 2]
|
[-~ 1]
Now, what you have is a variable number instead of the 0.5 that you had for the basic squarewave. If you set this number very very small, say 0.01, then you'll only get a very short pulse width. And if you set it at 0.5, then you get the full-width squarewave. The part where i have put [r pulsewidth] could be used to receive whatever controller you desire for your PWM. it might just be a simple slider set between 0.01 and 0.5 (log scale would be best), or else you could even start bringing in envelope or lfo control or whatever once you get the hang of patching a bit more.
finally, for the moment, there is one more important waveform you can make easily with a [phasor~] - the sine wave (or actually, in pd's case, a cosine wave...but basically the same).
the construction is really simple:
[phasor~]
|
[cos~]
now every cycle of the [phasor~] will be converted mathematically into a single cycle of cosine wave, oscillating between -1 and 1, like a good audio signal should.
Sine waves by themselves are pretty useless for subtractive synthesis, cos they don't have any overtones/partials or whatever, but you can do interesting things such as modulating their frequency (fm synthesis) to make them come alive. They are also very useful at low frequency for making LFO's and things like that.
so, those are some basic waveforms. You can look up the pd documentation for an example of a triangle wave, and then there are all sorts of other waveforms you can start generating. But building with a [phasor~] as the base, and then shaping that signal, is a very powerful and commonly used way to generate waveforms in PD.