Open Source - square waves for the juceplugin

Just a quick open source project to share.

This one adds minBlep antialiased square / triangle / sawtooth and hard synced sine waves to the juceDemoPlugin.

minBleps are a method for constructing real time, band limited waveforms. It’s somewhat technical, so there is a blog post below that goes into detail about the method.

Github project:

Blog post on the subject:

4 Likes

thank you! looks great.

It looks like there’s a dc offset on the blep in the juce synth - ?

If you start skewing the waves (similar to PWM duty cycle), you can indeed get shaped saw and triangle waves with DC offsets. In my synths I add a simple DC filter to remove this, and would advise doing so if you use this in a synth. Thanks for pointing that out, I had meant to mention it

Aaron - just started reading the code to see what you are doing here.

So, I think I’ve got this right:

WaveGenerator::buildWave is the core of things. It does two different jobs:

• Calculates based on the position through the waveform (aka the skewedPhaseAngle) where the bandlimited steps will need to be inserted.
• Inserts into the output buffer the non-bandlimited version of the waveform.

Then the calling function mixes the potentially overlapping bandlimited steps into the output buffer?

All this, I think, requires some prior knowledge of where the bandlimited steps are needed. Did you have a solution that worked for arbitrary wavetables?

Thats basically correct.

In the audio thread we run MinBlepGenerator::processBlock() - from the buildWave function in waveGenerator, which pulls the next buffers worth of blep based corrections, and adds that to the naive wave.

There are other functions in minBlep - rescale_bleps_to_buffer() - that can be used for bleps that are known to occur but the nature of the discontinuity (the scale of the 0th and 1st order isn’t known and has to be calculated from the incoming audio). This is the case for things like a sawtooth flanger, or skipping around in an audio buffer.

Also - note the MinBlepGenerator::setLimitingFreq() function - which is used to rescale the minBlep array limiting frequency, effectively controlling the harmonic depth of the waveform (how many higher frequency components we are allowing).

1 Like

Thanks for the examples Aaron, and good to meet you at the conference. You mention open source but there’s no license info in the GitHub repository. Any chance of a clarification?

Yeah, I consider this just example-ware. Feel free to use it in any way you like, no need to worry about the license. I’ll drop something in there to that effect soon.

1 Like

Hi Aaron!
I am trying to compile your code but is throwing me Undefined symbols for architecture x86_64 errors. Do I need an specific version of JUCE for compiling this?