SynthMaker

Sync DC Offset

Archive · 2012 28 old posts

From the original SynthMaker forum (2004–2014), with its members’ names and dates.

adamszabo ·

Hey guys, I am experimenting with syncing oscs and it works well and all, however I get some DC offset anomaly and its really not what I would like. When you turn knob 1 up, you can see the wave really goes offset, and also when you turn the knob 2 downwards. I tried some dc removal method and even high pass filters but they colored the waveform too much. Does any one have any suggestions?

DigitalWhiteByte ·

Hi Martin, you should use an Integrator, for compensate the DC-offset. You can have look, Here

oddson ·

adamszabo wrote: ...I tried some dc removal method and even high pass filters but they colored the waveform too much. Does any one have any suggestions?

I had a similar problem getting DC out of the feedback loop with Karplus-Strong synth because I didn't get the cut off low enough.

MyCo posted this filter which is a pretty good blocker:

streamin in; streamout out;

float lastin; float lastout;

out = in-lastin + 0.9999*lastout;

lastin = in; lastout = out;

adamszabo ·

Yeah I tried that already, the problem with that is that I still get a pop in the beggining until the wave aligns, and if I lower the constant It acts as a high pass filter and changes the waveform.

cyto ·

That offset is perfectly normal for hard-sync. It happens when the master osc (knob 1) is higher than the slave osc (knob 2). You'll notice that when this is the case, the resulting wave is simply an offset saw. Rather than trying to "center" it after it has been generated, I think a better solution may be to just make sure that the freq of the slave osc is dependent on that of the master osc and that the slave is always lower. A good explanation can be found here that has lots of good pictures.

-cyto

trogluddite ·

Also, worth noting that this is not an SM specific, or even DSP in general, problem. An analogue synth would do the same when using hard-sync, and the filtering (DC blocking capacitors), and attack side-effects (DC "thump") are also much the same. Some folks even consider the DC thump as a 'feature' because it adds extra punch to bass and 'percussion' sounds - I have at least one old plugin that has a specific setting for DC thump.

cyto wrote: It happens when the master osc (knob 1) is higher than the slave osc (knob 2).

It certainly makes the problem worse - the offset is 'diluted' by more whole cycles of the slave (assuming that the slave wave is centred to start with). However, an offset will still be there any time that the carrier is cut short of completing a whole cycle. But of course, that is precisely where the interesting sounds are - if the slave fits the master in whole cycles, you just hear the slave with no sync effect (boring!).

Now here's an idea, but I think maybe tricky and probably only with custom osc's. (and much more CPU than a HP filter!!) 😉 😈 From the ratio of the two frequencies we can easily work out the number of full wave cycles that the slave fits in, and also how big the remaining unplayed fraction of the wave will be. Because of the sync we can now easily predict exactly how far through a cycle the slave will be when the next sync happens. Use this prediction to look up a value from a table - this has a list of values for the average signal level of the waveform between the point in question and the end of the cycle. The looked up value is weighted according to how many full cycles get to happen (i.e. duration of time with no DC offset). Add value to output. DC Gone 😕 ????

...can't quite tell if that is at a sensible idea, or if it is just the terrible "summer" weather getting to me! 😝

cyto ·

trogluddite wrote: However, an offset will still be there any time that the carrier is cut short of completing a whole cycle. But of course, that is precisely where the interesting sounds are - if the slave fits the master in whole cycles, you just hear the slave with no sync effect (boring!).

Just to clarify... I wasn't suggesting that the two oscillators be whole-cycle multiples of each other. I was saying that whatever ratio you choose, make sure that the master is lower than the slave. Otherwise, you "shunt" the slave before it completes a cycle (every cycle), not only causing the dc offset, but actually changing the pitch of the resultant wave. Look at the link above. It does a better job explaining this than I can.

I think this was the situation that Adam was talking about (right?). The normal dc-offset caused by hard-syncing I don't think would be too much cause for concern. If I'm way off base here, I apologize for muddying the conversation 😉

-cyto

trogluddite ·

cyto wrote: Just to clarify...

He he, no I wasn't suggesting that you were suggesting..... 😉 You're quite right, "shunting" the slave is by far the worst case - I was just covering all the bases as Adam didn't say whether the pitch was affected.

adamszabo ·

Ah those are indeed good solutions! However the synth I am building must have the knobs working this way, so I have to be able to make the master osc go higher. A way I am trying to solve this is taking the difference of the knobs and call a number based on the difference, which will align the dc offset. Since there are 96 (since when you have knob1 on 48, and knob2 on-48 thats 96 steps) possible combinations this will be damn tedious work haha. I have to manually find this number for each step because I couldnt generate an appromixation curve close enough. Althought there is a funny relationshop between the freq and the dc offset, when I have the knob1 at an octave (12 semitone) the waveform goes half way down, so the top of the saw is touching the center line. If you increase it another octave (24 semitone) the waveform halves again, and now the dc offset is half of what it was before. I am still trying to figure this out!

martinvicanek ·

In the critical regime where Freq1 > Freq2 the DC offset is simply DC = Freq2/Freq1 - 1 This holds for a saw. Edit: This holds for a perfect saw which goes from -1 to 1. There are some deviations for the band limited saw which you might need to take into account.

martinvicanek ·

Looking at the waveform in more detail, have you noticed that there is some heavy aliasing there? May or may not be desired, just wanted to let you know.

trogluddite ·

