Reliable phase sync of many rect~ oscillators.

Alba Triana's icon

Hello,

I would like to know if there is a reliable way to reset the phases of multiple oscillators (40) without having to stop and start DSP each time.
Please find below a description of my patch and issue, and attached a resumed version of the patch with notes included.

Patch description:

Patch is comprised of 5 synthesizer modules controlled by a sequencer; the resulting signal from each module is used to drive a set of external devices. Every signal comes out through the dac~ object to an external audio interface, and then to each device. Every synth module is comprised of 8 rect~ oscillators and all modules are configured in the following way:

- All oscillators frequencies are set to 30hz but all of them have independent phase modulation, amplitude and pulse width.

- All oscillators within the modules are grouped in pairs. Every pair shares a common phase modulation speed (X) but one oscillator begins the sequence at phase 0° (A), while the other begins with its phase set at 180° (B).

- Phase: The phase of every pair is modulated by a triangle wave LFO at X speed, where:
- X is different for all pairs within all modules.
- X is set at specific rates so all synth modules behave differently but all of its oscillator pairs will sync phase at specific time intervals.

In order to achieve the proper syncronization of all modules, they all must begin the sequence at the same phase: 0° and 180° for A and B oscillators respectively. The only way I found to achieve this is to create all LFOs as rate~ objects with independent frequency (X), driven by a master phasor at 1hz. The resulting signal of each rate~ object is then connected to a pong~ object in order to bend the waveform into a triangular wave. Then, it is summed to a master phasor which sets its phase as follows:

- Master phasor A begins with a 0 message for phase 0°.
- Master phasor B begins with a 0.5 message for 180o phase.
- Banging the phase messages of master phasors doesn't sync all of the oscillators but rather randomizes the phases of all of them. To actually reset phases we must stop and restart DSP each time.

Issue: Even though this method is working, it is not 100% reliable. Approximately, 10% of the times the sequence starts, one of the modules begins with a phase completely different to the rest of the modules. The defective module is almost always the same, even though it works fine 90% of the times and is built exactly as the rest of the other modules.

I like to ask the following:
Is there a better or simpler method to achieve our goal?
Do you think this small margin of error could be caused by computer processing or external hardware issues?

Please refer to the resumed patch below further understanding. Thanks in advance!

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

Jan M's icon

not in front of max right now? did you check the rate~ object. it does exactly this - everything can be driven by one phasor~.

kleine's icon

If you use send~ and receive~ it will introduce a few samples latency (afaik), so in your case it should be avoided...