SynthDef Argument posting function

Hello!

Since I have quite many custom SynthDefs and it's hard to remeber all the custom arguments for a SynthDef I'm wondering if there is some way to query the SuperCollider server via OSC to return the arguments of a SynthDef.

I know that if I stored a SynthDef in a global variable x, then I can use

x.allControlNames; 

to get an array of ControlName objects for which i can use the .name method to get the parameter name.

What I don't know how to do is how to query a running server for a specific SynthDef that is loaded on that server.

I found this document in the SC reference:

the /d_recv looks promising, but I don't know how to use this. Can anyone help?

I made a little progress, but one final piece is missing and I hope someone can help me out here (it's more tidal related this time). I've found a way to send all control names of a synth from supercollider to tidal every time SC recieves an OSC message to the path /SynthControls with the name of the synth as argument. This is the SC code for the OSCFunc:


(
OSCdef.new(
	\SynthControls,
	{
		arg msg, time, addr, port;
		var controls, controlNames, name, address, synth;


		address = NetAddr.new("localhost", 6010);

		name = msg[1].asSymbol;

		synth = SynthDescLib.global.at(name);

		controls = synth.controls;

		controlNames = msg[1];

		controls.do{arg control; controlNames = controlNames ++ " " ++ control.name};

		address.sendMsg("/ctrl", "synthControl", controlNames);
	},
	'/SynthControls'
);
)

To read the variable in Tidal (1.7.2) one can use

import Control.Concurrent.MVar
import Data.Map.Strict as Map

fmap (Map.lookup "synthControl") ((readMVar $ sStateMV tidal))

for older versions of Tidal have a look at OSC: Tidal and Processing - #7 by yaxu

So the only thing missing is a tidal function to send a single OSC message to SC, and then post the message recieved back from SC in the console like above. I don't really want to define a custom supercollider target just for this. And it seems so simple to do, but I really don't know how. So I hope someone can help :slight_smile:

hi @polymorphic.engine,

Here's my best guess:

import qualified Sound.OSC as O

sendO False (sListen tidal) (head $ sCxs tidal) $ O.Message "/SynthControls" []

It'd be great to get this into superdirt/tidal! There's one related issue here: https://github.com/musikinformatik/SuperDirt/issues/199

1 Like

Sorry for missing your question earlier by the way. In general for questions more on the superdirt side, opening an issue on github is probably more likely to get good attention.

1 Like

Thanks yaxu ! This works. So I defined the following function in tidal:

lookupControls:: String -> IO (Maybe Value)
lookupControls synthName = do sendO False (sListen tidal) (head $ sCxs tidal) $ O.Message "/SynthControls" [O.string synthName] 
                              fmap (Map.lookup "synthControl") ((readMVar $ sStateMV tidal))

and it almost works as expected, the only thing is, that there should be a bit of a delay between the sending of the message and printing of the parameter, since right now the function has to be executed twice to get the right parameters. Ofcourse it could be put into two seperate functions, one to send and one to lookup, but it would be awesome if it was just a single function.

I would love that! The only thing is, that I have basically no experience with GitHub and have never worked on something before, so I don't really know where to add the code. But I'm actually planning to get more into that so I'll be able to contribute in the future :slight_smile:

1 Like

Right, yes there's now a dedicated superdirt <> tidal API that we can use instead of getting stuff via control state.

I made a pull request here for the superdirt side: https://github.com/musikinformatik/SuperDirt/pull/234/files

1 Like

This used to work on older versions of GHCI but now it complains about hidden modules. I wonder if there is another way around it.

t> : error: Could not load module ‘Sound.OSC’ It is a member of the hidden package ‘hosc-0.18.1’. You can run ‘:set -package hosc’ to expose it. (Note: this unloads all the modules in the current scope.)