sync'ing cycle~ input into poke~ (sah~?)

Dec 11, 2007 at 10:50pm

sync'ing cycle~ input into poke~ (sah~?)

Hello all,

Attached is a patch that feeds a damped sinusoid (cycle~ scaled by phasor~) via poke~ into a buffer~. I’ve been trying to make it so whenever the specification for number of periods to enter into the buffer~ changes, the input starts at a zero point. There’s an sah~ in the patch that should help with this, but doesn’t, and I think the same kind of problem occurs when cycle~’s frequency is changed. So I’m stuck with a buffer~ that’s out of phase (which creates problems on playback with wave~).

I could try, for instance, taking the output from phasor~ and putting it into the control inlet of [sah~ 0.] above, but of course that creates a signal loop and nothing happens.

I’d be grateful for your input, and sorry if I’ve overlooked something obvious!

Inouk

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P comment 181 27 58 9109513 # of periods;
#P number 259 101 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 182 148 28 9109513 sig~;
#P newex 182 183 39 9109513 sah~ 0.;
#P number 665 73 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 665 92 45 9109513 delay $1;
#N vpreset 1;
#X append 1 2 7 155 447 flonum float 0.4 ; 14 128 182 flonum float 1.25 ; 23 61 497 flonum float 46. ; 25 45 182 number int 8 ; 26 64 40 number int 10 ; 28 131 326 flonum float;
#X append 1 2 18. ; 30 136 715 number int 524 ; 32 59 580 flonum float 1. ; 37 73 665 number int 10 ; 40 101 259 number int 512 ;;
#P preset 282 282 47 27;
#P newex 580 108 50 9109513 pack 0. 0.;
#P newex 580 83 27 9109513 !- 0.;
#P flonum 580 59 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P message 580 131 57 9109513 range $1 $2;
#P number 715 136 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P user scope~ 580 157 725 291 2 3 256 -1. 1. 0 10. 0 0. 75 133 255 0 0 0 0;
#P flonum 326 131 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 182 67 27 9109513 t b f;
#P number 40 64 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P number 182 45 35 9 1 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 182 103 27 9109513 / 1.;
#P flonum 497 61 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 497 81 41 9109513 phasor~;
#P newex 497 105 58 9109513 wave~ grain;
#P newex 40 327 31 9109513 abs~;
#P newex 213 295 38 9109513 *~ 512.;
#P message 311 154 37 9109513 size $1;
#P newex 259 130 62 9109513 sampstoms~;
#P newex 182 269 29 9109513 +~ 1.;
#P newex 182 242 31 9109513 *~ -1.;
#P flonum 182 128 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 39 351 358 9109513 poke~ grain;
#P newex 40 301 27 9109513 *~;
#P newex 311 179 93 9109513 buffer~ grain 200;
#P newex 40 103 49 9109513 cycle~ 10;
#P newex 182 208 47 9109513 phasor~;
#P message 465 205 68 9109513 startwindow;
#P flonum 447 155 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 430 177 27 9109513 *~;
#P user ezdac~ 430 235 474 268 0;
#P window linecount 2;
#P comment 326 98 68 9109513 or length in ms (independent);
#P window linecount 1;
#P comment 40 44 25 9109513 freq;
#P comment 103 210 73 9109513 damps sinusoid;
#P comment 258 81 62 9109513 buffer length;
#P comment 496 40 55 9109513 wave~ freq;
#P connect 20 0 13 0;
#P connect 26 0 10 0;
#P connect 10 0 12 0;
#P connect 12 0 20 0;
#P fasten 16 0 12 1 187 293 62 293;
#P connect 25 0 27 0;
#P fasten 26 0 24 0 45 91 187 91;
#P connect 27 0 24 0;
#P connect 24 0 14 0;
#P connect 14 0 39 0;
#P connect 39 0 38 0;
#P connect 38 0 9 0;
#P connect 9 0 15 0;
#P connect 15 0 16 0;
#P connect 27 1 24 1;
#P fasten 10 0 38 1 45 174 216 174;
#P fasten 9 0 19 0 187 233 218 233;
#P connect 19 0 13 1;
#P fasten 40 0 19 1 264 124 246 124;
#P connect 40 0 17 0;
#P connect 17 1 18 0;
#P connect 28 0 18 0;
#P connect 18 0 11 0;
#P fasten 21 0 6 0 502 134 435 134;
#P connect 6 0 5 0;
#P fasten 8 0 5 0 470 228 435 228;
#P connect 7 0 6 1;
#P connect 23 0 22 0;
#P connect 22 0 21 0;
#P connect 32 0 33 0;
#P connect 33 0 34 0;
#P connect 34 0 31 0;
#P fasten 21 0 29 0 502 152 585 152;
#P fasten 36 0 29 0 670 153 585 153;
#P connect 31 0 29 0;
#P fasten 32 0 34 1 585 77 625 77;
#P connect 37 0 36 0;
#P connect 30 0 29 1;
#P window clipboard copycount 42;

#34985
Dec 12, 2007 at 4:47am

You could do it like this, you don’t have to use count~ I never used it before so it’s a little exercise for me.

