Skip to content

Commit 522e838

Browse files
author
Simon Holliday
committed
- Add support for multiple MIDI input and output devices
1 parent 9ea8065 commit 522e838

8 files changed

Lines changed: 1187 additions & 76 deletions

File tree

README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,25 @@ Pattern length can be specified two ways - use whichever is clearest:
476476

477477
When `output_device` is omitted, Subsequence auto-discovers available MIDI devices. If only one device is connected it is used automatically; if several are found you are prompted to choose. To skip the prompt, pass the device name directly: `Composition(output_device="Your Device:Port", ...)`.
478478

479+
**Multiple output devices** - use `comp.midi_output()` to register additional devices. Each call returns a device index (1, 2, …) that can be used in pattern decorators or as a named alias:
480+
481+
```python
482+
comp = subsequence.Composition(bpm=120, output_device="MOTU Express") # device 0
483+
484+
comp.midi_output("Roland Integra", name="integra") # device 1
485+
comp.midi_output("Elektron Analog Four", name="a4") # device 2
486+
487+
@comp.pattern(channel=1, beats=4, device="integra")
488+
def strings(p):
489+
p.note(60, beat=0)
490+
491+
@comp.pattern(channel=1, beats=4) # device defaults to 0 (MOTU Express)
492+
def bass(p):
493+
p.note(36, beat=0)
494+
```
495+
496+
Patterns without a `device=` parameter always route to device 0 - single-device compositions work exactly as before without any changes.
497+
479498
MIDI channels and drum note mappings are defined by the musician in their composition file - the module does not ship studio-specific constants. Channels use 1-based numbering by default (1-16, matching instrument panels - channel 10 is drums). To use 0-based numbering (0-15, matching the raw MIDI protocol), pass `zero_indexed_channels=True`:
480499

481500
```python
@@ -1711,6 +1730,21 @@ Two dispatch modes:
17111730

17121731
Built-in preset strings: `"cc"` (identity), `"cc:N"` (remap to CC N), `"pitchwheel"` (scale to ±8192). Pass a callable for full control over output message type and value scaling.
17131732

1733+
**Multiple input/output devices** - both `cc_map()` and `cc_forward()` support `input_device=` and `output_device=` parameters for routing between devices:
1734+
1735+
```python
1736+
comp.midi_input("Arturia KeyStep", name="keys")
1737+
comp.midi_input("Faderfox EC4", name="faders") # second call adds an extra input
1738+
1739+
comp.midi_output("Roland Integra", name="integra")
1740+
1741+
# Only respond to CC 74 from the fader box
1742+
comp.cc_map(74, "filter", input_device="faders")
1743+
1744+
# Forward mod wheel from the keyboard to pitch bend on the Integra
1745+
comp.cc_forward(1, "pitchwheel", input_device="keys", output_device="integra")
1746+
```
1747+
17141748
### MIDI clock output
17151749

17161750
Make Subsequence the MIDI clock master so hardware can lock to its tempo:

0 commit comments

Comments
 (0)