Hi Everyone,
I have a few questions about passing real-time events to Csound from Openframeworks/C++.
Setup -----------
Apple Silicon
Openframeworks / C++ compiled in XCode
Csound-MacOS-universal-6.18.1
installed from DMG / not homebrew.
Compositional Context -----------
. I’m working on a large, very public, real-time data visualization piece that opens next month.
. From within my application, I will be passing score events to Csound for real-time, keyframed sound design.
. I am writing launchd scripts to start and exit the openframeworks app at the same time everyday
. My openframeworks app will launch and close csound.
. It will be running for several months, all day long.
. I will not be there in person to oversee it.
Technical Context -----------
For reasons I won’t bore you with, I was unable to get the csound performance thread working in my system.
It is some combination of lack of sleep, super tight deadlines, library binding issues, and reaching the boundary of my knowledge.
(I would, however, like to revisit this issue with you all in the future because I’ve long used the performance thread in Java/Processing and would really love to use it in openframeworks projects. I want to learn how to do that successfully. )
I developed two workarounds:
(A) Openframeworks – OSC → Csound
Straight-forward. On startup, Openframeworks launches Csound using a posix_spawnp(); passes messages over a udp port; the CSD has a continuously running listener instr. I’ve worked in a similar way on other projects with Java and with Max and it’s been predictable. But I’ve never had to run it for a long time unattended. What concerns me with this version is that, for a while, quitting the app would hang and I would have to hard quit Csound from the terminal. I’ve now written a hard kill function in my app’s destructor. It seems to solve it, but I’m still cautious.
(B) Openframeworks – popen() → “-L stdin” → Csound
Looking more into POSIX. My app launches Csound with popen(). It’s a separate thread, open-loop / no feedback. I pass score messages to csound after setting the flag “-L stdin.” It works. It works better than I thought it would. It feels very light and useful but I’ve not encountered discussions about using csound in this way and that makes me a bit cautious. At the moment, I’m preferring this method because it never crashes at shut down. But also, I’m completely unfamiliar with its “coffin corners.” Is there anything I am missing?
The TL;DR Technical Question ---------
Given the context of this piece, can you spot any red flags about these two approaches? Are there things I should look out for? Is there something I’m doing that works fine as I prototype but that will bite in the butt when I try to scale the duration, etc? I’m scrambling to finish this on time and would like to not be caught off-guard.
I know this was a long email. I’m hoping a few of you might have the time to consider it. It would be a huge help!
Very best
Robert
Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here