[PD] help making a square wave?

Frank Barknecht fbar at footils.org
Fri Mar 7 19:38:15 CET 2003


Hallo,
David Merrill hat gesagt: // David Merrill wrote:
> I've been trying to make a square wave, but my pd knowledge is a little 
> rusty.  I know of osc~ and phasor~ for a cosine and sawtooth wave, 
> respectively, but I haven't been able to find a square-wave generator.  I 
> think I ought to be able to use an osc, and just output 1 when the output 
> is positive, and -1 when it's negative, but I've become hung on the 
> details.  Is the following a good overview of what needs to be done?
> 
> osc~ -> snapshot~ -> moses 0 -> b (one for each moses output) -> -1.0 or 
> 1.0 -> sig~
> 
> It seems like using snapshot to turn every sample into a number so that 
> moses can divide them around 0 is inefficient.  Is there an object that 
> deals with signals that can do what moses does?  (Or just a better way to 
> get a variable-frequency square-wave in general?)

There are severaly ways. Attached is a non-antialiased version with
pulse modulation (PM on hardware synths)

ciao
-- 
 Frank Barknecht                               _ ______footils.org__
-------------- next part --------------
#N canvas 281 247 669 318 10;
#X obj 49 166 tabwrite~ snd;
#N canvas 0 0 450 300 graph1 0;
#X array snd 1000 float 0;
#X coords 0 1 999 -1 200 140 1;
#X restore 435 20 graph;
#X msg 50 59 \; pd dsp \$1;
#X obj 50 31 tgl 24 0 empty empty Click_here! 0 -6 0 8 -262144 -1 -1
0 1;
#X floatatom 179 61 5 0 0 0 - - -;
#X obj 179 120 squareosc~ 440;
#X obj 49 121 metro 500;
#X obj 225 45 vsl 15 64 0 1 0 0 empty empty PulseMod_0-1 0 -8 0 8 -262144
-1 -1 0 1;
#X msg 309 26 0.5;
#X obj 174 274 dac~;
#X obj 202 173 vsl 15 64 0 1 0 0 empty empty Volume 0 -8 0 8 -262144
-1 -1 0 1;
#X obj 179 245 *~ 0;
#X obj 179 89 mtof;
#X msg 388 201 1000;
#X msg 425 201 100;
#X msg 388 227 \; snd resize \$1;
#X connect 3 0 2 0;
#X connect 3 0 6 0;
#X connect 4 0 12 0;
#X connect 5 0 0 0;
#X connect 5 0 11 0;
#X connect 6 0 0 0;
#X connect 7 0 5 1;
#X connect 8 0 7 0;
#X connect 10 0 11 1;
#X connect 11 0 9 0;
#X connect 11 0 9 1;
#X connect 12 0 5 0;
#X connect 13 0 15 0;
#X connect 14 0 15 0;
-------------- next part --------------
#N canvas 452 390 450 300 10;
#X obj 163 192 -~;
#X obj 163 118 -~ 0.5;
#X obj 179 146 wrap~;
#X obj 179 169 -~ 0.5;
#X obj 163 93 phasor~ \$1;
#X obj 163 223 outlet~;
#X obj 228 36 inlet;
#X obj 163 36 inlet;
#X obj 200 9 inlet;
#X connect 0 0 5 0;
#X connect 1 0 0 0;
#X connect 1 0 2 0;
#X connect 2 0 3 0;
#X connect 3 0 0 1;
#X connect 4 0 1 0;
#X connect 6 0 4 1;
#X connect 7 0 4 0;
#X connect 8 0 1 1;


More information about the Pd-list mailing list