Cabbage Logo
Back to Cabbage Site

guiMode and guiRefresh

Please, a bit more about guiMode and guiRefresh and identChannels().
I am trying to understand the mechanism of examples Oscilloscope and FFTSpectrum and use them inside a caption of my own.
Console gives me this warning:
Warning: It looks like you are trying to use identChannels() with guiMode("queue"). These are not compatible.

Identifier channels are the old way of updating Cabbage widgets from Csound. If you use guiMode(“queue”) you don’t need to use ident channels. All communication between Csound and Cabbage widgets will happen on a single channel. Many of the examples were developed using the older system, but the new guiMode(“queue”), together with the cabbageSet opcode is the way to go now.

1 Like

I have to dig a little bit… ok.
I would also like to mention that Oscilloscope and FFTSpectrum examples (which generate the table and display it with gentable) are much better aesthetically, they have grid lines, and mouse over shows the frequency… Signaldisplay seems to be less attractive (no grid lines)…

I agree, you can make things look much better with the gentable. On the other hand the signal display widget performs a little better, especially with larger files.

That was a difficult puzzle. :sweat: It took me an eternity to figure out how it works. But I did it. :fireworks:
If you have any comments about the CabbageSet opcode’s kTrig = 1 in my code, please, let me know.

I rewrote the “frequency pop-up” section of the FFTSpectrum.csd file.
The original code:

; Frequency pop-up
 kMOUSE_X  chnget  "MOUSE_X"
 kMOUSE_Y  chnget  "MOUSE_Y"
 if changed(kMOUSE_X,kMOUSE_Y)==1 then
  if kMOUSE_X>1 && kMOUSE_X<609 && kMOUSE_Y>1 && kMOUSE_Y<299 then
   kMOUSEFreq  =  (kMOUSE_X/610) * (11025 * (1024/kFFTSize))
   Spos  sprintfk  "pos(%d,%d), text(%d Hz), visible(1)",limit:k(kMOUSE_X,0,553),kMOUSE_Y-10,kMOUSEFreq
      chnset    Spos,"MOUSEFreqID"
  else
       chnset    "visible(0)","MOUSEFreqID"
  endif
 endif

after changing the form widget’s identifier to guiMode("queue") the above code turn to:

 ; Frequency pop-up
 kMOUSE_X  chnget  "MOUSE_X"
 kMOUSE_Y  chnget  "MOUSE_Y"
 if changed(kMOUSE_X,kMOUSE_Y)==1 then
  if kMOUSE_X>1 && kMOUSE_X<609 && kMOUSE_Y>1 && kMOUSE_Y<299 then
   kMOUSEFreq  =  (kMOUSE_X/610) * (11025 * (1024/kFFTSize))
   Stext  sprintfk  "%d Hz",kMOUSEFreq
   cabbageSet 1, "MOUSEFreqID", "bounds", limit:k(kMOUSE_X,0,553), kMOUSE_Y-10, 60, 13 
   cabbageSet 1, "MOUSEFreqID", "text", Stext
   cabbageSet 1, "MOUSEFreqID", "visible", 1
  else
   cabbageSet 1, "MOUSEFreqID", "visible", 0
  endif
 endif

I think in this case it’s Ok to do kTrig=1 because it’s guarded by a changed() opcode. It could be streamlined, but I don’t think it will affect the performance much.

1 Like