I’m a JUCE newbie. After working in audio software for some time I finally got around to starting a plugin of my own. One thing it needs is a scrolling waveform display similar to the one seen in GRM Tools “Freeze” effect. Of course, code for one was nowhere to be found, so I thought I’d be the one to put it out there.
I’ve tried to make it as simple as possible, yet accurate and thread-safe (i.e. uses locks). The basic idea is to specify a buffer size and calculate the number of samples per pixel (which of course depends on the width of the compnent). The plugin audio proc counts up to this number of frames and keeps track of the abs min and abs max in that block. It then pushes those values onto a stack for the UI to pick up when it needs to draw. The UI has a timer which, on a constant refresh interval, takes the lock that protects the stack object and quickly pops all the values off and passes them on to the waveform display. Then the lock is released and the display is invalidated (now the display has a stack of min and max samples). The longer the timer interval, the more samples will be on this stack, and the more jerky the display will be (it is constantly scrolling, after all).
The demo projects (VC8 for Win VST and XCode for Audio Unit) will build a demo plugin with the display and controls for the buffer size and refresh interval. The projects are set up to expect the vstsdk and JUCE to be in the same dir as the zipped folder.
You will see that there is a tradeoff between refresh interval and CPU consumption, but I am happy to report that my tests have shown that a reasonable refresh rate doesn’t look too jerky and isn’t too bad on the CPU.
I hope you all have a chance to build this, test it, give me feedback, and (this would be a real honor) change some things and send it back my way. There are definitely some flaws, but I need to get on to other parts of my plugin. I’m sure with some collaboration this thing can be very ‘pro’.
All the best,