Cabbage Logo
Back to Cabbage Site

Converting from FLTK to Cabbage

So, I’ve found an instrument that I think might be useful to learn from. It is an instrument from Iain McCurdy’s collection. Only trouble is, it is stitched together using FLTK, which seems extremely bloated with code for the interface.

Is there an easy way to strip out the FLTK code and replace it with Cabbage? I’m figuring that Iain’s code would be great to learn from…

There is no easy way, but on the other hand, @iainmccurdy has ported many of his FLTK instruments to Cabbage over the years. If the same examples isn’t available in Cabbage, I’m sure there is something comparable. What example were you looking at?

Thanks for tagging Iain. I’m trying to figure out how to implement a “mono” mode for my synth, and he’s got a couple of examples that I was thinking of translating.

I think many of his Cabbage synths also have a mono mode. His gBuzz synth for example has a mono/poly button. While Csound excels in its support for out of the box polyphony, monophonic instruments are a little trickier to build. I borrowed some code of Iain’s I had lying around for the discussion here. It’s probably not as good as what he has used in his Cabbage instruments, but it might be a good starting place.

Attached is a simple template of my current approach.
MonoSynth.csd (1.4 KB)

It’s basically a combination of:
massign to send all notes to instr 1
active (i-rate version) to test if this is the first note played in instr 1
instr 1 can play multiple notes, instr 2 only one
active (k-rate version) in instr 2 to check if all MIDI notes have been released, reflected in the number of active instances of instr 1

It uses a feature of a global variable in multiple playing instances of an instrument in that the most recent instance will determine the actual value of that global variable received in other instruments. This feature means that the last note played will determine the pitch of the monophonic synthesiser.

Things can get a little more complicated if instr 2 uses a long release time and you may want to make adjustments. release can be used to test whether an instr 2 is in its release stage and then use that to determine conditional behaviour.

1 Like

Thanks Rory and Iain!

@iainmccurdy, I’ve finally gotten around to work with this, but now that I have, I am wondering how does the noteoff get triggered that occurs when all of the notes are turned off? Using this as you have it, for me the note keeps playing. Do I need to watch for noteoff events and then trigger a turnoff message to the playing voice?

OK, sorry… I found the turnoff message in the second instrument… It’s already going to be a long day, and I just woke up…