GUI solution for command line controlled program

Hello everyone,

I’ve written a Csound program in which I use the sensekey opcode and the command line (Terminal in MacOS) to input character commands on the keyboard that control the program in real time. I like this sensekey/command line approach because 1) it’s a constraint that keeps things simple and 2) I don’t have to hit Return in order to enter the commands.

I’d like to build a GUI that will display the current state of the program (e.g. parameter values, currently selected tracks, etc) to the user. The user won’t be interacting with the program through the GUI, just looking at the visual state of the program. The actual interaction should only be done through the command line with a keyboard to keep things direct and simple.

Can you give me suggestions on what technology I could use to build this GUI and have it connect to the instance of Csound being controlled through the command line? Or maybe instead of using the command there’s a way to simulate the sensekey/command line functionality? I imagine there could be many ways to accomplish this. I’m open to any ideas, even if it means rethinking my current approach, although I’d prefer to use vanilla Csound rather than Web Csound for this project. I’m on MacOS 10.15.6.

Thanks!
Jason

Hi!

The are really many ways to do that. The simplest way to use UI experiences is to to use Cabbage or CsoundQt? Otherwise - what programming language are you familiar with? It is definitely worth to explore Eduardo Moguillansky’s python based CsoundEngine that has support for also creating some widgets:
https://github.com/gesellkammer/csoundengine

I think this could be possibly the quickest start.

Greetings,
tarmo

Kontakt Jason Hallen via The Csound Community (<noreply@forum.csound.com>) kirjutas kuupäeval E, 11. oktoober 2021 kell 23:09:

I’m not sure about CsoundQT, but Cabbage has a texteditor widget that you can parse input text from. If you wanted to implement something from scratch, JUCE , QT or wxWidgets would probably work well. And there are already examples of Csound’s use in these frameworks. There is also GUILite which I’ve wanted to try out myself for some time. A header only cross-platform GUI framework. Sounds enticing…

Thanks, Tarmo and Rory! I’ll look into CsoundEngine and GUILite first. The Cabbage texteditor widget is pretty close, but I’d like a solution where I can type in single characters and have Csound immediately respond without having to hit the Return key. That’s what makes this program feel like an immediately responsive instrument.

I suppose the crux of my question is, can I both control a Csound performance through the command line using the sensekey opcode and simultaneously send the Csound performance data to be displayed in a GUI? I’m familiar with more traditional uses of GUIs to display and control Csound, but this aspect of the controlling Csound via the command line is the part I’m just not sure how to do in tandem with a GUI. Just wondering if someone already knew the answer and could point me in the right direction. But I’m going to look into the platforms you suggested to see if the solution is in there.

Thanks!
Jason

I think it would be easier to run a GUI app that interrupts all key presses and uses this data to update the GUI, if you need a GUI that is. I’ve built entire command line systems for Csound that use only the terminal and sensekey.

When you say “run a GUI app that interrupts all key presses and uses this data to update the GUI”, is this what you’re suggesting?

  • The GUI itself listens for key presses
  • When a key is pressed, the GUI immediately sends the key value into Csound via a control channel
  • Csound gets the value from the channel and responds accordingly
  • Csound sends any updated program state to the GUI for display

That’s actually what I had been doing with a program I built in Web Csound and p5.js earlier this year. It just got bogged down in performance issues, so it made me leery about using a GUI in that way. However, maybe working with Python and native Csound rather than within the web framework will perform better. I’ll look into it.

Technically, I don’t NEED a GUI for this program, but the complexity of this particular program is such that it would be extremely helpful to have a visual depiction of the program state. There are a lot of samples, buffers, and loops to keep track of.

Thanks for your guidance!
Jason

Yeah. That’s it. you can bypass the last step by simply getting the GUI to respond to the keypress directly, if it’s always going to be the same, for example, press A and the screen turns red, or whatever.

That definitely shouldn’t happen when running Csound on a desktop.