Creating an Oscilloscope


I’m new to JUCE and am trying to create a simple oscilloscope, very similar to the one demonstrated at 14:01 in this JUCE Cpp Con presentation:

I already have a sine wave generator implemented.

My oscilloscope class inherits from AudioIODeviceCallback so it can receive audio data generated by the sine wave, and from AudioVisualiserComponent to do some of the drawing for me.

The only problem is, I’m having trouble displaying the waveform in a similar way to the video. When I use the AudioVisualiserComponent to show the waveform, I can get close to a good, zoomed in, waveform representation by adjusting setSamplesPerBlock() and setBufferSize(), but the wave looks sharp like it is made out of triangles instead of smooth like a sine wave. I think this is because of the way AudioVisualiserComponent paints the audio data, so I’m going to try to override its paintChannel() function.

Here’s a dropbox link to a screen/audio recording of the program I have so far:
(the sine wave’s frequency is being controlled by an invisible frequency ribbon triggered by mouse events)

There seems to be alot of sharp triangle shapes in this visualization at times, which is not what I want.

Does it seem I am moving in the right direction with this?
Does the AudioVisualiserComponent seem fit for this kind of oscilloscope implementation?

I also realize that oscilloscopes are not just audio scrollers, but will keep a certain number of cycles visible in the viewport, so I’ll have to deal with that as well.

If anyone has made something similar to this before, any kind of explanation would be helpful.



I found a great example in the JUCE forums after further searching.
@dave96 has an open source module on github called dRowAudio.
Link here:

It’s been a great learning tool!
The only problem I had when firing up the demo project on my machine was that it originally used an older version of the Projucer, so I just started a new Projucer project and copied the demo source code. I also had problems with my computer working with the cURL library in the demo, so I just disabled that stuff in the module.
Besides the minor problem of the demo project on my machine, the module integrates easily.

Thanks Dave!


Thanks! Glad you like it.
I’ve been meaning to update the module format to the new JUCE 4 version but sadly haven’t had time yet.
Hopefully soon.