What's wrong with this synthesis?

So I’m trying to understand how to create sounds with SC, using a SinOsc(), and applying mathematics functions on it.

I made this :

{ SinOsc.ar( 55  * [ 0.99, 1.02 ], mul: 0.5 ).fold( -0.25 * SinOsc.kr(1/6), 0.25 * SinOsc.kr(1/3) ) }.play;

Which I like. To be clear, I had no idea what it would do, I skipped mathematics so I lack the ability to predict sound from math operations… But anyway, there’s a huge problem with this.

The period looks like :

Here I’m confused because ‘it sounds good’, but it’s not centered around 0, there’s I think, a big carrier, which I suppose shouldn’t be here. I have the intuition it would sound all the same with everything centered around 0, and prevent speaker issues…

I tried to find a way to subtract the associated sine, but I couldn’t figure out how to calculate it. I think my problem is related to the fold function sometimes folding between two negative values, or two positive values.

So if anyone has any idea of what I’m doing wrong, either that I should never fold like this, or that I missing how to correct the actual sound, or that the problem is elsewhere, and would like to share an answer, it would help me progress,

Thank you,


One solution may be to wrap the output of this into a LeakDC.ar (which is basically a high pass filter to remove components that cause this kind of shift).

Josh Parmenter

Yes thank you, that works !

When trying to correct it, I didn’t even think about a high pass, because I still see it as a musical effect, not an arithmetic function. But it sure is. That made me realize that.