Skip to content

Latest commit

 

History

History
135 lines (86 loc) · 5.7 KB

README.md

File metadata and controls

135 lines (86 loc) · 5.7 KB

mot build

mot - MIDI and OSC Tools

mot consists of several MIDI and OSC command line tools. These are mainly of interest to debug and check OSC messages and MIDI devices. There are applications to:

  • midi_echo: prints MIDI messages coming from a connected MIDI device.
  • osc_echo: prints OSC messages arriving at a certain UDP port.
  • osc_send: sends OSC messages from STDIN to a certain host.
  • midi_to_osc: a MIDI to OSC bridge which sends MIDI messages coming from a connected MIDI device to an OSC target.
  • midi_roundtrip_latency: measure MIDI round-trip latency.

Install MIDI and OSC Tools mot

Currently, the only way to install this software is by using cargo, the Rust package manager. Please make sure you have installed a recent cargo/rust version first.

git clone --depth 1 https://github.com/JorenSix/mot.git
cd mot
cargo build --release
cargo install --path .
mot -h 

These commands assume that ~/.cargo/bin is present in the users $PATH. Alternatively you can copy mot to a directory more likely to be in the path:

git clone --depth 1 https://github.com/JorenSix/mot.git
cd mot
cargo build --release
sudo cp target/release/mot /usr/local/bin

Command line applications in mot

mot works with sub-applications which are called with e.g. mot midi_echo to call the midi_echosub application. Each sub-application also comes with a help function: mot midi_echo -h

mot - Midi and OSC Tools

Usage: mot <COMMAND>

Commands:
  midi_to_osc             Transport MIDI over OSC
  midi_echo               Print incoming MIDI messages.
  osc_echo                Print incoming OSC messages.
  midi_roundtrip_latency  Test MIDI roundtrip latency
  help                    Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

MIDI echo

This application prints MIDI messages which are received on a MIDI input port. There is also an option to list all input midi ports. This application is ideal to check if a) a MIDI device is correctly recognized, b) a MIDI device sends messages and c) a MIDI device sends the expected messages.

mot midi_echo -l
#Listing MIDI input devices:
# Available MIDI input ports:
# 0: Teensy MIDI Port 1
mot midi_echo 0

OSC echo

This application prints OSC messages which are received on a certain UDP port. This application is ideal to check if a) a OSC messages are being received and b) the OSC messages received are in the expected place or type.

mot osc_echo 127.0.0.1:6666

MIDI to OSC bridge

This application sends incoming MIDI messages over OSC to an OSC receiver. This is ideal if you want to send MIDI messages over the network.

It also allows to create a virtual MIDI port. This can be useful e.g. to send messages from a browser window, over MIDI, to a network. If mot is running, a browser can send messages to a virtual port which is then translated to UDP messages on a network.

mot midi_to_osc 127.0.0.1:5566 /midi_transport 6666

OSC to MIDI bridge

This application receives OSC messages and sends them to a MIDI device. This is ideal if you want to receive messages coming from the @midi_to_osc@ command. The decoding is simple: it expects OSC messages with each byte of a midi message encoded in an integer. Each integer is packed in a byte and send to MIDI transparently. There is a check if the integer is positive and under 256.

It also allows to create a virtual MIDI port. The following example receives OSC on UDP port 5566 and sends it to a virtual midi port.

mot osc_to_midi 127.0.0.1:5566 /m 6666

OSC send

This application sends OSC messages read from STDIN and sends the message to the specified host and port. This can be used to check if manually constructed OSC messages arrive on a listening server or to check message handlers. See the example below.

There is limited support for typed OSC message arguments and there are a few limitations. Each line that comes in via STDIN is split on whitespace. The first token is interpreted as the OSC method, the other tokens are seen as OSC message arguments. If an argument is an integer or a float the corresponding OSC type is used, otherwise the OSC argument is a string. String arguments with spaces are not supported.

#Listen to incoming osc messages in the background
mot osc_echo 127.0.0.1:6666 &
#Send an OSC message
echo "/test 12 15.2 str_arg\n" |  mot osc_send 127.0.0.1:6666
#Response generated by osc_echo:
msg: OscMessage { addr: "/test", args: [Int(12), Float(15.2), String("str_arg")] }

MIDI round-trip latency

This application sends out a MIDI message as quickly as possible when a MIDI message is received. It can be used to measure MIDI round-trip latency if it is used together with the Teensy patch in the misc directory. If all goes wel a relatively constanc round-trip latency of less than 1m should be no problem. An example on macOS can be seen below:

MIDI round trip latency

The roundtrip time for a midi message send over BTLE is much worse: with an ESP32 I measured an average of 43 +- 6 milliseconds with the worst rountrip time around 60 ms. There is also a BT LE MIDI

Browser to OSC example

One of the ways to send OSC messages from a browser to a local network is by using the MIDI out capability of browsers and - using mot - translating MIDI to OSC an example can be seen below.

mot browser to OSC

Credits

Joren Six @ IPEM, UGent