Cabbage Logo
Back to Cabbage Site

FM Synth

Hi all,

This is my 1st Cabbage Instrument, would love input or advice from anyone.

There are a couple of things I’d still like to add to it, however, at the moment, the CPU is blowing out after about 30 seconds whenever I play a lot of notes in succession. I’d love any feedback or advice on how to make the code more efficient. I’m neither a coder nor a mathematician, and only a few months new to CSound - so I’m sure I’ve done more than a few silly things here.

FM_TEST_8:12:18.csd (45.7 KB)

Presets please :slight_smile:

FM_TEST_8:12:18.csd (45.9 KB)
FM_TEST_8:12:18.snaps (21.0 KB)

The interface is too big to show on my laptop screen. I’ll try once I have access to a bigger screen.

From what I can see, to make a big improvement in the performance of your code you can do at least two things:

  1. set the ksmps value to 256. That means 5.8ms of lag when you click on a note, that is still perceived as an immediate response by the human brain, but it will decrease the stress very much on your CPU.

  2. get rid of all those if/then/chnset at the end of your instrument:

    if (kalgorithmselect == 5) then
    chnset “outlinecolour(0,128,0)”, “Op2LFOGUI”
    chnset “outlinecolour(0,128,0)”, “Op2GUI”
    chnset “outlinecolour(0,128,0)”, “Op2 EGGUI”
    chnset “outlinecolour(0,128,0)”, “Op2TimeGUI”
    chnset “outlinecolour(0,128,0)”, “Op2CurveGUI”
    chnset “outlinecolour(0,128,0)”, “Op2LevelGUI”
    chnset “trackercolour(128,0,128)”, “LFOMode2RateGUI”

I don’t know for what they are, but if I remove them the max polyphony increases.

Then I think you could try to make many k-time variables in i-time variables, so that they are computed only once.

1 Like
  1. set the ksmps value to 256. That means 5.8ms of lag when you click on a note, that is still perceived as an immediate response by the human brain, but it will decrease the stress very much on your CPU.

Thanks for that, I haven’t had time to work on it the last day - but tried this quickly this afternoon and it made it much more usable! Appreciated.