martinvicanek wrote: heavy aliasing there? May or may not be desired

The sync point is set to be the steepest of the two zero crossings, so there is always a sharp bounce down to zero, then back up again, at the sync point. While the wavetables do a good job of anti-aliasing most of the time, they are only "recordings" of a band-limited signal. At best, there may be some interpolation or crossfading at the "loop point", but the discontinuity in the "playback" is almost certainly not band-limited (it would show in the CPU load!) Same story as with FM, ring-mod etc. - once you start adding new harmonics, anti-aliased source sounds are no guarantee of alias-free music.

MyCo ·

The DC Blocker was only made for mono streams. In the poly system, you have to remove the initial offset which, would take too long for the 1 pole highpass to smooth that out.

Here is my first guess, how it could be done:

streamin in; streamout out;

float lastin; float dc; float init = 0;

float INITSTEPS = 5;

dc = dc - (init<INITSTEPS) & (dc+in); out = in+dc - lastin + 0.9999*out;

lastin = in+dc; init = init+(init<INITSTEPS)&1;

adamszabo ·

Thanks for that Myco! When I put that code after the saw bfore the combiner, and move the knobs everything goes haywire 🙁

MyCo ·

Don't know what you mean, maybe a copy&paste mistake. Try the attached file.

adamszabo ·

Ah yeah, you are right, it was propably what you said, thank you!

martinvicanek ·

Here is an alternative DC compensation. It will only work for this particular schematic, e.g. if you change the saws for triangles, you'll have to rework the maths. However, the advantage is that DC compensation is instantaneous, there is no transient as in a high-pass based DC blocker.

adamszabo ·

Wow thats pretty good! What exactly would I have to change if I were to use different waveforms?

martinvicanek ·

adamszabo wrote: What exactly would I have to change if I were to use different waveforms?

The inner workings of the "DC Eval" module would have to be adapted to the waveform of oscillator 2. Basically the module computes the DC offset as a function of the frequency ratio, i.e. the average over the waveform 2 from start to the first resync. I can be more specific if you post your schematic with the desired waveforms.

adamszabo ·

Ooh, well I am planning to have morphable oscillators so for example it can go from a saw to square to a sine, and anywhere in between. So I tried to turn the green into an assembly function and somehow make it dynamic so it can adapt to the wave. Do you think its possible or its not worth bothering with it?

martinvicanek ·

It can be done but I'd have to see the details in your schematic. I suppose there would be some extra cpu load though. If you can live with the transient, MyCo's solution is much easier of course. Edit: Thinking about it, it would probably be easier to generate your DC-free waveforms in code outright, given the aliasing that you have anyway.

infuzion ·

MyCo & martinvicanek, your signal-to-noise ratios are amazing!

adamszabo ·

Hi martinvicanek,

Sorry for the late reply. I was thinking of something like this. You can morph the wave and it aligns with the dc offset, if its possible.

infuzion ·

adamszabo wrote: Hi martinvicanek,

Sorry for the late reply. I was thinking of something like this. You can morph the wave and it aligns with the dc offset, if its possible.

It seems there is still DC unbalance; many input combinations have an extra mini-triangle on the bottom. Or do I miss-understand what DC offset is supposed to be?

Would be handy to have a module that could tell you if there is offset.

martinvicanek ·

adamszabo wrote: You can morph the wave and it aligns with the dc offset, if its possible.

Nice! Yeah, DC compensation should be possible for the morphed waveforms, I just need to work out the details.

infuzion wrote: It seems there is still DC unbalance; many input combinations have an extra mini-triangle on the bottom. Or do I miss-understand what DC offset is supposed to be?

Would be handy to have a module that could tell you if there is offset.

Well spotted! For a pure saw (not band limited) set the correction factor to 1. The value 0.85 was for the band limited saw. Good idea to include a DC meter for checking.

martinvicanek ·

This one should do DC compensation for morphed waveforms. It's kinda special purpose but it works.

adamszabo ·

Thats pretty amazing! But how do you figure out these formulas? Is there a general rule one can follow?

martinvicanek ·

Basically the DC Eval module computes the DC offset as a function of the frequency ratio, i.e. the average over the waveform 2 from start to the first resync. Something like

DC = 1/r*integral_0^r f(x) dx,

where r is the frequency ratio and f(x) is the waveform 2, and x goes from 0 to 1 for a full cycle. The integration can be carried out in closed form for sine and piece-wise for saw, triangle, and square. The formulas look more complicated than they actually are.

Wrote something here? To have a post removed or your name hidden, write to [email protected].

Before your first post

A few rules keep this a friendly place. You agree to them once.

Shown next to what you post, here and in the app. It doesn’t have to be your real name: 3–24 lower-case letters, digits or _ (capitals become lower case, spaces become _).

    Then your post goes up straight away.

    Delete this reply?

    Open it in SynthMaker?

    It goes on the track you’re editing there, in place of that track’s sound, and into My sounds. Your other tracks stay as they are.

    Want to keep that track’s sound? Start a new song in SynthMaker first (Song › New song), then open this.

    Report this reply?

    Only the developer reads reports. The person isn’t told who reported them.

    What’s wrong with it?

    Block this person?

    You won’t see their posts and replies here any more. They aren’t told, and you can unblock them at any time.

    People you’ve blocked

    Their posts and replies are hidden from you. Unblock someone to see them again.

    The community rules

    A few rules keep this a friendly place. Everyone agrees to them once, before their first post.