#P window setfont “Sans Serif” 9.;
#P window linecount 1;
#P message 333 316 50 196617 set grain;
#P user waveform~ 333 340 315 107 3 9;
#W mode select;
#W mouseoutput continuous;
#W unit ms;
#W grid 1000.;
#W ticks 0;
#W labels 1;
#W vlabels 0;
#W vticks 1;
#W bpm 120. 4.;
#W frgb 33 0 0;
#W brgb 60 178 173;
#W rgb2 0 95 255;
#W rgb3 0 0 0;
#W rgb4 0 0 0;
#W rgb5 190 137 255;
#W rgb6 100 100 100;
#W rgb7 100 100 100;
#P hidden button 324 86 15 0;
#P message 78 41 29 196617 stop;
#P newex 250 130 35 196617 * 0.5;
#P number 250 111 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 250 165 49 196617 !/ 1000.;
#P newex 129 325 52 196617 /~ 1000.;
#P newex 129 300 54 196617 !-~ 1000.;
#P newex 146 160 46 196617 +~ 0.25;
#P button 146 24 15 0;
#P newex 146 137 46 196617 /~ 100.;
#P newex 146 52 40 196617 count~;
#P comment 236 92 72 196617 # of periods;
#P number 326 168 48 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P flonum 393 198 35 9 0 0 0 3 0 0 0 221 221 221 222 222 222 0 0 0;
#P newex 107 394 31 196617 abs~;
#P message 378 221 51 196617 size $1;
#P newex 326 197 62 196617 sampstoms~;
#P newex 106 418 181 196617 poke~ grain;
#P newex 107 368 32 196617 *~ 1;
#P newex 378 246 93 196617 buffer~ grain 200;
#P newex 107 189 49 196617 cycle~ 0;
#P window linecount 2;
#P comment 395 169 82 196617 or length in ms (independent);
#P window linecount 1;
#P comment 317 153 76 196617 buffer length;
#P comment 163 25 66 196617 Start me up!;
#P fasten 11 0 18 1 331 192 272 192 272 319 176 319;
#P fasten 11 0 17 1 331 191 178 191;
#P fasten 11 0 13 1 331 188 318 188 318 48 181 48;
#P fasten 11 0 19 1 331 187 305 187 305 161 294 161;
#P hidden connect 11 0 23 0;
#P connect 11 0 7 0;
#P connect 15 0 13 0;
#P fasten 15 0 25 0 151 40 508 40 508 296 338 296;
#P connect 25 0 24 0;
#P connect 9 0 6 0;
#P connect 10 0 8 0;
#P connect 8 0 4 0;
#P connect 7 1 8 0;
#P connect 5 0 9 0;
#P connect 3 0 5 0;
#P connect 16 0 3 1;
#P connect 17 0 18 0;
#P connect 18 0 5 1;
#P connect 14 0 16 0;
#P connect 20 0 21 0;
#P fasten 13 0 6 1 151 109 196 109;
#P connect 13 0 14 0;
#P fasten 13 0 17 0 151 99 228 99 228 291 134 291;
#P fasten 22 0 13 0 83 64 115 64 115 48 151 48;
#P fasten 19 0 14 1 255 186 220 186 220 122 187 122;
#P connect 21 0 19 0;
#P hidden connect 23 0 20 0;
#P window clipboard copycount 26;

#118736
Dec 12, 2007 at 5:51am

P.S. I just noticed that some of the envelopes were not ending exactly on 0.

Adding one sample to the buffer length (before sampstoms~) will solve this problem.

I’d be interested to see what you do with the patch.

Best,

John.

#118737
Dec 12, 2007 at 6:54am

Hi, It looks to me as if you are trying to do somethin glike FOF synthesis?
Dampened sines

1. If so you may benefit from using the hard sync example in the examples
folder

2. Also There is a nice fof generator in the FTM library which is free and
the IRCAN object (not so free)

There is also a very good tutorial in the PD examples which shows how to
update the parameters at zero crossings. This might help with changing the
sine frequency.

P

