Hey all. I’m working on my first audio plugin with JUCE, building a pretty simple waveshaper almost exactly like Image Line’s Fruity Waveshaper: https://www.image-line.com/support/FLHelp/html/plugins/Fruity%20WaveShaper.htm
The idea is that for each input sample
x, the output sample is
f is a function from [-1,1] to [-1,1] defined by whatever curve the user draws in the graph.
I’m building this with a lookup table with 1024 elements as a
std::vector<float> on my main AudioProcessor so that my output loop can essentially just write
output[i] = table[floor(input[i] * table_size)] (maybe with some kind of interpolation). This member is public such that my PluginEditor component can read the values to draw the curve and also write new values back to the table as the user draws in the graph.
My concern is about reads and writes to the same vector from the GUI and the main DSP loop, but I don’t know what the best solution is. I obviously don’t want to lock in the dsp loop, so that kind of approach seems like a solid no. Maybe redraw a new 1024-sample vector on every mouse interaction and then atomically set the AudioProcessor’s pointer to the new vector? That seems like it could be resource heavy if I’m constantly making and throwing away vectors. So I’m really not sure here.
If you have any advice or ideas, I’d love to hear your thoughts! Thank you!