Cabbage Logo
Back to Cabbage Site

Csound code efficiency

Hi all,

Is there a document around for optimizing the performance of our code specifically for csound ?
just some guidelines like this:

regards,

Yorick

No, at least none Iā€™m aware of. It would be nice, although, itā€™s much harder to write completely inefficient code with Csound than C/C++. The biggest issue I see with Cabbage code is users calling cabbageSet on each cycle. Thatā€™s a performance red-flag every time.

2 Likes

I try to trigger code as conditionally as possible. Here are some things Iā€™ve started doing that have improved the performance of my plugins:

  • Use changed2() to trigger cabbageSet
  • Use the kTrig from cabbageGetValue
  • Trigger instruments with event
3 Likes

Is using a kTrig to a cabbageSet statement like an ā€˜ifā€™ where the statement would be ignored entirely ?
The only issue I had with this is that double-clicking a widget to default value doesnā€™t get detected by the trigger, so I had to enter ā€˜1ā€™ as kTrig for it to work at the moment.

It should get picked up if the widget isnā€™t at its default value?

Recently started doing kTrig at ā€œcabbageGetValueā€ simply for using less lines.
There was no ā€œchanged2()ā€-version for kTrig at cabbageGetValue-statement, which would have been nice though.
Havenā€™t had much need so far for event statements.

Thanks for adding your tips !

I used 2 widgets representing the same value, which both used a trigger to update the other.
When I double-clicked 1 of them, I do an opcode to get a derived value from the main value for the other widget.
Using kTrig, it gets triggered but doesnā€™t give the right value most of the time.
It only works every time when I remove the kTrig.

Could you prepare a small example of this?

As @hdale94 suggests, a minimal example of the problem would be most helpful. Thanks.

Hmm,

Not gonna work
The problem disappeared in a stripped down version ā€¦ :thinking:
Iā€™ll take a look at it when I have time,
thanks anyway.

rgds

1 Like