Cabbage Logo
Back to Cabbage Site

Flickering!

I have customized the FFTSpectrum.csd example, removed all unnecessary commands and used guiMode("queue") successfully. I experience a strange flickering problem. The fft spikes on the display flicker! I suggest that the problem is related with csound internal triggers because it happens when signal’s amp and freq come from MIDI, for example

 aSig vco2 p5, p4

On the other hand, FFT spikes are steady when I set them up numerically in the orc section, for example

 aSig vco2 .7, 220

Here is a copy of all significant commands

<Cabbage>
form caption("FFT Spectrum"), size(610,570), colour( 50, 50, 50), pluginId("spec"), guiMode("queue")
gentable outlineThickness(1), bounds( 0,  0, 610,300), tableNumber(1), tablebackgroundColour("white"), tableGridColour(100,100,100,50), tableColour(0,0,200,200), channel("ampFFT"), ampRange(0,1,-1), outlineThickness(0), sampleRange(0, 512), zoom(-1) 
</Cabbage>
<CsoundSynthesizer>
<CsOptions>
-n -d -+rtmidi=NULL -M0 --midi-key-cps=4 --midi-velocity-amp=5
</CsOptions>
<CsInstruments>
ksmps = 32
nchnls = 2
0dbfs = 1
;...
instr 1
;...
; signal generation
 aSig vco2 p5, p4
;...
 if  metro(16)==1 then
  kflag  pvsftw fSig2, iampFFT
 endif
 if kflag==1 then
  cabbageSet	1, "ampFFT", "tableNumber", 1	; update table display
 endif
;...
endin

</CsInstruments>
<CsScore>
;causes Csound to run for about 7000 years...
f0 z
i1 0 [3600*24*7]
e
</CsScore>
</CsoundSynthesizer>


Can you post a working example that illustrates the problem?


Allow me to upload a short video for today demonstrating the problem.
(a bit frustrated and rushing… the flickering part doesn’t last long. My ubuntu laptop crashed while recording twice…)

I’ll test some ideas before posting the code.
ifreq init p5… etc, still produces flicker
store values to a cabbage widget and get them from there is another idea for tomorrow.
M.

test_FFT_solved.csd (3.1 KB) test_FFT.csd (3.1 KB)

I found a workaround. Can you explain it? Please? I’m afraid it is a Cabbage related issue.

test_FFT.csd flickers.
test_FFT_solved.csd flickers not!
Their difference is in the score!
i1 0 z flickers!
My solution was to add a dummy note i1 0 2 220 .01 after which the keyboard notes’ (either from virtual keyboard or real MIDI keyboard) FFT analysis is displayed as expected.

(PS: Sounds are also audible. You have to turn the Audio gain rslider.)

I suspect the issue is that in test_FFT.csd instrument 1 is always on, even if you are not playing any notes. So when you play a note, the two instances compete to display the spectrum. I believe this is the problem, although I’ve not had a chance to look over the code in much detail. I’ll be back to all things Cabbage tomorrow, I can take a deeper look then if you’ve not figure it out. :+1:

A score without an i1 statement does not activate the instrument. I need an i1 statement. I discovered that the score statement i1 0 0 220 0 also works. The FFT is displayed correctly.
I have no further experience to say when the program terminates after this command.
It seems that it continues and expects a midi note. For how long, I don’t know.

It does, and it’s expected because the instrument is being triggered via MIDI. You can both hear the results, and see them in the output console. However, for some reason the FFT is not displaying. I haven’t had a chance to see why, but I have a feeling you have it figured out before I do :slight_smile:

1 Like

The csound is activated, ok. This fft needs the instrument and this cabbageSet message to show something. But I would like to know when the gentable widget is activated. When the grid lines are drawn?
f0 z is not enough to see the grid lines.
My experiments showed that the instrument seems to be activated from the note on message till the note off + release time. This is the period that the mouse over routine works. Grid and spikes of the display remain after the instrument is idle.
Then I tried to experiment with a command i1 0.5 2 220 1 Well …( :drum: :drum: :drum:) … the mouse over works from t=0.5 to t=2+release time, but the FFT display is empty. No grid lines, not nothing. Not before the command, not during the command (it is executed, console says), nor after! :thinking: :face_with_thermometer:

It might be best to put the fft display stuff into an instrument that is always on, and then pipe the audio to it using named channels.

1 Like

Do you mean
connect alwayson outleta inleta…

No I mean start it in the score with a z or extremely long duration, and then send audio to it using chnset/chnget…

1 Like

This solution leads to a different problem.
When FFT display is part of an instrument listening to the midi port, it seems that pvs opcodes stop working as soon as the noteoff message is received.

I tried an always on FFT display instrument. I was able to chnset and chnget the audio signal, but I could not control when to stop. The FFT display instead of freezing at the last (correct) pvs analysis, it continues to receive audio signal with undesirable effect.

I tried to control with the following code

 koff release
 if (koff!=1) then
  chnset aSig, "FFT" 
 endif

but it did not work. Not sure what can I do…

No, that’s not quite what I had in mind. I was thinking more along the lines of:

instr 1
   a1 oscili p5, p4
   outs a1, a1
   chnset a1, "synthOutput"
endin

instr 1000; //start in score to run for a long time..
   aSig chnget "synthOutput"
   //do FFT with this signal..
endin 

That should do the trick :+1:

This is what I did. But when noteoff message arrives, the fft continues.

When the FFT is inside the instrument, it goes like this:

This is the desired result, which I cannot get. That’s why I said, I cannot stop chnset optcode.

Ah, you need to use chnclear in your fft display instrument to clear the channel…

Thank you!!! :heart_eyes:
I didn’t know that. (In fact, I learned tooo many things :man_student: by this conversation). It is time to stop this thread, and move on!

Now the FFT display fades out (because of the smoothing).
chnclear works both ways:
a) Either at the end of the FFT instrument as you suggested, or
b) in the sending instrument, like this:

 koff release
 if (koff!=1) then
  chnset aSig, "FFT" 
 else
  chnclear "FFT"
 endif

The advantage of (a) is that the FFT works during the release time.

1 Like