Sync trigger for cycle~ object

rgbrobot's icon

Hello. I am trying to make a multi-wave oscillator.

Most of the standard features I have figured out (tuning, PW, etc.)

The one feature I haven't quite figured is Sync control of a sine wave. (i.e. the wave of one sine wave controls the reset of another.)

I know the [tri~], [saw~], and [rect~] all have the sync input (sync trigger) and they seem to be working fine. my only issue is getting the sine wave [cycle~] to sync.

https://cycling74.com/forums/resetting-cycle
^^ The above thread is the closest I've seen it come, but the issue is that it resets to a value of 1, so when you have another oscillator driving your main, there's clicks and pops all over.

I'd paste what i have so far, but A)I don't know how to do it for the forums B) what I have isn't much, and it's not needed to solve the issue.. I don't think.

Thanks all!

oli larkin's icon

if you want to do band-limited hard sync with sinusoids, you need to look into making an external with minBLEP. You can pull the source code from the GPL TAL-noisemaker synth.

Max Patch
Copy patch and select New From Clipboard in Max.

Alternatively, you can do Casio CZ style "windowed" hard sync like this...

Floating Point's icon

I think your reset to a value of 1 is to do with the cycle object outputs a cosine wave rather than a sine, so you'd have to have a phase offset of 0.75 for the cycle object relative to the other wave shapes. As for waveform discontinuities you'd need to work out a change in phase over time (say 50ms or so maybe) using line~

rgbrobot's icon

Thanks for the response Oli.

The patch you posted is not quite what i"m looking for. I'm not even sure if i fully understand everything going on in that patch. Here's a look at what I'm trying to accomplish.

The two pairs on the right are syncing fine, but two cycle waves I can't get to sync.

Max Patch
Copy patch and select New From Clipboard in Max.

Also, I looked into minBLEP, and it seemed a little confusing.

rgbrobot's icon

Hey Terry. Thanks for the response.

I wouldn't say I'm a MaxMSP noob, but I will say I know very little about all the math functions throughout the software. Would you mind pasting an example?

thanks!

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

This is adapted from the example posted in the thread you referred to before:

The patch you posted just before is not an example of synching using phase, but actually an example of phase distortion.

Floating Point's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Here you go, hope it makes sense:

oli larkin's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here is a non-bandlimited hard synced sine… perhaps more what the OP was after

>The patch you posted just before is not an example of synching using phase, but actually an example of phase distortion.

not really. true it is used on a synth famous for being a PD synth (the "resonant" waveforms), but this is actually hard sync.... windowed to smooth out the discontinuities and hence the aliasing. The other waveforms on the CZ synths are actually more "phase distortion", since there the phase accumulator is being warped.

Max Patch
Copy patch and select New From Clipboard in Max.

Here is a similar version of the first patch i posted without the windowing

rgbrobot's icon

you guys rock. however, I don't think we've quite achieved what I'm looking for. i'm trying to emulate an analog synth (in the most basic way) by connecting the output of one oscillator to the 'sync' input of another oscillator to have them in sync. (note: Not trying to emulate the "unstable" sound of analog circuitry, but rather the overall experience.)

So. having said that, Oli, I think you are on a different page than the rest of us. I'm not sure how to translate your patches into what I'm trying to do. see the patch below, which is what I'm trying to do.

Max Patch
Copy patch and select New From Clipboard in Max.

(note: the gate represents connecting/disconnecting the output of one oscillator to another)

Sorry I'm being so confusing.

Terry, i think we're getting closer, but I'm not so much interested in getting oscillators in phase. It's more important to figure out how to get that value of .75 (in your adapted version of the patch from the previous thread) to be triggered each time an external oscillator makes its cycle.

I hope that makes sense.

Thanks again for your help!
- Argee.

Chris Muir's icon
Max Patch
Copy patch and select New From Clipboard in Max.

I think Oli's non-bandlimited patch did what you want.

roger.carruthers's icon
Max Patch
Copy patch and select New From Clipboard in Max.

Would I be right in thinking Oli's windowed patch is almost Vosim?
I've been trying to create a little Vosim patch recently, and would welcome any input. I suspect there's more to it, but it's interesting in itself anyway.
I must admit, I'd missed the +~ .75 trick, but it doesn't seem to make any audible difference,
cheers
Roger

rgbrobot's icon

