I have just made a github repo public with the code necessary to build/run a plugin called Deviant, which is a distortion effect. It utilizes the CMake API offered by JUCE to build VST/VST3/AU formats on Windows/macOS.
Below are more details/intentions related to the code for those who may be interested:
In “processBlock”, each buffer is sent to either membersF or membersD, which are member variables of the plugin, templated on float or double, depending on the precision currently used. From here, a double buffer of a size known at compile time (256 samples) is filled. When the write buffer is filled, those samples are processed and the read/write pointers are swapped. The samples are written back to the “processBlock” buffer as needed.
Unfortunate as it may be, as a delay is incurred, I’ve found that there are many benefits for double buffering, the pivotal reason being the bit-crushing algorithm. When the signal level can be obtained prior to processing, the bit resolution can be controlled and, when the reduction is high, dropout of low-level signals can be avoided. I’ll also tell you that I’m not happy with the sound of the Deviant crusher and I’ll be working hard to get it right.
For each distortion style there are two small (4 sample) FIR filters, one pre-waveshaping, one post. They can be exposed in a right-click menu.
There are a bunch of distortion algorithm styles that can be engaged in the plugin, each of which is represented by a struct with two methods named “processSample” and “calculateCoefficients”. These structs then represent a template parameter for each specialization of a “SadisticEffect” class to be instantiated.
Before the samples are processed a copy is kept, and after the samples are processed, the dry and wet copy are both sent to the oscilloscope. It is implemented with a derived version of JUCE’s OpenGLRenderer class. The OpenGL graphics are rendered in back of all the other juce::Components.
Let me know if you have any insights.