Other waveforms with MinBLEPs ?
-
- KVRAF
- 4737 posts since 20 Feb, 2004 from Gothenburg, Sweden
w00t? you have to add bleps at all steps.
From dwerners (excellent page) "So for a square wave you insert a MinBLEP at the positive and negative edges of either side of the waveform, for saw wave you insert a MinBLEP where the value inverts at maximum amplitude, but you generate the ramp as normal. "
So he does not add a blep at both sides of the discountiuities.
Keep in mind though that you might have to mix in several bleps at the same time. The last "mixed in blep" might not be over when a new discountiuity occurs.
From dwerners (excellent page) "So for a square wave you insert a MinBLEP at the positive and negative edges of either side of the waveform, for saw wave you insert a MinBLEP where the value inverts at maximum amplitude, but you generate the ramp as normal. "
So he does not add a blep at both sides of the discountiuities.
Keep in mind though that you might have to mix in several bleps at the same time. The last "mixed in blep" might not be over when a new discountiuity occurs.
Stefan H Singer
https://dropshotaudio.com/
https://dropshotaudio.com/
- KVRist
- Topic Starter
- 102 posts since 21 Sep, 2004
My mistake... I misread the square wave explaination as adding two bleps for each disc., but I see now that it infact says adding two bleps, one for each disc.
But anyway... I guess it all boils down to how many bleps are neede for a triangle wave and at what position(s) ????
But anyway... I guess it all boils down to how many bleps are neede for a triangle wave and at what position(s) ????
-
- KVRist
- 32 posts since 22 Sep, 2004 from Melbourne, Australia
I wish I did know how to do a triangle with MinBLEPskarmafx wrote: Yes, I visited your site yesterday actually... Looks cool, but it doesn't clarify how to build a triangle wave with minbleps ?!
Do you have code snippet that generates that ?
Eli talks about it in the end of his paper, but does not go into detail.
If you're talking about the MinBLEPs.zip posted on musicdsp.org, I think you'll find for square wave it inserts a MinBLEP at each point the waveform inverts (once at the start of the cycle and once at the pulse width transition). Saw waves only require one MinBLEP where the signal inverts, the ramp doesn't require MinBLEPs. Hmmm... just looked at my page, I guess I wasn't very clear, sorry about that. One MinBLEP per discontinuity folkskarmafx wrote: Also, I'm curious.... in the text you write that you add minbleps on both side of the discountiuity... but (as far as I can see) the MinBLEP code in the archive only adds a single blep. Is the code in the archive wrong, or am I missing something ?
Thanks.
-
- KVRian
- 574 posts since 6 Jan, 2003 from Somewhere between ))o Left and Right o((
Integrate the square wave.dwerner wrote: I wish I did know how to do a triangle with MinBLEPs, I remember thinking about that when I read Eli's paper but I didn't understand what he meant. I might email Eli and ask him about the elusive triangle / bandlimited ramps.
-
- KVRist
- 32 posts since 22 Sep, 2004 from Melbourne, Australia
no_signal wrote: Integrate the square wave.
Integrating the square wave is just like using the BLIT method, you're losing the neatness of MinBLEPs, plus you have to use a leaky integrator because of roundoff error. And I'm not so sure it would support hard sync well. It's problematic, that's why Eli suggests in his paper to use bandlimited ramps to generate triangle.
-
- KVRist
- 37 posts since 27 Jun, 2004 from Berlin, Germany
I am currently using a different anti-aliasing approach, which first calculates the position of the wrapping-point (as in MinBLEPs) but then does not mix something in by adding, but instead the naive waveform is multiplied by a window. The window is simply a cosine function shifted to range 0..1, so what it does is: it starts as value*1.0f, then goes down, forces the signal to zero at the actual wrapping-point and goes up again. It works surprisingly well.
I'd like to try the MinBLEPs and compare the two approaches... is there a ready MinBLEP table available somewhere? I mean, not code to generate the step function, but the actual sample data of the step function. I'm lazy
and you generate it only once anyway, right? Mixing it in later on is easy...
I'd like to try the MinBLEPs and compare the two approaches... is there a ready MinBLEP table available somewhere? I mean, not code to generate the step function, but the actual sample data of the step function. I'm lazy
- KVRist
- Topic Starter
- 102 posts since 21 Sep, 2004
Yes, look at the MinBLEP code in the archive...:travelboy wrote:is there a ready MinBLEP table available somewhere? I mean, not code to generate the step function, but the actual sample data of the step function....
http://www.musicdsp.org/showone.php?id=112
it comes with a pregenerated matlab table.
And that is what I'm using. I would especially be interested in your results at high frequencies...since it seems I'm getting aliasing there... don't know, maybe it's just a bug.
-
- KVRer
- 3 posts since 29 Jul, 2004
I think minblep can be used for any kind of wave, I have no idea how. The important thing is that minblep only works (alias free) on saw/square waves when hardsync.
You can get triangle by integrating the square wave:
triangle = triangle*leaky_integrator + square / (period*duty*(1 - duty))
Note that minblep will not produce an alias free hard sync triangle that way either.
Basically MinBLEP is just BLIT-SWS but he takes it a step further by pre-integrating the sinc. You can get it with a FIR filter and some rceps() but, honestly I had it working and then screwed it up somehow
You can get triangle by integrating the square wave:
triangle = triangle*leaky_integrator + square / (period*duty*(1 - duty))
Note that minblep will not produce an alias free hard sync triangle that way either.
Basically MinBLEP is just BLIT-SWS but he takes it a step further by pre-integrating the sinc. You can get it with a FIR filter and some rceps() but, honestly I had it working and then screwed it up somehow
-
- KVRist
- 37 posts since 27 Jun, 2004 from Berlin, Germany
Here is an audio example of the windowing approach (described above), without any MinBLEPs. It's a short MP3 with a high pitch sequence, first native sawtooth and then with anti-aliasing.
http://www.bitclick.com/linked/NewAliasDemo.mp3
http://www.bitclick.com/linked/NewAliasDemo.mp3
- KVRist
- Topic Starter
- 102 posts since 21 Sep, 2004
Sounds very nice ! I want to try it...travelboy wrote:Here is an audio example of the windowing approach (described above), without any MinBLEPs. It's a short MP3 with a high pitch sequence, first native sawtooth and then with anti-aliasing.
Not really sure I understood your description though.... Exactly where do you apply the cosine window ? On the whole waveform (i.e. per period) or just near the discontiuity or wrap point ?
Some pseudo code would be cool
-
- KVRist
- 37 posts since 27 Jun, 2004 from Berlin, Germany
Not on the whole waveform, just on a few samples around the discontiuity. Place the window so that your cos function is zero at the fractional sample position of the discontiuity. Then experiment with different widths. I found that +/- 2.5 samples is a good value.
By the way: any idea how we can get rid of the division needed to calculate the fractional position?
By the way: any idea how we can get rid of the division needed to calculate the fractional position?
- KVRist
- Topic Starter
- 102 posts since 21 Sep, 2004
I can easily see how this would be applied to saw and square waves, but it is not obvious how to apply this to say a triangle wave... Have you succesfully generated bandlimited triangle waves with this technique ?travelboy wrote:Not on the whole waveform, just on a few samples around the discontiuity. Place the window so that your cos function is zero at the fractional sample position of the discontiuity. Then experiment with different widths. I found that +/- 2.5 samples is a good value.
If I understand you correcly you want to replace an fmod with something faster ? why not just use (float_value - (int)float_value) to get the fraction ? This can be done quite fast in fpu asm.travelboy wrote: By the way: any idea how we can get rid of the division needed to calculate the fractional position?
-
- KVRAF
- 2460 posts since 3 Oct, 2002 from SF CA USA NA Earth
If you don't want to integrate the blepped square to get a triangle, try just integrating the blep itself. You'll need to fiddle about a bit to match the endpoint slopes.
A triangle wave is continuous, but its derivative (slope) isn't; that's what you need to smooth over. An integrated blep should fill the bill.
A triangle wave is continuous, but its derivative (slope) isn't; that's what you need to smooth over. An integrated blep should fill the bill.
-
- KVRist
- 37 posts since 27 Jun, 2004 from Berlin, Germany
I'm using the window method for saws and rectangles. You're right, karma: it doesn't work for triangles. Sorry, I forgot to mention that
I currently use the raw triangles, because aliasing is much less audible on those than on rectangles and sawtooths anyway.
It might be possible to somehow adapt the method for triangles (I haven't thought about it enough), but I suppose it gets more complicated then, and in that case you might be better off simply mixing in a pre-calculated BLEP or whatever. I am quite content with my waves so far, although they are not really band-limited versions of a saw or a square. They just come close enough to sound good enough.
I need to calculate the exact fractional time where the discontuity occurs (I guess that's also needed for inserting MinBLEPs). Let's look at this simple phase accumulator (saw osc):
incr is proportional to the frequency of the oscillator. The second line does the wrap-around which produces the discontinuity. Since the frequency may be modulated (i.e. incr changes all the time), we can hardly predict the wrap-around points, so we just know about them when they happen. I handle them in the THEN-part of the above IF. To calculate the exact position of the discontinuity, I divide the phase by the increment.
Once you know where the discontinuity occured, you can apply the windows (or mix in your MinBLEP). I use a small output buffer (only 2 samples latency), in order to correctly apply the window to the samples before the discontinuity.
It might be possible to somehow adapt the method for triangles (I haven't thought about it enough), but I suppose it gets more complicated then, and in that case you might be better off simply mixing in a pre-calculated BLEP or whatever. I am quite content with my waves so far, although they are not really band-limited versions of a saw or a square. They just come close enough to sound good enough.
I need to calculate the exact fractional time where the discontuity occurs (I guess that's also needed for inserting MinBLEPs). Let's look at this simple phase accumulator (saw osc):
Code: Select all
phase += incr;
if (phase >= 1) phase -= 2;Code: Select all
Example:
old phase = 0.9
incr = 0.4
new phase = 0.9 + 0.4 - 2 = -0.7
0.3 out of 0.4 of the increment obviously took place in the time-slice belonging to the new iteration, so the position of the discontinuity occured 0.75 samples ago in the past.No, I mean the division (0.3 / 0.4 in the above example). Is there an easier method to locate the discontinuity without having to divide?If I understand you correcly you want to replace an fmod with something faster ? why not just use (float_value - (int)float_value) to get the fraction ? This can be done quite fast in fpu asm.
-
- KVRist
- 32 posts since 22 Sep, 2004 from Melbourne, Australia
Another shape you can do that I call TriSquare, which is even easier is to use the integrated blep exactly as you would use the normal blep to do a square wave, and it sounds quite different.Borogove wrote:If you don't want to integrate the blepped square to get a triangle, try just integrating the blep itself. You'll need to fiddle about a bit to match the endpoint slopes.
A triangle wave is continuous, but its derivative (slope) isn't; that's what you need to smooth over. An integrated blep should fill the bill.



