Non-[cycle~] oscillator phase restart

Dra's icon

Hey guys,

I've seen various combinations of [cycle~] [phasor~] [buffer~] and [wave~] for controlling phase offsets which is cool, but how would one restart the phase of the antialiased [saw~] [rect~] and [tri~] oscillators at the start of each new note?

Many thanks

Dra's icon

If a [click~] is fed to the right inlet of a [saw~], [rect~] or [tri~] oscillator, and is triggered by a new note in a tempo-active device, the phase is not reset.

I have been shown an example elsewhere whereby the phase of the mentioned oscillators does indeed restart from zero using the click method, but this example was in what I would call a "static" environment where an active project tempo was not in use.

Could anyone enlighten me further? I'd love to get this one put to bed.

Dra's icon

Phase is not reset...evidence to illustrate:

Phase.amxd
amxd 5.61 KB
Example instrument

Scope (C1@125BPM)

Phase.aif.zip
zip 85.61 KB
Audio

Someone must know something about this

Roman Thilenius's icon

sorry if i dont fully understand your question:

these objects have a phase inlet which can be synced to a master phasor just as cycle~, no?

Dra's icon

Hi Roman thanks for the reply, no, feeding a [phasor~] into the right inlet of any of the above objects (whether it's own phase is being reset to zero or not) does not achieve this. I have seen how to create interesting effects with this set up...but nothing on successfully resetting the phase of the oscillator it's going into at the start of new notes.

Roman Thilenius's icon

if i interpret the picture correctly you are sending a float into the object in order to change the frequency. did you try yet to use a signal, which can more securely be in sync with the click?

i dont know this trick with the spike, but i could imgaine that it requires to delay the frequecny change for exactly one sample. (?)

Roman Thilenius's icon

i dont use these 3 objects myelf but it seems i am fundamentally wrong with the assumption that it works like with cycle. especially it does not seem to overwrite the last frequency value received at the first inlet. :)

Dra's icon

After testing your suggestion of a signal input this is also unsuccessful. Do you design your own oscillators?

Roman Thilenius's icon

there are many threads with the same question. most dont contain useful answers. here are some working examples:
https://cycling74.com/forums/phase-shift-of-rect-tri-saw

Dra's icon

Oh, hold on sorry I didn't see your sample delay suggestion

Dra's icon

Yes, I've seen and read all of them.

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

It's still inconsistent...

I just wanted to check with the professionals that I hadn't missed something, thank-you as always for your time, it seems this one will remain in the Bermuda Triangle.

Roman Thilenius's icon

i might have been wrong about the sample delay. according to the reference the OSCs should set back the internal phase position on zero to nonzero transition at that inlet.
that would be sample number 1 of the first vector after the messge comes into the click~, just as at the frequency input of the OSC.

i´ve built a huge patch earlier and didnt get it to work using click~ to have two phaselocked tri~s .

actually i dont even understand its helpfile.

Roman Thilenius's icon

the patch in your picture demonstrates well that click~ and phasor~ here are basically doing the same thing to that inlet.

only it doesnt work as expected. :)

they have great weather in bermuda.

Dra's icon

Interesting how difficult this is to achieve isn't it? So I have arrived at the conclusion that the following statement, at the moment, is true:

To reset the phase of any of Max's anti-aliased oscillators, to any value at all, at the start of each new note in a tempo-active device....is impossible.

Today I must find Bermuda shorts to help celebrate this conclusion.

kLSDiz's icon

They do reset their phase, but you have to keep in mind, that band limiting is done (just a guess, but plausible) using some steep filtering, and the first samples just after the reset are depending on a few previous samples.

Edit:

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


saw~ phase reset (2nd channel directly from the saw~ object)

Roman Thilenius's icon

phase lock sync tri saw rect

Dra's icon

Hi KLSDIZ, thanks for your observation.

Yes...in your screenshot the first is off then the second and third are at zero, but if you continue to feed it notes (at irregular intervals) the non-zero crossings appear intermittently again. I'm probably not understanding fully what you have pointed out, Roman clearly has, but before I also book my ticket I want to know what the future holds....could you possibly elaborate further on your point for me please?

Dra's icon

Your patch in a tempo active state, two notes later........

Dra's icon

Triangle wave restarted from zero

Triangle wave restarted from "zero" in Max with same notes at same time

Dra's icon

From the perspective of synthesizer design and use, if this apparent "reset from zero" function is implemented and offered as an option to the user...what they actually get is nothing of the sort.

Roman Thilenius's icon

[postcard from bermuda]

Max Forums, P.O. Box 74

hi guys,
it is really great here in bermuda. today i was
shark diving and i highly doubt that tri~ uses
filtering to archive bandimiting. it is either
using polynominals/additive or, if the author
cares about CPU hunger, wavetables. but otoh,
you never know. i´ve seen all sort of crap in
vanilla objects.
which reminds me on ordering more ice cream.
-110

kLSDiz's icon

I think "reset from zero" and "phase reset" aren't the same thing. In the case of band limited oscillators the shape of a wave is of a secondary importance. Here is a close view of waveform in the point of reset: from the top to bottom there are: raw osc output, gate signal (on/off), waveform gated by this signal and waveform gated by slightly delayed gate signal:

And here the same place from distance:

It takes 3-4 samples to go to the bottom "starting" position for the oscillator after "phase reset" signal. It doesn't jump immediately to the bottom position, but gets interpolated – which means there is a kind of filter (averaging with previous values) or the algo uses some kind of accumulator. As Roman wrote from his journey, we can only speculate about the algorithm used by those objects.
From what I see you have a few possibilities:
- take advantage of what is available: delay gate a few samples to get more or less predictable wavform starting position (and consider possibility that band-limited generators don't have natural neutral "zero" state)
- use non band limited oscillators (phasor~ and family, full phase control)
- dig into some DSP theory and make band limited oscillators by hand (wavetable sequencing, or some clever gen~ patching; and don't forget sharing your discoveries here! :)
- buy a ticket and join Roman

cheers!

band-limited oscs in max.amxd
amxd 7.68 KB
device used to produce images above