One issue I currently face when launching multiple instances of sclang via the command line (which boots scsynth) is connecting Midi ports on Linux using the patchbay (for flexibility), across different sessions.
Supercollider is using the same port names and ALSA is adding a port number to each instance [129] and [130] for example. But after rebooting the two instances of supercollider, the ALSA port numbers could be changed, to [134] and [135] or vice versa, for example. So a tool which tries to restore the MIDI connections, fails to do so.
Not sure how and if this could be solved, but I was thinking would it be possible to add a method to sclang (MIDIClient?) which allows you to set a custom ALSA midi port name? (Then the MIDI connection restore tool, should still do some regex to filter out the port numbers probably).
Edit: Same is true for the JACK client name probably:
One could do that. āSuperCollider_1ā, āsupercollider_2ā etc.
Or, you could have another process receiving all input control data, and rerouting freely to the other 2 processes, maybe via OSC. Maybe more flexible?
ALSA does not guarantee client names to by unique. I.e. it is possible to have two apps that create two clients with same ALSA client name. JACK however requires port names to be unqiue. To ensure this uniqueness, a2jmidid will add the unique numeric ALSA client ID to the JACK port name. However this behaviour is known to be problematic when restoring connections using simplistic tools like aj-snapshot and jack_connect. In order to make them work, the -u option can be used. This option will cause a2jmidid to omit the numeric ALSA Client ID from JACK port names. In this mode, ALSA client name uniqueness must be guartanteed externally."
So a2jmidid is adding the port id numbers.
A other solution would be to add JACK MIDI support to SuperCollider.
Only if youāre explicitly requesting it by running a2jmidid yourself, but that wasnāt the case in the original post? Unless Iām missing something.
Yeah, the restriction to ALSA MIDI is occasionally uncomfortable. Adding (or switching to) JACK MIDI is likely to be a do-ocracy task though (itāll happen when someone needs it, and does it, and puts in a PR).
I think the easiest and probably the best solution now is to add support for a environment variable which (if available) sets the JACK client name and the MIDI client name (both are āSuperColliderā by default).
The JACK client name is for the server, and this is already set by s.options.device (documented here). So thereās no need for an environment variable, because itās already configurable.
Iām not sure how MIDI clients appear in other OSes. Only Linux by default supports inter-app patching, so in Linux, apps must appear as ports. In MacOS, thereās IAC Bus; in Windows, loopMIDI. Certainly itās possible to run multiple sclang clients in every OS, so, identifying multiple sclang MIDI clients could be a cross-platform issue. In that case, a language-side variable would make more sense, but this may need confirmation. (If this problem is specific to Linux, then Iād probably go with the environment variable ā it wouldnāt make sense to add a MIDIClient.clientName for everybody, if it would be ignored in the vast majority of installations.)
If you look at JACK clients which have session manager support on Linux (NSM, RaySession), they use the same client name for JACK as for the MIDI client name.
I think it makes sense to automatically use the same name for the MIDI client, as is set via s.options.device in supercollider to. So if you set the device name to āSuperCollider.drumsā, your supercollider midi client name is also named āSuperCollider.drumsā.
Having the same names will also be the case with JACK MIDI support probably, as the JACK client name is the same for audio as for MIDI then (same JACK client).
A downside I can think of is that it might break some existing code of people who expect the MIDI client name always contains āSuperColliderā. But a custom device name can still contain āSuperColliderā of course.
I have a bit icky feeling about that ā coupling two entities that are not substantially related, but only in Linux (it would be 100% wrong in Mac and Windows to do anything like this), and only because of the accident that audio and MIDI connections can be made in the same JACK interfaces, doesnāt strike me as something to enforce as a default situation.
I think it would be fine if a user wants this to have a method in a linux/ directory that sets both the server device name and (future, after making it settable) MIDI client name to the same string.
Iāve no clue about other platforms, but I would expect them to mirror the JACK MIDI situation, where the audio client is the same as the midi client, while with ALSA, midi is a other layer, which is typical Linux.
Renaming the device name doesnāt rename the MIDI client name in OSX/ Windows automatically?
It would be good to have that option, this is currently the biggest obstacle for me to run SC as some sort of standalone application in a linuxaudio session. You want reliable restoration of MIDI connections, also if you use the patchbay and not MIDIOut.connect().
It belongs in MIDIClient. I strongly disagree with any notion of folding a MIDI option into ServerOptions. MIDI is language-only and has nothing to do with the server. The fact that they both appear in JACK UIs is purely an accident of the evolution of audio and MIDI subsystems in Linux. This should not influence SC architecture.
There could be a convenience method to set both at once, but these two entities should not be modeled in the same place.
Some Apps work better because they support. For example, many apps save their status when receiving āSIGUSR1ā Unix signal, which non-section-manager does etc.
You can set save and stop signal in NSM-Proxy indeed. It might be nice for instance if it was possible to handle SIGTERM in sclang. Then a SIGTERM signal could be sent from NSM-Proxy and it could be handled in sclang, by for example, sending \quit to the belonging scsynth.
Not sure how useful a SIGURS1 signal would be when it comes to SC. Ideally OSC would be used instead I think in this case.
Or MIDIClient.name_("APopular80sTechnology").init;
Iām not sure if this is relevant to other OSes. I think (in both Mac and Windows) that apps can see only device names, not other apps, and devices typically donāt have access to app names (the connection is via a physical cable), so the SC client name is probably invisible and thus irrelevant (except maybe in MacOS Audio MIDI Setup). This may be why MIDIClient never had an interface for setting a name.
Itās true. non-session-manager can also be controlled by OSC, but I donāt know much about compatibility/features on NSM yet. Iāve been using just non-mixer.
The non-mixer and non-timelines are good software and can fit many different situations since they are so clean and modular. Checking out NSM now. Letās see.
@flower share some tips on how you use NSM, Iām just considering it right now. The other pieces are more obviously useful for me.
Add supported NSM clients to your session (non-mixer, non-sequencer, zynaddsubfx, ardour, qtractor, carla, seq192 etc.).
Add applications without NSM support using nsm-proxy
Restore JACK connections by adding jackpatch to your session. https://non.tuxfamily.org/wiki/Non%20Session%20Manager
Btw: sclang doesnāt launch scsynth detached, so when sclang is started in a terminal and you kill the terminal, both sclang and scsynth are gone.