correcting minBLEP sawtooth DC-offset
-
- KVRist
- Topic Starter
- 78 posts since 27 Mar, 2012
In my implementation of minBLEP, overlapping minBLEPs result in a DC offset as the frequency increases.
Here's a frequency sweep from 100Hz to 15kHz. The second signal shows the number of active bleps.
The DC offset eventually goes away as the oscillator transitions to a sine between 8kHz and 10kHz. But at 8kHz, before the sine kicks in, it's pretty bad.
Interestingly, the minBLEP paper (http://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf) acts as if the DC woes are all solved by switching from integrating impulses to placing BLEPs. There's no mention of correcting DC when lots of BLEPs overlap.
Should I just add a DC-blocker at the end? Is that what is generally done?
Thanks!
Here's a frequency sweep from 100Hz to 15kHz. The second signal shows the number of active bleps.
The DC offset eventually goes away as the oscillator transitions to a sine between 8kHz and 10kHz. But at 8kHz, before the sine kicks in, it's pretty bad.
Interestingly, the minBLEP paper (http://www.cs.cmu.edu/~eli/papers/icmc01-hardsync.pdf) acts as if the DC woes are all solved by switching from integrating impulses to placing BLEPs. There's no mention of correcting DC when lots of BLEPs overlap.
Should I just add a DC-blocker at the end? Is that what is generally done?
Thanks!
You do not have the required permissions to view the files attached to this post.
Last edited by tayholliday on Mon Aug 24, 2015 4:59 pm, edited 1 time in total.
-
- KVRist
- Topic Starter
- 78 posts since 27 Mar, 2012
Also, why is it important that the BLEPs are minimum phase? Using linear phase BLEPs would alleviate the DC bias, at the cost of delaying the oscillator output by half the length of the BLEP.
-
- KVRist
- Topic Starter
- 78 posts since 27 Mar, 2012
- KVRian
- 799 posts since 25 Apr, 2011
Are you sure you're scaling the BLEP by the correct amount? IE the exact size of the step in the naive waveform (assuming your BLEP represents a bandlimited step from 0 to 1). Does the output show the expected bandlimiting, proving the maths to be correct?
Watching the waveform with an oscilloscope while you switch the BLEP on and off should show what's going wrong - in fact developing a MinBLEP oscillator was exactly what prompted me to create my J-Scope plugin: http://jaggedplanet.com/vst/jscope.asp
Watching the waveform with an oscilloscope while you switch the BLEP on and off should show what's going wrong - in fact developing a MinBLEP oscillator was exactly what prompted me to create my J-Scope plugin: http://jaggedplanet.com/vst/jscope.asp
-
- KVRist
- 328 posts since 1 Feb, 2005 from Portland
My understanding from the Brandt paper was that the author just sided with minimum phase because he saw the extra delay of linear phase as a problem to solve.tayholliday wrote:Also, why is it important that the BLEPs are minimum phase? Using linear phase BLEPs would alleviate the DC bias, at the cost of delaying the oscillator output by half the length of the BLEP.
However, there is an additional reason that minimum phase is important these days, especially in commercial applications, and that is because Korg arguably owns the practical implementation of linear phase BLEP. I am not a lawyer, but to me as an engineer, the claims in US patent 7589272 describe the concept of creating a linear-phase alias-rejection sequence and mixing it with a naive oscillator waveform containing a discontinuity. The patent does not explicitly state "linear phase," but it calls out any corrective sequence "having essentially no dc offset" or "odd symmetric." Those both happen naturally if you use the Brandt approach with a typical linear phase FIR instead of minimum phase.
- u-he
- 28042 posts since 8 Aug, 2002 from Berlin
LOL, that patent is amazing because the list of prior art might exceed the number of letters its written in.
It may increase shareholder value for Korg, but one doesn't have to be a lawyer to see that it won't hold in court.
It may increase shareholder value for Korg, but one doesn't have to be a lawyer to see that it won't hold in court.
Eli Brandt wrote:Stilson and Smith truncate and apply a window function to this signal, store it in a table, and use it to generate bandlimited impulse trains (BLITs): subsample the table whenever an impulse is desired.
- KVRist
- 293 posts since 1 Apr, 2009 from Hannover, Germany
I'm having the same issue right now with a MinBLEP implementation at high frequencies. Is a DC filter the way to go or is there any way to compute the DC offset and compensate for it directly?
- KVRAF
- 12554 posts since 7 Dec, 2004
Integrate the impulse and apply the inverse of the integral scaled by the density at which it is inserted.
For example if you insert one impulse per two samples all in the same direction and "1.0" amplitude, the offset = (1/2)integral.
You need to take into account the effects of your interpolation technique if used.
Simply oversampling using the same interpolation technique by some number such as 2^8 is going to get you quite close and is a "quick and dirty" approximation.
You can come up with better solutions once you actually understand the issue.
For example if you insert one impulse per two samples all in the same direction and "1.0" amplitude, the offset = (1/2)integral.
You need to take into account the effects of your interpolation technique if used.
Simply oversampling using the same interpolation technique by some number such as 2^8 is going to get you quite close and is a "quick and dirty" approximation.
You can come up with better solutions once you actually understand the issue.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
- KVRAF
- 12554 posts since 7 Dec, 2004
This may or may not help. If you don't understand the issue in the first place it shouldn't help you.
This is under CC-BY license. "aciddose". "As used in the Xhip synthesizer." Must include a link to xhip.net. Phrasing is up to you but that's the gist of it.
Note this is a horrible, inefficient and inaccurate approximation. This is the "quick and dirty garbage approximation".
You can do far better, although there isn't much reason to unless an offset like 1e-9 bothers you.
This is under CC-BY license. "aciddose". "As used in the Xhip synthesizer." Must include a link to xhip.net. Phrasing is up to you but that's the gist of it.
Code: Select all
float impulse_t::compute_sum()
{
float sum = 0.0f;
for (int i = 0; i < samples; i++) {
sum += data[i];
}
return sum;
}
void impulse_t::compute_offset()
{
float sum = 0.0f;
const float *p = data;
const int simulated_cycles = 4096;
const int il = zero_crossings*oversamples*4;
for (int i = 0; i < samples; i++) {
int index = i * step_size;
ASSERT(index < il);
float phase = 0.0f;
const float delta = 1.0f / float(simulated_cycles);
for (int j = 0; j < simulated_cycles; j++) {
// simulated rate = nyquist
const float simulated_rate = 0.5f - delta;
while (phase < 1.0f) {
phase += simulated_rate;
}
phase -= 1.0f;
const float phase_fraction = phase / simulated_rate;
const float fraction = phase_fraction * step_size;
const int impulse_offset = int(floorf(fraction));
const float v = interpolate(ptr_impulse_data + index + impulse_offset, fraction - impulse_offset);
sum += v * delta;
}
}
offset = sum;
}
You can do far better, although there isn't much reason to unless an offset like 1e-9 bothers you.
Last edited by aciddose on Thu Dec 10, 2015 11:20 am, edited 1 time in total.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
-
- KVRian
- 563 posts since 23 Nov, 2010
- KVRAF
- 12554 posts since 7 Dec, 2004
You also can't patent something that "happens naturally if you use long known methods".
Patents apply to things that don't happen naturally when you use obscure or otherwise unknown methods.
Patents apply to things that don't happen naturally when you use obscure or otherwise unknown methods.
Free plug-ins for Windows, MacOS and Linux. Xhip Synthesizer v8.0 and Xhip Effects Bundle v6.7.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
The coder's credo: We believe our work is neither clever nor difficult; it is done because we thought it would be easy.
Work less; get more done.
-
- KVRist
- 328 posts since 1 Feb, 2005 from Portland
One doesn’t have to be a lawyer to know that it doesn’t matter if the patent holds up in court; the cost of going to court over patent infringement would bankrupt a small developer even if they won. At least that’s how it is in the US.Urs wrote:LOL, that patent is amazing because the list of prior art might exceed the number of letters its written in.
It may increase shareholder value for Korg, but one doesn't have to be a lawyer to see that it won't hold in court.
You can try to be proactive and file for a reexamination of a bogus patent in order to have claims shot down before you infringe. That is much cheaper than going to court, but a quick google search shows that reexamination is still typically well over ten thousand dollars.
I’m not defending the patent, just mentioning that it can be a reason to avoid linear phase BLEP. It was enough for me to avoid it.
- u-he
- 28042 posts since 8 Aug, 2002 from Berlin
Ah, that sucks. If it was an EU patent I'd definitely get it submitted for reexamination.skrasms wrote:One doesn’t have to be a lawyer to know that it doesn’t matter if the patent holds up in court; the cost of going to court over patent infringement would bankrupt a small developer even if they won. At least that’s how it is in the US.Urs wrote:LOL, that patent is amazing because the list of prior art might exceed the number of letters its written in.
It may increase shareholder value for Korg, but one doesn't have to be a lawyer to see that it won't hold in court.
You can try to be proactive and file for a reexamination of a bogus patent in order to have claims shot down before you infringe. That is much cheaper than going to court, but a quick google search shows that reexamination is still typically well over ten thousand dollars.
I’m not defending the patent, just mentioning that it can be a reason to avoid linear phase BLEP. It was enough for me to avoid it.
Furthermore one can just use bandlimited ramps to get the same effect, and those are not covered by the patent. While one needs two of those to cover a step, they're infinitely more flexible.