---
title: MIDI and OSC tools improvements  - MIDI processing and mDNS support
canonical: https://0110.be/posts/MIDI_and_OSC_tools_improvements__-_MIDI_processing_and_mDNS_support
markdown_url: https://0110.be/posts/MIDI_and_OSC_tools_improvements__-_MIDI_processing_and_mDNS_support.md
id: 566
published_at: '2025-10-02T00:00:00Z'
updated_at: '2025-10-06T13:54:28Z'
author: Joren
tags:
- name: Code
  markdown_url: https://0110.be/tags/Code.md
- name: Music Information Retrieval
  markdown_url: https://0110.be/tags/Music%20Information%20Retrieval.md
- name: UGent
  markdown_url: https://0110.be/tags/UGent.md
---

# MIDI and OSC tools improvements  - MIDI processing and mDNS support

I've just pushed some updates to [mot](https://github.com/JorenSix/mot) — a command-line application for working with OSC and MIDI messages. My LLM tells me that these are exciting updates but I am not entirely sure that this is the case. Let me know if this ticks your box and seek professional help. 

### 1. Scriptable MIDI Processor via Lua

I have implemented a **MIDI processor** that lets you transform, filter, and generate MIDI messages using [Lua](https://www.lua.org/about.html) scripts.

**Why is this useful?** MIDI processors act as middlemen between your input devices and output destinations.You can do the following on incoming MIDI messages:

- **Transform** - Transpose notes, generate chords, map velocity curves
- **Filter** - Block unwanted messages - channels - or select specific ranges
- **Route** - Send different notes to different channel
- **Generate** - Create complex patterns from simple input

<svg viewBox="0 0 800 300" xmlns="http://www.w3.org/2000/svg">
                <!-- External MIDI Device -->
                <g id="midi-device">
                    <rect x="20" y="100" width="140" height="100" rx="10" fill="#667eea" stroke="#5568d3" stroke-width="2"/>
                    <text x="90" y="140" text-anchor="middle" fill="white" font-size="16" font-weight="bold">MIDI Device</text>
                    <text x="90" y="160" text-anchor="middle" fill="white" font-size="12">(Keyboard, Pad, etc.)</text>
                    <circle cx="90" cy="185" r="3" fill="white"/>
                    <circle cx="90" cy="195" r="3" fill="white"/>
                </g>

                <!-- Arrow 1 -->
                <g id="arrow1">
                    <line x1="160" y1="150" x2="230" y2="150" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)"/>
                    <text x="195" y="140" text-anchor="middle" font-size="11" fill="#666">MIDI In</text>
                    <text x="195" y="170" text-anchor="middle" font-size="10" fill="#999" font-family="monospace">Note On C4</text>
                </g>

                <!-- mot Processor -->
                <g id="mot-processor">
                    <rect x="230" y="80" width="340" height="140" rx="10" fill="#764ba2" stroke="#6a3f8f" stroke-width="3"/>
                    <text x="400" y="110" text-anchor="middle" fill="white" font-size="18" font-weight="bold">mot midi_processor</text>
                    
                    <!-- Lua Script Box -->
                    <rect x="250" y="125" width="300" height="80" rx="5" fill="rgba(255,255,255,0.15)" stroke="white" stroke-width="1" stroke-dasharray="3,3"/>
                    <text x="400" y="145" text-anchor="middle" fill="white" font-size="14" font-weight="bold">🌙 Lua Script</text>
                    <text x="400" y="165" text-anchor="middle" fill="white" font-size="11" font-family="monospace">process_message()</text>
                    <text x="400" y="183" text-anchor="middle" fill="#ffd700" font-size="10">Transform • Filter • Generate</text>
                    <text x="400" y="198" text-anchor="middle" fill="#90ee90" font-size="9">C4 → C4 + E4 + G4 (chord)</text>
                </g>

                <!-- Arrow 2 -->
                <g id="arrow2">
                    <line x1="570" y1="150" x2="640" y2="150" stroke="#333" stroke-width="2" marker-end="url(#arrowhead)"/>
                    <text x="605" y="140" text-anchor="middle" font-size="11" fill="#666">MIDI Out</text>
                    <text x="605" y="170" text-anchor="middle" font-size="10" fill="#999" font-family="monospace">3 notes</text>
                </g>

                <!-- Virtual MIDI Device -->
                <g id="virtual-device">
                    <rect x="640" y="100" width="140" height="100" rx="10" fill="#28a745" stroke="#218838" stroke-width="2"/>
                    <text x="710" y="135" text-anchor="middle" fill="white" font-size="16" font-weight="bold">Virtual MIDI</text>
                    <text x="710" y="155" text-anchor="middle" fill="white" font-size="12">Device</text>
                    <text x="710" y="175" text-anchor="middle" fill="white" font-size="10">(DAW, Synth, etc.)</text>
                    <circle cx="710" cy="190" r="3" fill="white"/>
                    <circle cx="710" cy="198" r="3" fill="white"/>
                </g>

                <!-- Arrow definition -->
                <defs>
                    <marker id="arrowhead" markerWidth="10" markerHeight="10" refX="9" refY="3" orient="auto">
                        <polygon points="0 0, 10 3, 0 6" fill="#333"/>
                    </marker>
                </defs>

                <!-- Data flow animation circles -->
                <circle r="4" fill="#ffd700">
                    <animateMotion dur="3s" repeatCount="indefinite" 
                        path="M160,150 L230,150 L570,150 L640,150"/>
                </circle>
</svg>

The processor reads incoming MIDI from a physical device, processes it through your Lua script, and outputs the modified messages to a virtual MIDI port that your DAW or synth can receive. Some examples:


```ruby
# Generate chords from single notes
mot midi_processor --script scripts/chord_generator.lua 0 6666

# Transpose notes up by one octave
mot midi_processor --script scripts/example_processor.lua 0 6666
```




### 2. Network Discovery via mDNS

OSC receivers now **advertise themselves on the network** using mDNS/Bonjour with the `_osc._udp` service type. 

This makes mot compatible with the [EMI-kit](https://github.com/IPEM/EMI-kit) — the Embodied Music Interface Kit developed at IPEM, Ghent University. OSC-enabled devices can automatically discover mot receivers on your network, eliminating manual configuration if the OSC sources add this functionality.


### Get started

Installation via Rust's cargo:


```ruby
git clone https://github.com/JorenSix/mot.git
cd mot
cargo install --path .
mot midi_processor -h
```


Check out the [mot repository](https://github.com/JorenSix/mot) for full documentation and example Lua scripts!

