Default sclang port change

Hello,

Is there a way to start SuperCollider with a different default port other than 57120? Or do you have to make a special build with a different port?

Thanks,
Dan

1 Like

You can do that. You can even have several servers and one client, and vice versa.

So how do you change sclang’s port from 57120? I ask this because I have another device that uses the port 57120, so I have a conflict.

Hey Dan!
sclang itself does have the the --port flag where you can change the default port when you run it from the command line, but it doesn’t seem that we can set that when we start it from the IDE.
I think it’s worth it to file it as an issue on GH.
Cheers,
Marcin

Hi Marcin!

I tried this in terminal open /Applications/SuperCollider.app --args --port 57121 but that didn’t work. How exactly do you use the --port flag?

Hey

How about the second argument of the Server class? To the best of my knowledge, one can boot different servers. Of course, you need to assign to different variables, otherwise you will lose the reference to the first server.

This is concerning sclang and not scsynth. scsynth has the port 57110 so there’s no confict there for me.

Yes, you can have different sclang processes as well. But this is tricky; you need to think a bit and sync their states, where necessary. I don’t remember a template for that, a recommended way, or a tutorial, etc. But it is just an argument, as you said.

Try

/Applications/SuperCollider.app/Contents/MacOS/sclang --port 57121

Use control-d to exit the CLI.

Be aware - the REPL interface is a bit …broken?, it is definetely inteded to be used with the IDE :wink:
Maybe we can add this as a setting to the IDE or the LanguageConfig in a future version?

1 Like

This gives the error sclang: invalid option --

Working here, homie:

Maybe you are using an older (<3.14) version of sclang, in that case it is -u instead of --port.

-u works with dev branch too

Ahh thanks. Yes, -u works. But I guess that’s not super helpful if it’s not in the IDE. Thanks for the replies! I will try a build from source (although does FluCoMa work with the newer SC yet?)

Well, you can also have two instances of emacs… (or create a mode where you can switch to which process the code goes? Not trivial, I think. If you tell us your use case, maybe we can find the simplest solution)

The newest flucoma version Release 1.0.9 · flucoma/flucoma-sc · GitHub is only compatible with 3.14.0+, so if you compile SC yourself you should be fine.

supercollider/editors/sc-ide/core/sc_process.cpp at 96bc0cb45621da728725018919a61fdd52c018de · supercollider/supercollider · GitHub is the method you should patch btw.

The use case was noted earlier: there’s a device that uses port 57120, so the IDE needs to start a single sclang on a different port. No multiple instances, no syncing states.

Tbh the IDE should have exposed the port number in Preferences from the beginning; I’m not sure why we never did that.

I guess another workaround might be to write a shell script that appends the port argument to the sclang command… call that “sclang” and rename the sclang executable to something else.

  • Inside the Mac app bundle, find sclang and rename it to sclang-bin or something
  • Then make a script sclang-bin ...options... and save that as sclang, and make it executable. If you want to get fancy, you could use Perl to handle incoming arguments from the IDE but if you’ll only ever use one sclang configuration file, hardcoding the args would be quicker.

Untested but maybe worth a shot?

But we should put in a feature request to add the port to Preferences.

hjh

1 Like

Touchée. That sounds like a solution.

EDIT: Just make sure to pass the arguments of the script to the sclang command too. It sounds solid.

I think I have followed these instructions, but when I start the IDE I get Interpreter has quit. [Exit code: 0]. I will keep tinkering with it, thanks!

I think you need to use the -i inside your script, to set the sclang --ide arg. I think the best way is to just replicate and pass all arguments (just force a different port)