max v2; #N vpatcher -1 57 1279 819; #P origin 42 0; #P message 959 483 17 196617 0.; #P message 609 488 17 196617 0.; #P message 1049 279 42 196617 store 1; #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; #X append 1 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 78 10. \; 11 282 844 flonum float 37. \; 14 384 571 gain~ list 76 10. \; 15 315 596 flonum float -0.09 \; 17 123 813; #X append 1 2 flonum float 0.49 \; 20 202 844 flonum float 8.699994 \; 21 224 846 flonum float 94. \; 23 488 628 gain~ list 114 10. \; 25 488 652 gain~ list 132 10. \; 26 426 714 flonum float 0.; #X append 1 2 \; 27 441 714 flonum float 0. \; 38 227 207 number int 0 \; 39 245 220 number int 0 \; 40 246 194 toggle int 0 \; 43 68 194 toggle int 0 \; 44 227 246 flonum; #X append 1 2 float 0. \; 55 226 425 number int 0 \; 56 244 438 number int 0 \; 57 245 412 toggle int 1 \; 60 67 412 toggle int 1 \; 61 226 464 flonum float 0. \; 66 375 948; #X append 1 2 gain~ list 85 10. \; 72 273 1203 flonum float 76. \; 75 375 930 gain~ list 91 10. \; 76 306 955 flonum float -0.08 \; 78 114 1172 flonum float 0.46 \; 81 193 1205 flonum float 8.96; #X append 1 2 \; 82 215 1205 flonum float 99. \; 84 479 987 gain~ list 108 10. \; 86 479 1011 gain~ list 129 10. \; 87 417 1073 flonum float 0. \; 88 432 1073 flonum float 0. \;; #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 1205 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 4 696 772 toggle int 1 \; 5 384 589 gain~ list 78 10. \; 11 282 844 flonum float 35.630138 \; 14 384 571 gain~ list 76 10. \; 15 315 596 flonum float -0.09 \; 17 123 813; #X append 1 2 flonum float 0.49 \; 20 202 844 flonum float 8.699994 \; 21 224 846 flonum float 94. \; 23 488 628 gain~ list 114 10. \; 25 488 652 gain~ list 132 10. \; 26 426 714 flonum float 0.; #X append 1 2 \; 27 441 714 flonum float 0. \;; #X append 2 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 85 10. \; 11 282 844 flonum float 64.329987 \; 14 384 571 gain~ list 80 10. \; 15 315 596 flonum float 0.439999 \; 17 123 813; #X append 2 2 flonum float 64. \; 20 202 844 flonum float 209. \; 21 224 846 flonum float 30. \; 23 488 628 gain~ list 112 10. \; 25 488 652 gain~ list 88 10. \; 26 426 714 flonum float 236.; #X append 2 2 \; 27 441 714 flonum float 0.54 \;; #X append 3 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 83 10. \; 11 282 844 flonum float 46. \; 14 384 571 gain~ list 82 10. \; 15 315 596 flonum float 0.729999 \; 17 123 813; #X append 3 2 flonum float 0.14 \; 20 202 844 flonum float 50. \; 21 224 846 flonum float 96. \; 23 488 628 gain~ list 113 10. \; 25 488 652 gain~ list 127 10. \; 26 426 714 flonum float 554.; #X append 3 2 \; 27 441 714 flonum float 0.22 \;; #X append 4 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 85 10. \; 11 282 844 flonum float 85. \; 14 384 571 gain~ list 95 10. \; 15 315 596 flonum float 0.549999 \; 17 123 813; #X append 4 2 flonum float 296.749847 \; 20 202 844 flonum float 507. \; 21 224 846 flonum float 101. \; 23 488 628 gain~ list 86 10. \; 25 488 652 gain~ list 116 10. \; 26 426 714 flonum float 236.; #X append 4 2 \; 27 441 714 flonum float 0.54 \;; #X append 5 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 85 10. \; 11 282 844 flonum float 65.630089 \; 14 384 571 gain~ list 80 10. \; 15 315 596 flonum float 0.309999 \; 17 123 813; #X append 5 2 flonum float 65. \; 20 202 844 flonum float 253. \; 21 224 846 flonum float 0. \; 23 488 628 gain~ list 112 10. \; 25 488 652 gain~ list 113 10. \; 26 426 714 flonum float 236.; #X append 5 2 \; 27 441 714 flonum float 0.54 \;; #X append 6 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 85 10. \; 11 282 844 flonum float 65.630089 \; 14 384 571 gain~ list 80 10. \; 15 315 596 flonum float 0.439999 \; 17 123 813; #X append 6 2 flonum float 64. \; 20 202 844 flonum float 22. \; 21 224 846 flonum float 0. \; 23 488 628 gain~ list 112 10. \; 25 488 652 gain~ list 113 10. \; 26 426 714 flonum float 236.; #X append 6 2 \; 27 441 714 flonum float 0.54 \;; #X append 7 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 85 10. \; 11 282 844 flonum float 25. \; 14 384 571 gain~ list 95 10. \; 15 315 596 flonum float 0.570001 \; 17 123 813; #X append 7 2 flonum float 174. \; 20 202 844 flonum float 356. \; 21 224 846 flonum float 1.449989 \; 23 488 628 gain~ list 0 10. \; 25 488 652 gain~ list 128 10. \; 26 426 714 flonum float 340.; #X append 7 2 \; 27 441 714 flonum float 0.040001 \;; #X append 8 2 4 696 772 toggle int 1 \; 5 384 589 gain~ list 85 10. \; 11 282 844 flonum float 25. \; 14 384 571 gain~ list 95 10. \; 15 315 596 flonum float 0.220001 \; 17 123 813; #X append 8 2 flonum float 100.089943 \; 20 202 844 flonum float 272. \; 21 224 846 flonum float 1. \; 23 488 628 gain~ list 0 10. \; 25 488 652 gain~ list 128 10. \; 26 426 714 flonum float 334.; #X append 8 2 \; 27 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 comment 206 194 35 196617 metro; #P comment 220 209 28 196617 freq; #P comment 246 194 30 196617 gain; #P fasten 45 0 48 0 189 61 92 61 92 36 107 36; #P fasten 48 0 47 0 106 58 141 58 141 29 154 29; #P connect 41 0 35 0; #P connect 35 0 34 0; #P connect 42 0 36 0; #P connect 36 0 34 1; #P connect 37 0 34 2; #P connect 46 0 43 0; #P connect 45 0 43 0; #P connect 43 0 40 0; #P connect 40 0 34 3; #P fasten 47 0 46 0 154 53 174 53 174 35 204 35; #P connect 38 0 34 4; #P connect 39 0 34 5; #P connect 44 0 34 7; #P fasten 62 0 65 0 407 60 310 60 310 35 325 35; #P fasten 65 0 64 0 325 57 359 57 359 28 372 28; #P connect 58 0 52 0; #P connect 52 0 51 0; #P connect 59 0 53 0; #P connect 53 0 51 1; #P connect 54 0 51 2; #P connect 63 0 60 0; #P connect 62 0 60 0; #P connect 60 0 57 0; #P connect 57 0 51 3; #P fasten 64 0 63 0 372 52 392 52 392 34 422 34; #P connect 55 0 51 4; #P connect 56 0 51 5; #P connect 61 0 51 7; #P fasten 7 0 13 0 778 424 656 424 656 306 576 306; #P connect 13 0 14 0; #P connect 12 0 5 0; #P connect 15 0 13 1; #P fasten 93 0 23 0 614 555 603 555 603 482 633 482; #P fasten 14 0 23 0 576 475 633 475; #P fasten 5 0 23 0 594 475 633 475; #P fasten 7 0 12 1 778 423 656 423 656 353 634 353; #P connect 5 0 24 0; #P connect 14 0 24 0; #P fasten 93 0 25 0 614 555 605 555 605 486 657 486; #P connect 24 0 25 0; #P connect 26 0 24 1; #P connect 27 0 24 2; #P connect 16 0 18 0; #P connect 18 0 19 0; #P connect 19 0 6 0; #P connect 9 0 7 0; #P connect 6 0 7 0; #P connect 6 0 8 0; #P connect 8 0 9 0; #P connect 20 0 18 1; #P connect 21 0 19 1; #P connect 17 0 22 0; #P connect 22 0 16 1; #P connect 10 0 8 1; #P connect 23 0 31 0; #P connect 25 0 31 0; #P connect 84 0 31 0; #P connect 86 0 31 0; #P connect 31 0 3 0; #P connect 4 0 3 0; #P fasten 34 0 11 0 161 330 521 330 521 91 849 91; #P connect 11 0 10 0; #P connect 31 0 3 1; #P fasten 68 0 74 0 1137 415 1015 415 1015 297 935 297; #P connect 74 0 75 0; #P connect 73 0 66 0; #P connect 76 0 74 1; #P fasten 94 0 84 0 964 502 951 502 951 475 992 475; #P fasten 75 0 84 0 935 466 992 466; #P fasten 66 0 84 0 953 466 992 466; #P fasten 68 0 73 1 1137 414 1015 414 1015 344 993 344; #P connect 66 0 85 0; #P connect 75 0 85 0; #P fasten 94 0 86 0 964 503 949 503 949 476 1016 476; #P connect 85 0 86 0; #P connect 92 0 89 0; #P connect 87 0 85 1; #P connect 88 0 85 2; #P connect 77 0 79 0; #P connect 79 0 80 0; #P connect 80 0 67 0; #P connect 70 0 68 0; #P connect 67 0 68 0; #P connect 67 0 69 0; #P connect 69 0 70 0; #P connect 81 0 79 1; #P connect 82 0 80 1; #P connect 78 0 83 0; #P connect 83 0 77 1; #P connect 71 0 69 1; #P fasten 51 0 72 0 379 317 557 317 557 59 1208 59; #P connect 72 0 71 0; #P pop;