max v2; #N vpatcher -1 44 1279 806; #P origin 42 0; #P comment 1052 360 42 196617 mo info; #N vpatcher 40 55 609 559; #P comment 213 456 314 196617 a >~ object works quite nicely as a square or pulse wave oscillator.; #P comment 213 182 314 196617 this patch uses a signal-and-hold object (sah~) to generate an offset signal that gets added with the output of the phasor~. when the modulation signal passes through zero in a positive direction \, sah~ samples the value of the ramp \, and holds it constant until the next trigger. the signal is inverted and summed with the ramp. as a result \, the ramp resets to zero at the instantaneous moment that it is sampled by sah~.; #P comment 213 64 313 196617 <-make a zero to one transition with the checkbox to "re-start" the slow phasor~ ramp.; #P comment 213 31 137 196617 oscillator sync; #P comment 213 352 314 196617 the resulting ramp signal can be used to drive anything \, in msp. the typical subject in analog synthesizers is a pulse wave oscillator \, which yields a pretty familiar sound... other types of oscillators \, wavetable lookup synthesis \, and buffer~ scanning are all interesting. as well \, the modulating sync signal does not need to be a stable oscillator - although \, harmonically simple signals often seem to work best. networks of basic oscillator types can be tuned to complex relationships \, that evolve slowly...; #P comment 213 273 314 196617 it is then necessary to wrap~ the value - not only so that it stays within the bounds of 0-1 \, but also so that it remains a continuous ramp \, for the purposes of driving an oscillator or other synchronized process. the integrity of the ramp can be verified by observing the patch at sub-audio rates \, as in the example to the left \, or by displaying high frequency behavior with scope~.; #P comment 213 115 314 196617 the basic idea is to use the output of one oscillator to re-start another - a standard technique on analog synthesizers. in msp \, it is possible to analyze any signal \, in any number of ways \, and use the result to modulate an oscillator - but first we need to figure out how to re-trigger a ramp signal with sample-accurate response.; #P newex 53 235 68 196617 snapshot~ 30; #P toggle 139 65 15 0; #P user number~ 117 181 156 196 9 3 3 2 0. 0. 0 0. 250 0.; #P newex 139 91 39 196617 sig~ 0.; #P newex 90 150 38 196617 *~ -1.; #P newex 90 126 29 196617 sah~; #P newex 53 258 39 196617 * 128.; #P newex 53 209 65 196617 pong~ 1 0. 1.; #P slider 53 291 15 128 0 1; #P newex 53 75 62 196617 phasor~ 0.3; #P comment 51 23 122 196617 this shows how it works \, in slow motion.; #P connect 6 0 3 0; #P connect 1 0 3 0; #P connect 3 0 10 0; #P connect 10 0 4 0; #P connect 4 0 2 0; #P connect 1 0 5 0; #P connect 5 0 6 0; #P connect 7 0 5 1; #P connect 6 0 8 0; #P connect 9 0 7 0; #P pop; #P newobj 1048 374 49 196617 p curious; #N vpreset 8; #P preset 1049 318 47 27; #P flonum 1073 432 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P flonum 1073 417 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P user gain~ 1011 479 24 100 158 0 1.071519 7.94321 10.; #P newex 1011 455 93 196617 lores~ 300. 0.5; #P user gain~ 987 479 24 100 158 0 1.071519 7.94321 10.; #P newex 1172 138 62 196617 phasor~ 0.3; #P flonum 1205 215 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P flonum 1203 193 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P newex 1132 231 27 196617 +~; #P newex 1132 209 27 196617 *~; #P flonum 1172 114 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P newex 1132 184 50 196617 cycle~ 0.; #P flonum 955 306 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P user gain~ 930 375 18 57 158 0 1.071519 7.94321 10.; #P newex 930 330 35 196617 >~ 0.5; #P newex 948 352 50 196617 cycle~ 0.; #P flonum 1203 273 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P newex 1203 296 62 196617 cycle~ 300.; #P newex 1143 358 38 196617 *~ -1.; #P newex 1143 334 41 196617 sah~ 0.; #P newex 1132 388 65 196617 pong~ 1 0. 1.; #P newex 1132 297 62 196617 phasor~ 0.3; #P user gain~ 948 375 18 57 158 0 1.071519 7.94321 10.; #P newex 320 37 40 9109513 del 100; #P button 367 32 15 0; #P message 417 37 14 9109513 0; #P message 402 37 14 9109513 1; #P flonum 464 226 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; #P toggle 412 67 15 0; #P button 386 67 15 0; #P button 373 67 15 0; #P toggle 412 245 15 0; #P number 438 244 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; #P number 425 226 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; #P button 399 245 15 0; #P button 386 245 15 0; #P button 373 245 15 0; #P newex 374 276 170 9109513 wiggleline01; #P comment 334 69 35 196617 all on; #P comment 363 87 37 196617 all off; #P newex 102 38 40 9109513 del 100; #P button 149 33 15 0; #P message 199 38 14 9109513 0; #P message 184 38 14 9109513 1; #P flonum 246 227 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; #P toggle 194 68 15 0; #P button 168 68 15 0; #P button 155 68 15 0; #P toggle 194 246 15 0; #P number 220 245 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; #P number 207 227 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0; #P button 181 246 15 0; #P button 168 246 15 0; #P button 155 246 15 0; #P newex 156 277 170 9109513 wiggleline01; #P comment 116 70 35 196617 all on; #P comment 145 88 37 196617 all off; #P newex 843 702 31 196617 *~ 2; #P comment 693 369 42 196617 mo info; #N vpatcher 40 55 609 559; #P comment 213 456 314 196617 a >~ object works quite nicely as a square or pulse wave oscillator.; #P comment 213 182 314 196617 this patch uses a signal-and-hold object (sah~) to generate an offset signal that gets added with the output of the phasor~. when the modulation signal passes through zero in a positive direction \, sah~ samples the value of the ramp \, and holds it constant until the next trigger. the signal is inverted and summed with the ramp. as a result \, the ramp resets to zero at the instantaneous moment that it is sampled by sah~.; #P comment 213 64 313 196617 <-make a zero to one transition with the checkbox to "re-start" the slow phasor~ ramp.; #P comment 213 31 137 196617 oscillator sync; #P comment 213 352 314 196617 the resulting ramp signal can be used to drive anything \, in msp. the typical subject in analog synthesizers is a pulse wave oscillator \, which yields a pretty familiar sound... other types of oscillators \, wavetable lookup synthesis \, and buffer~ scanning are all interesting. as well \, the modulating sync signal does not need to be a stable oscillator - although \, harmonically simple signals often seem to work best. networks of basic oscillator types can be tuned to complex relationships \, that evolve slowly...; #P comment 213 273 314 196617 it is then necessary to wrap~ the value - not only so that it stays within the bounds of 0-1 \, but also so that it remains a continuous ramp \, for the purposes of driving an oscillator or other synchronized process. the integrity of the ramp can be verified by observing the patch at sub-audio rates \, as in the example to the left \, or by displaying high frequency behavior with scope~.; #P comment 213 115 314 196617 the basic idea is to use the output of one oscillator to re-start another - a standard technique on analog synthesizers. in msp \, it is possible to analyze any signal \, in any number of ways \, and use the result to modulate an oscillator - but first we need to figure out how to re-trigger a ramp signal with sample-accurate response.; #P newex 53 235 68 196617 snapshot~ 30; #P toggle 139 65 15 0; #P user number~ 117 181 156 196 9 3 3 2 0. 0. 0 0. 250 0.; #P newex 139 91 39 196617 sig~ 0.; #P newex 90 150 38 196617 *~ -1.; #P newex 90 126 29 196617 sah~; #P newex 53 258 39 196617 * 128.; #P newex 53 209 65 196617 pong~ 1 0. 1.; #P slider 53 291 15 128 0 1; #P newex 53 75 62 196617 phasor~ 0.3; #P comment 51 23 122 196617 this shows how it works \, in slow motion.; #P connect 6 0 3 0; #P connect 1 0 3 0; #P connect 3 0 10 0; #P connect 10 0 4 0; #P connect 4 0 2 0; #P connect 1 0 5 0; #P connect 5 0 6 0; #P connect 7 0 5 1; #P connect 6 0 8 0; #P connect 9 0 7 0; #P pop; #P newobj 689 383 49 196617 p curious; #N vpreset 8; #X append 1 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 78 10. \; 8 282 844 flonum float 35.630138 \; 11 384 571 gain~ list 76 10. \; 12 315 596 flonum float -0.09 \; -1 315 596; #X append 1 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 0.49 \; 17 202 844 flonum float 8.699994 \; 18 224 846 flonum float 94. \; 20 488 628 gain~ list 114 10. \;; #X append 1 2 22 488 652 gain~ list 132 10. \; 23 426 714 flonum float 0. \; 24 441 714 flonum float 0. \;; #X append 2 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 85 10. \; 8 282 844 flonum float 64.329987 \; 11 384 571 gain~ list 80 10. \; 12 315 596 flonum float 0.439999 \; -1 315 596; #X append 2 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 64. \; 17 202 844 flonum float 209. \; 18 224 846 flonum float 30. \; 20 488 628 gain~ list 112 10. \;; #X append 2 2 22 488 652 gain~ list 88 10. \; 23 426 714 flonum float 236. \; 24 441 714 flonum float 0.54 \;; #X append 3 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 83 10. \; 8 282 844 flonum float 46. \; 11 384 571 gain~ list 82 10. \; 12 315 596 flonum float 0.729999 \; -1 315 596; #X append 3 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 0.14 \; 17 202 844 flonum float 50. \; 18 224 846 flonum float 96. \; 20 488 628 gain~ list 113 10. \;; #X append 3 2 22 488 652 gain~ list 127 10. \; 23 426 714 flonum float 554. \; 24 441 714 flonum float 0.22 \;; #X append 4 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 85 10. \; 8 282 844 flonum float 85. \; 11 384 571 gain~ list 95 10. \; 12 315 596 flonum float 0.549999 \; -1 315 596; #X append 4 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 296.749847 \; 17 202 844 flonum float 507. \; 18 224 846 flonum float 101. \; 20 488 628 gain~ list 86 10. \;; #X append 4 2 22 488 652 gain~ list 116 10. \; 23 426 714 flonum float 236. \; 24 441 714 flonum float 0.54 \;; #X append 5 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 85 10. \; 8 282 844 flonum float 65.630089 \; 11 384 571 gain~ list 80 10. \; 12 315 596 flonum float 0.309999 \; -1 315 596; #X append 5 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 65. \; 17 202 844 flonum float 253. \; 18 224 846 flonum float 0. \; 20 488 628 gain~ list 112 10. \;; #X append 5 2 22 488 652 gain~ list 113 10. \; 23 426 714 flonum float 236. \; 24 441 714 flonum float 0.54 \;; #X append 6 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 85 10. \; 8 282 844 flonum float 65.630089 \; 11 384 571 gain~ list 80 10. \; 12 315 596 flonum float 0.439999 \; -1 315 596; #X append 6 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 64. \; 17 202 844 flonum float 22. \; 18 224 846 flonum float 0. \; 20 488 628 gain~ list 112 10. \;; #X append 6 2 22 488 652 gain~ list 113 10. \; 23 426 714 flonum float 236. \; 24 441 714 flonum float 0.54 \;; #X append 7 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 85 10. \; 8 282 844 flonum float 25. \; 11 384 571 gain~ list 95 10. \; 12 315 596 flonum float 0.570001 \; -1 315 596; #X append 7 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 174. \; 17 202 844 flonum float 356. \; 18 224 846 flonum float 1.449989 \; 20 488 628 gain~ list 0 10. \;; #X append 7 2 22 488 652 gain~ list 128 10. \; 23 426 714 flonum float 340. \; 24 441 714 flonum float 0.040001 \;; #X append 8 2 1 696 772 toggle int 1 \; 2 384 589 gain~ list 85 10. \; 8 282 844 flonum float 25. \; 11 384 571 gain~ list 95 10. \; 12 315 596 flonum float 0.220001 \; -1 315 596; #X append 8 2 number int 84 \; -1 315 596 number int 16 \; 14 123 813 flonum float 100.089943 \; 17 202 844 flonum float 272. \; 18 224 846 flonum float 1. \; 20 488 628 gain~ list 0 10. \;; #X append 8 2 22 488 652 gain~ list 128 10. \; 23 426 714 flonum float 334. \; 24 441 714 flonum float 0.220001 \;; #P preset 690 327 47 27; #P flonum 714 441 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P flonum 714 426 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P user gain~ 652 488 24 100 158 0 1.071519 7.94321 10.; #P newex 652 464 93 196617 lores~ 300. 0.5; #P user gain~ 628 488 24 100 158 0 1.071519 7.94321 10.; #P newex 813 147 62 196617 phasor~ 0.3; #P flonum 846 224 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P flonum 844 202 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P newex 773 240 27 196617 +~; #P newex 773 218 27 196617 *~; #P flonum 813 123 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P newex 773 193 50 196617 cycle~ 0.; #P flonum 596 315 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P user gain~ 571 384 18 57 158 0 1.071519 7.94321 10.; #P newex 571 339 35 196617 >~ 0.5; #P newex 589 361 50 196617 cycle~ 0.; #P flonum 844 282 50 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0; #P newex 844 305 62 196617 cycle~ 300.; #P newex 784 367 38 196617 *~ -1.; #P newex 784 343 41 196617 sah~ 0.; #P newex 773 397 65 196617 pong~ 1 0. 1.; #P newex 773 306 62 196617 phasor~ 0.3; #P user gain~ 589 384 18 57 158 0 1.071519 7.94321 10.; #P toggle 772 696 40 0; #P newex 843 722 45 196617 dac~; #P fasten 42 0 45 0 189 61 92 61 92 36 107 36; #P fasten 45 0 44 0 106 58 141 58 141 29 154 29; #P connect 38 0 32 0; #P connect 32 0 31 0; #P connect 39 0 33 0; #P connect 33 0 31 1; #P connect 34 0 31 2; #P connect 42 0 40 0; #P connect 43 0 40 0; #P connect 40 0 37 0; #P connect 37 0 31 3; #P fasten 44 0 43 0 154 53 174 53 174 35 204 35; #P connect 35 0 31 4; #P connect 36 0 31 5; #P connect 41 0 31 7; #P fasten 59 0 62 0 407 60 310 60 310 35 325 35; #P fasten 62 0 61 0 325 57 359 57 359 28 372 28; #P connect 55 0 49 0; #P connect 49 0 48 0; #P connect 56 0 50 0; #P connect 50 0 48 1; #P connect 51 0 48 2; #P connect 59 0 57 0; #P connect 60 0 57 0; #P connect 57 0 54 0; #P connect 54 0 48 3; #P fasten 61 0 60 0 372 52 392 52 392 34 422 34; #P connect 52 0 48 4; #P connect 53 0 48 5; #P connect 58 0 48 7; #P fasten 4 0 10 0 778 424 656 424 656 306 576 306; #P connect 10 0 11 0; #P connect 9 0 2 0; #P connect 12 0 10 1; #P fasten 11 0 20 0 576 475 633 475; #P fasten 2 0 20 0 594 475 633 475; #P fasten 4 0 9 1 778 423 656 423 656 353 634 353; #P connect 11 0 21 0; #P connect 2 0 21 0; #P connect 21 0 22 0; #P connect 23 0 21 1; #P connect 24 0 21 2; #P connect 13 0 15 0; #P connect 15 0 16 0; #P connect 16 0 3 0; #P connect 3 0 4 0; #P connect 6 0 4 0; #P connect 3 0 5 0; #P connect 5 0 6 0; #P connect 17 0 15 1; #P connect 18 0 16 1; #P connect 14 0 19 0; #P connect 19 0 13 1; #P connect 7 0 5 1; #P connect 83 0 28 0; #P connect 81 0 28 0; #P connect 22 0 28 0; #P connect 20 0 28 0; #P connect 28 0 0 0; #P connect 1 0 0 0; #P fasten 31 0 8 0 161 330 521 330 521 91 849 91; #P connect 8 0 7 0; #P connect 28 0 0 1; #P fasten 65 0 71 0 1137 415 1015 415 1015 297 935 297; #P connect 71 0 72 0; #P connect 70 0 63 0; #P connect 73 0 71 1; #P fasten 72 0 81 0 935 466 992 466; #P fasten 63 0 81 0 953 466 992 466; #P fasten 65 0 70 1 1137 414 1015 414 1015 344 993 344; #P connect 72 0 82 0; #P connect 63 0 82 0; #P connect 82 0 83 0; #P connect 84 0 82 1; #P connect 85 0 82 2; #P connect 74 0 76 0; #P connect 76 0 77 0; #P connect 77 0 64 0; #P connect 64 0 65 0; #P connect 67 0 65 0; #P connect 64 0 66 0; #P connect 66 0 67 0; #P connect 78 0 76 1; #P connect 79 0 77 1; #P connect 75 0 80 0; #P connect 80 0 74 1; #P connect 68 0 66 1; #P fasten 48 0 69 0 379 317 557 317 557 59 1208 59; #P connect 69 0 68 0; #P pop;