On 11/12/2007, Inouk Demers wrote:
>
>
> Hello all,
>
> Attached is a patch that feeds a damped sinusoid (cycle~ scaled by
> phasor~) via poke~ into a buffer~. I’ve been trying to make it so whenever
> the specification for number of periods to enter into the buffer~ changes,
> the input starts at a zero point. There’s an sah~ in the patch that should
> help with this, but doesn’t, and I think the same kind of problem occurs
> when cycle~’s frequency is changed. So I’m stuck with a buffer~ that’s out
> of phase (which creates problems on playback with wave~).
>
> I could try, for instance, taking the output from phasor~ and putting it
> into the control inlet of [sah~ 0.] above, but of course that creates a
> signal loop and nothing happens.
>
> I’d be grateful for your input, and sorry if I’ve overlooked something
> obvious!
>
> Inouk
>
> #P window setfont “Sans Serif” 9.;
> #P window linecount 1;
> #P comment 181 27 58 9109513 # of periods;
> #P number 259 101 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 182 148 28 9109513 sig~;
> #P newex 182 183 39 9109513 sah~ 0.;
> #P number 665 73 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 665 92 45 9109513 delay $1;
> #N vpreset 1;
> #X append 1 2 7 155 447 flonum float 0.4 ; 14 128 182 flonum float 1.25; 23 61 497 flonum float 46. ; 25 45 182 number int 8 ; 26 64 40 number
> int 10 ; 28 131 326 flonum float;
> #X append 1 2 18. ; 30 136 715 number int 524 ; 32 59 580 flonum float
> 1. ; 37 73 665 number int 10 ; 40 101 259 number int 512 ;;
> #P preset 282 282 47 27;
> #P newex 580 108 50 9109513 pack 0. 0.;
> #P newex 580 83 27 9109513 !- 0.;
> #P flonum 580 59 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P message 580 131 57 9109513 range $1 $2;
> #P number 715 136 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P user scope~ 580 157 725 291 2 3 256 -1. 1. 0 10. 0 0. 75 133 255 0 0 0
> 0;
> #P flonum 326 131 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 182 67 27 9109513 t b f;
> #P number 40 64 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P number 182 45 35 9 1 0 1 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 182 103 27 9109513 / 1.;
> #P flonum 497 61 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 497 81 41 9109513 phasor~;
> #P newex 497 105 58 9109513 wave~ grain;
> #P newex 40 327 31 9109513 abs~;
> #P newex 213 295 38 9109513 *~ 512.;
> #P message 311 154 37 9109513 size $1;
> #P newex 259 130 62 9109513 sampstoms~;
> #P newex 182 269 29 9109513 +~ 1.;
> #P newex 182 242 31 9109513 *~ -1.;
> #P flonum 182 128 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 39 351 358 9109513 poke~ grain;
> #P newex 40 301 27 9109513 *~;
> #P newex 311 179 93 9109513 buffer~ grain 200;
> #P newex 40 103 49 9109513 cycle~ 10;
> #P newex 182 208 47 9109513 phasor~;
> #P message 465 205 68 9109513 startwindow;
> #P flonum 447 155 35 9 0 0 0 139 0 0 0 221 221 221 222 222 222 0 0 0;
> #P newex 430 177 27 9109513 *~;
> #P user ezdac~ 430 235 474 268 0;
> #P window linecount 2;
> #P comment 326 98 68 9109513 or length in ms (independent);
> #P window linecount 1;
> #P comment 40 44 25 9109513 freq;
> #P comment 103 210 73 9109513 damps sinusoid;
> #P comment 258 81 62 9109513 buffer length;
> #P comment 496 40 55 9109513 wave~ freq;
> #P connect 20 0 13 0;
> #P connect 26 0 10 0;
> #P connect 10 0 12 0;
> #P connect 12 0 20 0;
> #P fasten 16 0 12 1 187 293 62 293;
> #P connect 25 0 27 0;
> #P fasten 26 0 24 0 45 91 187 91;
> #P connect 27 0 24 0;
> #P connect 24 0 14 0;
> #P connect 14 0 39 0;
> #P connect 39 0 38 0;
> #P connect 38 0 9 0;
> #P connect 9 0 15 0;
> #P connect 15 0 16 0;
> #P connect 27 1 24 1;
> #P fasten 10 0 38 1 45 174 216 174;
> #P fasten 9 0 19 0 187 233 218 233;
> #P connect 19 0 13 1;
> #P fasten 40 0 19 1 264 124 246 124;
> #P connect 40 0 17 0;
> #P connect 17 1 18 0;
> #P connect 28 0 18 0;
> #P connect 18 0 11 0;
> #P fasten 21 0 6 0 502 134 435 134;
> #P connect 6 0 5 0;
> #P fasten 8 0 5 0 470 228 435 228;
> #P connect 7 0 6 1;
> #P connect 23 0 22 0;
> #P connect 22 0 21 0;
> #P connect 32 0 33 0;
> #P connect 33 0 34 0;
> #P connect 34 0 31 0;
> #P fasten 21 0 29 0 502 152 585 152;
> #P fasten 36 0 29 0 670 153 585 153;
> #P connect 31 0 29 0;
> #P fasten 32 0 34 1 585 77 625 77;
> #P connect 37 0 36 0;
> #P connect 30 0 29 1;
> #P window clipboard copycount 42;
>
>


Pere J Villez: Pereshaped

#118738
Dec 12, 2007 at 5:56pm

John,

That’s a fantastic solution. I should have known there was a way to apply count~ in there somehow, and you basically use it as a scaled phasor~ too! And I can use a float for number of periods now, which allows for some nice sweeps…

Now with any luck I’ll be able to scale each bump of the FOF, and maybe start changing the distance between bumps, though I haven’t figured out how to do that yet.

Anyway thanks so much for your help! And to all other posts for the helpful info on other sources.

Inouk

#118739
Dec 12, 2007 at 6:41pm

> Now with any luck I’ll be able to scale each bump of the FOF, and
> maybe start changing the distance between bumps, though I haven’t
> figured out how to do that yet.
>

Check out trapezoid~ for that…

Peter McCulloch

#118740

You must be logged in to reply to this topic.