Virtual midi with JUCE in LInux

Hi guys,

this is my first post in the forum; I’m quite new to JUCE, so maybe my issue is quite easy for an experienced JUCE programmer, but for me at the moment is quite difficult to understand where is the trick that causes things to work properly (or maybe I didn’t understand nothing at all and what I’m trying to do is not possible…)

I’m using Juce 6.1.4 free edition on Linux.

By reading the official JUCE documentation, it seems possible in Linux (and also on Mac) for one juce application send midi messages to another juce application by using virtual midi ports. Infact the documentation for MidiOutput::createNewDevice states:
“This will attempt to create a new midi output device with the specified name that other apps can connect to and use as their midi input.”

To be honest this sentence leaves me a little bit confused: how can an application connect to a midi output port to get midi messages from it, i.e. use it as a midi input port? To read midi messages one usually connects to a midi input port…

Anyway, let’s call the midi message producer application A, and the midi message consumer application B.

In A I successfully create a virtual midi output port (whose name is “vmidi”) with the static public method createNewDevice of the MidiOutput class; then I periodically send midi messages to it via the sendMessageNow method and it all seems to work by the producer side…

Now my doubt…

The virtual midi port created in A is an output port, so I can send midi messages to it, but where do these message go? How can I read the messages sent to that port? (which is waht I would like application B were able to do…).

To solve this question, what I tried in application B (the consumer) was:
I created a new virtual input midi port with the same “vmidi” name as the virtual output midi port by using the public static MidiInput::createNewDevice method; the port was created without errors; then I started the midi input port in the hope that the messages written by the application A were read by the registered midi callback in application B, but nothing happens: the midi messages that A sends to virtual output midi port “vmidi” do not magically appear in the virtual input midi port “vmidi” for the application B to be read…

What lacks to my understanding is how can I manage to have the midi messages written to a virtual midi output port by an application appear in another virtual midi input port to be read by another application…

The final goal is to have a chain of midi applications that send a stream of midi messages to one another, each application possibly performing some filtering and transformation on the midi messasges read before forwarding them to the following application in the chain…

Excuse me for having been so verbose, but I wanted to explain precisely the problem I’m trying to solve…

Luca

Hi guys,

I try to say again what I would like to do with more simple words…My original post was too verbose…

Is there a way under Linux ALSA for a juce application send midi messages to a virtual midi output port and have another juce application read these midi messages?

It’s as if there were a sort of virtual midi cable so that the midi messages written to one end of the cable by the first application can be read to the opposite end of the cable by the second application…

Any suggestion will be appreciated! :slight_smile:

Thank you,

Luca

It’s possible with Midi-through:

Hi KottVv,
thank you for your reply!
So, it’s something that must be done outside of JUCE; by reading the JUCE docs it seemed that it was something that you could do programmatically with the JUCE API…
Anyway, for example, if there are two JUCE applications, one that produces midi data, called A, and the other that must read midi data produced by A, called B, the way to set things up is the following:

  1. A creates an output virtual midi port - let’s call it “A_out” - it sends midi messages to
  2. B creates an input virtual midi port - let’s call it “B_in” - it reads incoming midi messages from
  3. The two midi ports should automatically be shown in the patchage (am I wrong here?)
  4. In the patchage I connect “A_out” with “Midi Through In” and “Midi Through Out” with “B_in”
    Is that correct?

Why not directly connecting “A_out” with “B_in” in the patchage?
Am I missing some important concepts?

Thank you very much.

Luca

You can directly connect A to B in the plugin host, like Carla or any other. But in standalone apps you’ll see the “devices” with their ports only.

I re-read your original post. If I got it correctly, you want to make ALSA MIDI device in JUCE app.
I don’t know that it’s possible using JUCE only, maybe you have to do that with ALSA programming.

I’m still a little bit confused about what I want to do, meaning that I would like to learn how to write midi applications…
So I started as a first exercise with writing two simple applications using JUCE that send midi data to each other…
At the moment I’m leaving VST apart… That will come later…
You mentioned Carla… Is it a VST host? Because in that case it’s not at the moment what fits to my needs… I simply want a first midi application to write midi data to some virtual midi port so that another midi application can read those data and make some filtering and manipulation on them before in its turn forwarding them…

1 Like

Thank you, I’ll watch at these tools!!
Luca