Phasor to SQUARE wave?


#1

Hi everyone!

For my String Machine project, I need to convert the Sawtooth wave coming out of a osc/phasor into a Square Wave. Below is my subpatch in charge of the conversion. The Phase is converted to Sine Wave and then clipped with the object dist/inf.

It works like a charm but the dist/inf uses a lot of %DSP and it dramatically limits the number of instances I can use...

Do you guys have a lighter idea to get a Square Wave from a Phasor?
Thanks in advance!


#2

sure check out lokki/octaver/squarify ...

:slight_smile: i hope it is more processor friendly...


#3

and you might have to move the "zero" point of the phasor to get a square instead of a pulse..


#4

:slight_smile: i hope it is more processor friendly...

OMG YES IT IS!!
It allowed me to double my overall polypony!!!

The aliasing seems to be a bit more hearable (do you confirm?) but that's OK, it's perfect for my need!
Thank you so much my friend!


#5

yes, there is no filtering whatsoever, there will be aliasing. (i don't know what dist inf does in that regard)

note that you also don't need the math/sin object, maybe that could give you some more voices?


#6

The dist/inf does have a bit of aliasing but in a more reasonable range. Anyway, it doesn't bother me more than that. Just for my knowledge, would a simple low pass filtering reduce the aliasing of your object? I guess it's a bit more complicated...

Actually, I didn't manage to get any sound out of your object with only phasor-->squarify. Like you said I need to move the zero point of the phasor to make it works, but I didn't try to modify its code yet. For now, math/sin gives me a perfect duty cycle and doesn't seem to eat that much CPU...

Do you think I'm wrong?


#7

no you are not wrong. but i think you can simply offset the phasor with a -c object or an unipolar to bipolar object to get the same result. but as you said the math/sin is not that expensive either.

try the lowpass after the squarify, it might help a little. but it will not remove aliasing.


#8

)

The low passed ate some %DSP and didn't reduce a single bit of aliasing :roll_eyes:

Tried it, both "-c" and "unipolar2bipolar" objects worked and saved some %DSP !

BUT

Something really weird occurs when I play 2 octave notes...
For example :
- if I play a C1 --> I hear a C1 (wow I'm such a good programmer :rofl:)
- if I play a C2 --> I hear a C2
- but if I play C1 + C2 --> I hear C1 + C3 !!!!! :dizzy_face:

If I use a math/sin object before your squarify, I don't get this strange phenomenon... :roll_eyes:

I didn't mention it yet but I use a phase lock architecture, this means that C1, C2, C3, etc are coming from the same phasor that fed the polyphonic object I've showed few posts above.

Any ideas ?
I really would like to replace math/sin with any of these object to gain some %DSP...


#9

It may be a problem with phases.
Maybe you can try changing the -c value.

As you stated, phases relations are crucial when it involves combining octave related notes.


#10

Here's some news!

The problem does not seem to be induced by the phase the square method but by the math/satp included in the filtering block right after. Indeed, if I disconnect it, the problem disappear.

Here's a test bench I made to figure how to solve the problem :
phasor2square.axh (52.8 KB)

You'll be able to select between the 3 methods (math/sin, -c and unipolar2bipolar). Try to play a note and its octave (C2 + C3 for example), everything will be OK with math/sin but you will hear a higher octave with the 2 other methods.

Let me know what you think!
Thanks a lot for you help!