Chris! What you have posted seems to work, audibly, but I'm not sure if it is *exactly* what I want....My only concern for it is that, according to the scope, it appears to be all positive values, which I'm okay with, as long as there's no damage done to headphones/speakers/etc. I wonder how this would compare with an analog system. But, it produces the desired result, so I believe I'll be alright with it for now!

My only concern for it is that, according to the scope, it appears to be all positive values, which I'm okay with, as long as there's no damage done to headphones/speakers/etc. I wonder how this would compare with an analog system.

Since I am using this for a school project, I don't want to turn this in and say "viola! a sync'd sinewave oscillator!!!" I'd like to be able to explain how it's working. Chris (or oli), would you mind explaining what is going on inside that patcher?

Thanks again guys!

Floating Point's icon

"Since I am using this for a school project, I don't want to turn this in and say "viola! a sync'd sinewave oscillator!!!" I'd like to be able to explain how it's working. Chris (or oli), would you mind explaining what is going on inside that patcher?"

I suggest you figure that out for yourself; otherwise you haven't necessarily learned anything. There's plenty of resources (help files, tutes etc) to look at.

Chris Muir's icon

THe reason it's all positive is because that's what you're asking it to do. You are syncing the sine at twice its rate. This means that it goes through the first half of its cycle, then gets synced, and starts to do it again.

rgbrobot's icon

Ahh.. Well that makes sense. I suppose at different frequencies, it'd look differently. Thanks everyone!

Roman Thilenius's icon

if you want to play a "waveform" (== a cycle~ buffer) once, and then another one after the first one
has finished, i think you could just use index~ play~ and buffer~ instead.

you, the programmer, know how long a sinewave or a tri wave will last when played at note number
60 (or when played at rate*2 or at 5 Khz) and so you could use index~to play one after another.

jvkr's icon
Max Patch
Copy patch and select New From Clipboard in Max.

@roger, concerning vosim, this could be a model to work with.

roger.carruthers's icon

Thanks, that makes much more sense!
Cheers
Roger

pid's icon

@jvkr
beautiful, fantastic, generous and supremely pedagogical example.
thanks.

Gregory Taylor's icon
Max Patch
Copy patch and select New From Clipboard in Max.

here's a gen~ version, I think.

oli larkin's icon

nice... but a bit glitchy. maybe the parameter changes need to be done at the beginning of each pulse?

Gregory Taylor's icon

The more charitable man might have concluded or wondered whether or not it was done *on purpose* because I liked the way it sounds, and also because it's always interesting and useful to leave things in a state where other people can feel as though they can "contribute" by making a few judicious changes (otherwise you're just doing people's homework for them). Feel free to make those mods and it'll be um... "perfect."

oli larkin's icon

sorry if I offended your ego somehow. When i have time to investigate more and learn gen~ i may well try and add said mods to the nice patch you posted.

Regarding doing peoples homework for them... the OP didn't say it was a homework question initially. If he had I and others would likely have been more careful about just providing the solution. But anyhow phase reseting a sine wave in Max at sample-rate is a fiddly business - easiest shown with the solution imho.

pid's icon

ooh, those are fun the last few comments...

anyhow, i had some fun with this this afternoon. in gregory's spirit of "it might not be very good though", here it is...

@oli, "phase reseting a sine wave in Max at sample-rate" - actually remarkably easy with [gen~]. although i might have misunderstood...

i decided to sync to the phasor, although this means parameter jumps from slow/low (long phasor freq times) to high are a bit lame. it is non-glitchy, although in the spirit of those who like it glitchy, i provided a "mode" toggle so you can choose between them.

[codebox]'s in the [gen~] are just for patch cleanliness (as we still have no encapsulation in [gen~]), nothing more.

and one more thing i changed: personally, i do not think using [param] is much cop for signal rate controls.

please mod away...

Max Patch
Copy patch and select New From Clipboard in Max.

thanks all!

Chris Muir's icon

IMO, ArgeeBrobot seemed to be making a real effort to do something, unlike some of the other "my assignment is…" sort of posters.

Gregory Taylor's icon

That looks nice, pid. Sounds pretty good, too. Thanks for getting the obvious tell about using messages not being the best fit.

When the next version of Max is released, you'll find my considerably more traditional values approach - I wanted to keep it really simple [gen~ for the other N% and all. :-) ]. But I'm sure you'll notice the similarities.

The *other* reason for doing the VOSIM patch is personal. Stan Tempelaars (VOSIM's daddy) was one of my teachers, once upon a time. Nice guy, and a great teacher. May his name be for a blessing.