Hi,

Within Supercollider, I have no problem getting MIDI messages into Bela, but I can't manage to send out MIDI (to send to a synth). On a linux laptop, I indeed need to do some routing in the ALSA settings of QjackCtl. But I'm not sure SC whether Bela uses jack at all (??). Has anyone manged to output MIDI messages out from Bela in Supercollider?

Thank you

hmm MIDI should work on Bela like on a regular Linux computer. If you normally have to use Jack, then you probably have to use it here as well? I am not sure why: maybe this has something to do with the distinction between ALSA MIDI "raw" and "sequencer".

Yes I probably need to use jack here as well, but I won't be able to run Qjackctl on Bela afaik (right?), and I have to confess I don't know (and couldn't find) how to set up ALSA routing with a CLI (instead of Qjackctl). This is probably not a strictly Bela issue though, but in case anyone here knows...

Ok, I understood how to do this: I just need to do the ALSA routing using the aconnect command, to connect the first output of Supercollider to the midi output port I need (sorry, Linux audio newbie here). However, this apparently needs to be done once Supercollider has launched already. In order to avoid doing this manually, is there a way I can tell Bela to run an aconnect command on project launch?

Hmmm.. can sclang run "shell" commands somehow? You could also mayb use virmidi to create some virtual port and pre-connect them, then sc will connect to one of these. Not sure if it would work

Yes indeed, SC can run shell commands. thank you for the suggestion! Here's a snippet of the code that works for me as a reference for others:

var p, l;

s = Server.default;
s.options.numAnalogInChannels = 8;
s.options.numAnalogOutChannels = 2;
s.options.numDigitalChannels = 16;
s.options.blockSize = 16;
s.options.numInputBusChannels = 2;
s.options.numOutputBusChannels = 2;
s.options.postln;

MIDIClient.init;
MIDIIn.connectAll;

// the ALSA MIDI routing:
p = Pipe.new("aconnect 128:5 20:0", "r");        
l = p.getLine;                    					// get the first line
while({l.notNil}, {l.postln; l = p.getLine; });     // post until l = nil
p.close;                    						// close the pipe to avoid that nasty buildup


s.waitForBoot({
	~midiOut = MIDIOut.newByName("ESI-ROMIO", "ESI-ROMIO MIDI 1").latency = (0.01);	
~midiOut.noteOn(1, 60, 60);
});
3 years later

Hi, have been going through various threads trying to compile a solution for my issue with no luck, this feels like the closest match.

I'm facing a similar situation wanting to send Midi from Supercollider running on Bela to another device, but my Bela is connected to a network over ethernet. Using the hints above I've got Bela emitting a note from Virtual port 1, which I can verify using amidi --dump -p hw:1,0.

In other places you've said this is related to the midi rpt functionality so I think I must be close, I think I just need a port number to complete the config of midi rpt in audioMidi setup, but I can work out where to look to get this, and snooping on active ports hasn't helped!

EDIT: I realise that I might be missing the part of setting up a udp port as the communication protocol...

Any reason why you specifically need to send MIDI? I am thinking, if the receiving end is running another Supercollider instance, then you could send OSC instead (also, if it is not running Supercollider, but it can run Supercollider, then you could have virmidi running on the receiving and and an sclang instance there doing the OSC to MIDI parsing, writing to virmidi).

Now, if sending actual MIDI over Ethernet is what you need, then I think you'll need one instance of qmidinet running on Bela and one on the receiving end (if that's another Linux machine). You should then be able to connect Sc on Bela to qmidinet via aconnect. When I last used qmidinet in 2016/2017, the version that came with Debian didn't allow to run it without an X-server (so I had to build it from source, with appropriate config), but more recent versions should have a --no-gui option (see https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=811240 ). You could try installing with apt-get install qmidinet and if it doesn't run without GUI, then build it yourself. Unfortunately it still has a lot of dependencies to instal, most of which are useless (as they are GUI related), but alas, these are the downsides of using a generic distro.