phase shift of rect~, tri~, saw~

oshii's icon

Hi guys,

Since I couldn't manage to find such a topic on this forum I guess it's a silly question:
How do you shift the phase of a rect~ object?
For a cycle~ object it can be done by using the right inlet, however this is not the case for rect~..
Same question for trip~ and saw~, but I guess the answer is the same.

Thanks!

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

Hi
it's possible to hack willy_wanker's example, to expose manual phase-shifting:

It looks ok; not sure how it will sound at audio frequencies though
Brendan

brendan mccloskey's icon

. . . it pitch shifts (well, rect~ does), but then Doppler (and PWM) can do that, so . . .

brendan mccloskey's icon

final ps

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

If you use this simple %~ method to phase shift, be aware that it only works on unipolar ramps:

Brendan

brendan mccloskey's icon

@willy
yes, in [poly~] situations % (and accum) are costly. But until the OP chimes in we won't know what implemetation s/he's after; and my solution is based on your's so now he has a choice :)

B

oshii's icon

Guys, thanks for all your replies.
I'm studying phase modulation right now, this is how I stumbled upon this.

However I am still obviously a dumb beginner. I thought that I'm not that "green" anymore, but your patches prove the opposite...
Could you please explain a bit what exactly happens?

Brendan, the "hack" you made of Willy's patch seems more or less indicative to me but I'm still some pieces.
I know the objects but sill can't really get the logic behind your algorithm.
What exactly does the "sync" function do to the rect~ object?
As far as I understand from Willy's first reply, everytime it receives a signal with value more than 0. (any value?) it shifts phase to 0.?

brendan mccloskey's icon

"I am still obviously a dumb beginner. I thought that I’m not that "green" anymore, but your patches prove the opposite…"

there used to be a guy on here called himself n00b4life. Modesty versus arrogance, 'tis a fine line we walk; I prefer to err on the side of arrogance, recently.

As for your question, phase sync refers to resetting an oscillator's output to zero, and if you search here (or elsewhere) for "hard-sync" you'll get a better explanation that I can offer. The phase-sync input only responds to a zero or one. I'm sure you're familiar with the concept and practice of driving an oscillator by ramping it's phase over time (connect a phasor to cycle's right inlet, for example). So, if you offset the driving phasor ramp by, say, 50% (0.5) and then do a reciprocal division (%, right?), you will get a phase shifted ramp. This ramp can then drive a rect or saw or whatever. My proviso above was based on my attempts to do phase shifting on bipolar oscillators, which naturally produced some strange results (because of the %1).

HTH

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

oops; a picture paints, erm, 200 words:

oshii's icon

"Modesty versus arrogance, ’tis a fine line we walk; I prefer to err on the side of arrogance, recently."

I'm sorry if I was not that clear. That wasn't sarcasm. I just expressed my disappointment from myself. No modesty, no arrogance; just reality.

Thanks a lot for the thorough explanation and for the nice patch.
I will spend some time studying it and will let you know if that helped.

Just at first glance - is there a particular reason why you use exactly 21.45Hz for rect~ and 0.25 for the cycle~?

brendan mccloskey's icon

"Just at first glance – is there a particular reason why you use exactly 21.45Hz for rect~ and 0.25 for the cycle~?"

Purely for the visual display using [scope~] - samples per pixel and buffer size I always set to 64. As for the 0.25 offset, if you think about it, 0.5 offset would give a 50% phase INVERTED ramp, which wouldn't be visually/aurally discernible.

ps i did not presume sarcasm, I myself was recently (and correctly) warned of misplaced/unwarranted modesty, and I wanted to pass it on. Paying it forward. We are all on an infinite learning curve - irrespective of medium, language, form,

shit, maybe I need another spliff
jk

oshii's icon

@Brendan Let see if I get it right:

- You get two signals coming out of cycle~ and multiply them by each other. I guess this is to convert the bipolar wave to unipolar. Just a question, when doing this is the frequency remaining the same (0.25Hz in this case)?
- Further down you add the phasor~ outlet to the multiplied cycle~ signal. So this is kind of frequency modulation, isn't it? In this case we use frequency modulation approach to achieve a phase modulation, isn't it?
- Then you pass the outcome through %~ 1. Is this kind of scale operation in order to keep the signal in the range between 0. and 1.?
- The hard-sync responds on 0. and 1. (signal!, and no messages can trigger it) only and nothing in between? When does rect~'s output reset to 0. - I guess it is it only when it receives signal 0.?

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

This is what i've been doing. It usually sounds quite nice, but I kinda mangle my harmonics. Rate~ doesn't seem to be too expensive

brendan mccloskey's icon

@raja
been here long enough to know ;) The name changes but the gravatar stays the same!.

@oshi
Multiplying a bipolar oscillator's output by itself creates a unipolar output at twice the frequency. The default values I used, as I said earlier, are purely for the visual display output via scope~. Those values are largely irrelevant as far as the concept explanation goes.

Adding a value to an oscillator's output effectively phase shifts it, if you also use %~. Modulo outputs the remainder of a division. It's a simple maths trick, there's no FM or PM. It's just, well, phase shifting. Look at the helpfiles of any object for a much clearer explanation of its function

I didn't look at monetus' example, but [rate~] and [pong~] are good pointers too.

I can't help feeling that this question has become unnecessarily over-complicated.

Brendan

brendan mccloskey's icon

ps

willy_wanker, or others, will explain hard-sync (resetting an oscillator to zero phase) better than I, because I've never used it. The first synth I ever owned was a DX9.

oshii's icon

@Brendan McCloskey , Yes, I think more or less I know what % modulo operator does, theoretically, but I'm lacking practical experience with it, so I wanted to know why you have decided to use it in your patch, what function does it have in this particular case. I guess that it serves to scale the signal in to 0. - 1. range in order to make the hard-sync work.
Another question pops up - instead of phasor~ can we use a signal with a different shape, for example cycle~, for a phase shift or we won't end up with a linear phase shift, I guess?

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

Hi oshi
do you want phase-shifting, or hard-sync, because it's clear from this thread that they are two slightly different approaches. Compare willy_wanker's hard sync example, with my phase-modulation patch and you should see the difference. I know how to phase-modulate phasor's linear ramp, based on raja's 1st example at the top of this thread. All I can say is, you are right about my use of %~ : effectively it shifts the phasor ramp forward in time, but I'm not using it as hard-sync. As for your second question, modulo will give you (me) quirky results if you feed it curves or negative values; see the patch below:

E&OE