Cubase send toggled instrument folder back to OSC button

Hey, folks!

I was wondering how/if it was possible to have a toggle button that opens an instrument folder in cubase (which I can do fine) but also receives in OSC when the instrument folder is open or closed in Cubase. I've managed to get transport controls and faders to send their states back to OSC but I think this is a bit different. I'd like to be able to easily see what folders I have open and closed at all times if possible.

Thank you!


The only thing I can think of is not a perfect solution to your question.

There is no way when opening a session in Cubase to have Cubase send to Cubase updates on which folders are open/closed. You can however as a workaround, save JSON data to remember which is closed and which is opened. So in theory it would work as the following:

  • Save a JSON data file in your local storage, for the session you're working on.
  • As you open/close data folders, have OSC save that information to the JSON file.
  • Next time you load the Cubase session, have OSC recall that JSON file.

In other words, as the Cubase session opens/closes, you can have OSC watch and load/save a JSON file that corresponds with the session you're working on.

Perhaps there is another solution I'm not thinking of that someone can chime in with. As well, hopefully, Cubase 12 API will be updated soon with some more goodies for us to use with OSC.


1 Like

Hey there! Thank you for the reply! I've never considered this solution!

I defintely don't need it to learn from the folder names as this is to go with my orchestral template which will have very specific and pre-set folders that I would need this to work with. (Woodwinds, brass, strings, etc)

I'm curious about this method, but I sadly have very little coding knowledge. What kind of scripts need to go into these JSON files if you dont mind explaining a little further?

Thank you again for your reply!


It feels like only yesterday I was on this forum, and I too knew very little about coding. I definitely have to thank OSC as it gets you motivated to learn coding to take your OSC to the next level.

Saving JSON
If you're getting the values already from the folder(s) toggles you created, on the widget, you could use the OnValue to send the value to an address of your choosing.

// value is a local variable that grabs the current value of the widget
// id is a local variable that grabs the current id of the widget
send("/testing", {type: "s", value: {value, id}})

In your custom module js file, under the method oscFilterOut in the module.exports, you'll need to listen for your custom address, to grab that data, and save it to your JSON file using saveJSON.

// Filter outgoing osc messages
const { address, args, host, port, clientId } = data
if (address === "/toggleFolderAddress") {
    let value = args[0].value.value
    let nameOfFolder = args[0]
    let saveToggleValue = {}
    saveToggleValue[nameOfFolder] = value

    // saveJSON(pathToYourJSONFile, dataObject)
    saveJSON("./toggleFolder.json", saveToggleValue)

In your custom module, at the start of the session, you could load the json data into a variable to use. Then for each id saved, you could send a receive to the value of each widget.

app.on("sessionOpened", () => {
   let toggleFolderJSON = loadJSON("./toggleFolder.json")

    // iterate over each key value pair in the object
    Object.keys(toggleFolderJSON).forEach((key) => {
      let id = key
      let value = toggleFolderJSON[key]
      receive(`/${id}`, value)

Then at the start of your OSC session, the values will be read from the JSON file, and sent to each button.


Thank you so much again for responding and for your detailed walkthrough of your code. I think i understand to a degree what you're suggesting and I'll be sure to try and see I can get it working.

Really appreciate your help.

1 Like