# Creating an Oscilloscope

**URL:** <https://forum.juce.com/t/creating-an-oscilloscope/17902>\
**Category:** General JUCE discussion\
**Created:** [May 31, 2016, 12:15am UTC](https://forum.juce.com/t/creating-an-oscilloscope/17902 "2016-05-31T00:15:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![timart](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timart/32/1119_2.png) [@timart](https://forum.juce.com/u/timart)\
**Post date:** [May 31, 2016, 12:15am UTC](https://forum.juce.com/t/creating-an-oscilloscope/17902/1 "2016-05-31T00:15:15Z")

</div>

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: [https://www.youtube.com/watch?v=boPEO2auJj4](https://www.youtube.com/watch?v=boPEO2auJj4)

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:  
[https://www.dropbox.com/s/ng1720mb215tz8f/Oscilloscope.m4v?dl=0](https://www.dropbox.com/s/ng1720mb215tz8f/Oscilloscope.m4v?dl=0)  
(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.

Thanks.

---

<div class="post-metadata">

**Author:** ![timart](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/timart/32/1119_2.png) [@timart](https://forum.juce.com/u/timart)\
**Post date:** [June 10, 2016, 2:00am UTC](https://forum.juce.com/t/creating-an-oscilloscope/17902/2 "2016-06-10T02:00:38Z")

</div>

I found a great example in the JUCE forums after further searching.  
@dave96 has an open source module on github called dRowAudio.  
Link here: [https://github.com/drowaudio/drowaudio](https://github.com/drowaudio/drowaudio)

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!

---

<div class="post-metadata">

**Author:** ![dave96](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/dave96/32/8487_2.png) [@dave96](https://forum.juce.com/u/dave96)\
**Post date:** [June 10, 2016, 8:48am UTC](https://forum.juce.com/t/creating-an-oscilloscope/17902/3 "2016-06-10T08:48:01Z")

</div>

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.
