Skip to content

Send MIDI messages between different computers through a TCP connection with NodeJS.

License

Notifications You must be signed in to change notification settings

David-Vandensteen/remote-midi

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

remote-midi

Remote-MIDI is a library that allows you to send MIDI messages between different computers through a TCP connection.
It can be used in both unidirectional and bidirectional communication scenarios.

Unidirectional

In a unidirectional scenario, the slave computer sends MIDI messages to the master computer, which then forwards them to a MIDI out device connected to it.
The process is represented in the following diagram:

+----------------+     +----------------+     +----------------+
| SLAVE COMPUTER |---->| MIDI MESSAGE   |---->| TCP            |
|                |     |                |     |                |
+----------------+     +----------------+     +----------------+
                                                            |
                                                            |
                                                            v
                                                      +----------------+
                                                      | MASTER COMPUTER |
                                                      |                |
                                                      +----------------+
                                                                  |
                                                                  |
                                                                  v
                                                            +----------------+
                                                            | MIDI OUT DEVICE|
                                                            |                |
                                                            +----------------+

On the server/master side, you can use the rMidiServer function to start a server that listens for incoming MIDI messages on a specific IP and port, and forwards them to a specific MIDI out device:

import { rMidiServer } from '#src/remote-midi';

const server = rMidiServer({
  host: '0.0.0.0', port: 7070, midiOutputDeviceName: 'vmidi-out',
});
server.start();

On the client/slave side, you can use the rMidiClient function to connect to the server and send MIDI messages:

import { rMidiClient } from '#src/remote-midi';

const client = rMidiClient({ host: '192.168.0.1', port: 7070 });
client
  .start()
  .send('cc', {
    controller: 30,
    value: 32,
    channel: 0,
  });

Bidirectional

In a bidirectional scenario, not only can the slave computer send MIDI messages to the master computer, but the master computer can also send MIDI messages to the slave computer.
The process is represented in the following diagram:

+----------------+     +----------------+     +----------------+
| SLAVE COMPUTER |---->| MIDI MESSAGE   |---->| TCP            |
|                |     |                |     |                |
|    rMidiClient |     |                |     |                |
|                |     |                |     |                |
+----------------+     +----------------+     +----------------+
                                                            |
                                                            |
                                                            v
                                                      +----------------+
                                                      | MASTER COMPUTER |
                                                      |                |
                                                      | rMidiServer    |
                                                      |                |
                                                      +----------------+
                                                                  |
                                                                  |
                                                                  v
                                                            +----------------+
                                                            | MIDI OUT DEVICE|
                                                            |                |
                                                            +----------------+



                                                            +----------------+
                                                            | MIDI IN DEVICE |
                                                            |                |
                                                            +----------------+
                                                                  |
                                                                  |
                                                                  v
                                                            +----------------+
                                                            | MASTER COMPUTER |
                                                            |                |
                                                            +----------------+
                                                            |
                                                            |
                                                            v
                                                      +----------------+
                                                      | TCP            |
                                                      |                |
                                                      +----------------+
                                                                  |
                                                                  |
                                                                  v
                                                            +----------------+
                                                            | SLAVE COMPUTER |
                                                            |                |
                                                            |    rMidiClient |
                                                            |                |
                                                            +----------------+

This is achieved by using the rMidiServer function on the master computer side to start a server that listens for incoming MIDI messages on a specific IP and port, and forwards them to a specific MIDI out device. The server also listens for MIDI messages from connected MIDI in device and sends them to the slave computer via the TCP protocol.

On the client/slave side, you can use the rMidiClient function to connect to the server and send MIDI messages.
The client also listens for incoming MIDI messages from the server and can handle them accordingly.

Here is an example of how you can use the rMidiServer function on the master computer side:

import { rMidiServer } from '#src/remote-midi';

const server = rMidiServer({
  host: '0.0.0.0', port: 7070, midiOutputDeviceName: 'vmidi-out', midiInputDeviceName: 'vmidi-in',
});
server.start();

and here is an example of how you can use the rMidiClient function on the slave computer side:

import { rMidiClient } from '#src/remote-midi';

const { log } = console;
const client = rMidiClient({ host: '192.168.0.1', port: 7070 });
client
  .start()
  .on('data', () => log)
  .send('cc', {
    controller: 30,
    value: 32,
    channel: 0,
  });

About

Send MIDI messages between different computers through a TCP connection with NodeJS.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages