Cabbage Logo
Back to Cabbage Site

Oscilloscope for dummys

Hello everybody!

I feel a bit stupid, because i don’t understand the oscilloscope example.
Can someone help and describe in plain english how to create a oscilloscope in cabbage?
Just the steps and i will try to figure it out on my own.


Take a look at the SignalDisplay example from the widgets example menu. That’s a little simpler. Also, I wrote it, so if you have any question specific to how that works let me know :slight_smile:

Thanks! That was easy to get.

But now i’m missing the flexibility of the oscilloscope example. I tried to make the SignalDisplay a little bit more felxible, but my reinit pass is not working and i can’t figure out why.
Maybe someone else can check this out.

   ;; oscilloscope
  aScopeIn = aOut
  kDisplayPeriod chnget "displayPeriod"
  if metro:k(5) == 1 then
    kTrig changed kDisplayPeriod
  if kTrig == 1 then
  iDisplayPeriod = i(kDisplayPeriod)
  display aScopeIn, iDisplayPeriod, 1

And the complete file:
gendy-cabbage.csd (5.4 KB)

The problem is that kDisplayPeriod is 0 at init time. That’s because its value is updated during the performance rather than initialisation. Consider this instrument:

instr 2
    k1 = 1
    print i(k1)

It will print 0 rather than 1 as the k-rate assignment is done at performance time. The simple fix for your code is to add a tiny number to the iDisplayPeriod so that on the first pass, when kDisplayPeriod is 0, it will still have a valid display period,

display aScopeIn, iDisplayPeriod+0.001, 1

After that you can update the period as you wish. :+1:

Thank you very much! This was an unexpected…

But now, working with the parameters of display, i don’ get to the results i would like to see. I have to check the Oscilloscope example again for a more flexible oscilloscope.