I’m developing a plugin for Bidule using their sdk that basically is integrating an instance of Csound api, and will be able to compile any valid orc code that is entered into a text box in the gui.
What’s the standard practice to recompiling orc code using the cpp api, when an instance of Csound is already running?
I have set up the initial orc (and sco) code in the init() method in the plugin, that works fine, but when I recompile some (valid) orc code that replaces the same instr 1, I get some nasty, loud glitchy output and the whole instance basically crashes and eventually brings down Bidule.
Is there a special order to doing this within C++?
I’m not using compilestr or any of the Csound opcodes for this - only within C++
This is the general idea:
// gets called when a button is pressed.
CsoundTest::recompileOrc() {
if (_recompileTrig == 1) {
// csound->Reset(); <- does this need to be called at all?
_csCompileResult = csound->CompileOrc(templateOrc.c_str());
if (_csCompileResult == 0) {
csound->ReadScore("i1 0 4 220"); // <- restarts a new instance of instr 1
}
_recompileTrig = 0;
}
}
It’s not pretty, but do the job. I had issues with some resources not being freed when calling csound->Reset(), which would in turn lead to other issues.
Probably could is that’s what is actually being passed to compileOrc. Sorry, I only noticed this message now. For some reason I don’t get notified of reponses…
Haha is ok! i think there is some notification button somewhere that gets auto-checked when you are the author…i dunno. Notifications sometimes do, sometimes don’t work…
In the end I decided for simplicity to pass the path to a .csd, and compile that instead. The code editing ui facilities within Bidule is somewhat lacking, so prob best to leave that to a dedicated editor for now. But I may circle back to this when I have it all working how I want, but I suspect that is a can of worms.
also does there need to be a period of time between destroying the instance of Csound, and then recreating it? probably something in my code, but I get a message from Csound saying: Csound is already started, call csoundReset() before starting again. Makes me think is “it” being called twice… it being csound->Start()?