Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jswrenn/midiplex
Volume-aware splitting of a polyphonic MIDI stream into multiple, monophonic streams.
https://github.com/jswrenn/midiplex
alsa midi rust
Last synced: 5 days ago
JSON representation
Volume-aware splitting of a polyphonic MIDI stream into multiple, monophonic streams.
- Host: GitHub
- URL: https://github.com/jswrenn/midiplex
- Owner: jswrenn
- Created: 2018-04-11T21:55:59.000Z (almost 7 years ago)
- Default Branch: master
- Last Pushed: 2018-07-12T19:45:00.000Z (over 6 years ago)
- Last Synced: 2025-01-19T18:52:11.788Z (10 days ago)
- Topics: alsa, midi, rust
- Language: Rust
- Size: 29.3 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
MIDIplex is a utility for volume-aware distributing a _polyphonic_ MIDI stream into multiple output streams. The output streams are guaranteed to be monophonic. Output streams are allocated to a note in proportion to that note's velocity, relative to the velocity of other notes being played.
## Why MIDIplex?
Music is often _polyphonic_, i.e., at times, there are multiple notes playing simultaneously. However, some synthesizers are _monophonic_, i.e., they can only voice one sound at a time. MIDIplex consumes a MIDI stream and automagically distributes it across a set number of output channels in such a way that it is guaranteed that no output will be expected to play two notes or more notes simultaneously. You can use MIDIplex to render a polyphonic MIDI across a given number of monophonic synthesizers, be it a [choir of musical floppy disks](https://www.youtube.com/watch?v=C3dU5u4xXaY), or (as I am) across a [lab of computers with `beep` installed](https://www.youtube.com/watch?v=ehpZ2GfWKe8).For a visual depiction of how MIDIplex distributes notes, watch [this demonstration video](https://www.youtube.com/watch?v=leyjsN-FpUo), in which events from an input keyboard (top) are distributed across three output channels.
## System Requirements
MIDIplex integrates with the _Advanced Linux Sound Architecture_. MIDIplex therefore is only supported on systems running Linux.## Usage
### Overview```
USAGE:
midiplex [OPTIONS]OPTIONS:
-i, --input-pool-size sets the ALSA input pool size
-m, --max-allocation sets the maximum number of outputs allocated to any noteOUTPUT MODES:
alsa ALSA output mode
udp UDP output mode
```### Input
MIDIplex consumes input as a virtual ALSA MIDI device named ‘midiplex’ with a writable port named ‘input’. You can verify that MIDIplex is running with `aconnect`:
```
$ aconnect -l
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 128: 'midiplex' [type=user,pid=6496]
0 'input
```### Output
MIDIplex supports two output modes. For most users, the ALSA output mode offers the most flexibility.#### ALSA Output
In the ALSA output mode, midiplex creates a specified list of readable ports to which it distributes notes. You can then patch those notes to other MIDI devices using the `aconnect` utility from `alsa-utils`, or a visual connection manager such as [patchage](http://drobilla.net/software/patchage).##### Overview:
```
USAGE:
midiplex alsa [OPTIONS] ...OPTIONS:
-o, --output-pool-size sets output pool sizeARGS:
... space-delimited names of output ports
```##### Example:
```
$ midiplex alsa melete mneme aoide & aconnect -l
[1] 10337
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 128: 'midiplex' [type=user,pid=10337]
0 'input '
1 'melete '
2 'mneme '
3 'aoide '
```##### “Help! I’m getting `ENOSPC`”:
The ALSA output mode is resource-intensive. For 𝘯 outputs, each input note _on_ and _off_ event must be copied 𝘯 times. If those 𝘯 output ports are then patched to 𝘯 synthesizers, that entails additional copying of the event. These issues can be somewhat assuaged with `--input-pool-size` and `--output-pool-size`, but for large values of 𝘯, intensive pieces may nonetheless cause MIDIplex to terminate with `ENOSPC`.#### UDP Output
For cases where ALSA output mode is unsuitable, MIDIplex can write its output directly to a UDP socket. Note _on_ and _off_ events are encoded as three-byte datagrams, [as described by the MIDI specification](https://www.midi.org/specifications/item/table-1-summary-of-midi-message). You can receive these messages using a utility such as [MIDInet](https://github.com/jswrenn/midinet) or [qmidinet](https://qmidinet.sourceforge.io/).##### Overview:
```
USAGE:
midiplex udp [HOSTS]...ARGS:
... space-delimited socket addresses
```##### Example:
Assuming three reachable hosts, _melete_, _mneme_ and _aoide_:
```
$ midiplex udp melete:8336 mneme:8336 aoide:8336 & aconnect -l
[1] 13114
client 0: 'System' [type=kernel]
0 'Timer '
1 'Announce '
client 14: 'Midi Through' [type=kernel]
0 'Midi Through Port-0'
client 128: 'midiplex' [type=user,pid=13114]
0 'input '
```