Connecting to the pedal
How to start the device engine, pick a port, follow the connection and startup sync, and run in listen-only mode or over Bluetooth. Needs the device feature (on by default; the Python package always has it).
Start the engine
Device::spawn starts a background thread that scans the MIDI ports, connects to the pedal and runs the startup sync. You talk to it with commands and read Updates back.
use open_stomp::device::{Config, Device};
let dev = Device::spawn(Config::default());
// ... dev.recv(), dev.set_param(...), ...
drop(dev); // stops the engine, closes the ports, joins the threadfrom open_stomp import Device
with Device() as dev: # the engine starts at once
... # dev.recv(), dev.set_param(...), ...
# leaving the block (or dev.close()) stops the engine- The engine only moves bytes and paces requests. Interpreting them is
DeviceState's job, in your thread (Reading pedal state). - Stopping: in Rust, dropping the
Devicestops the engine, closes the ports and joins the thread. In Python,close()or the end of thewithblock does the same; after that every call raisesRuntimeError. - GUIs:
Device::spawn_with_waker(config, move || ctx.request_repaint())runs your callback after each batch of updates, so the UI wakes up. The engine never touches your UI types.
commands / helpers midir (ALSA / CoreMIDI / WinMM)
your code ───────────────────▶ engine thread ◀──────────────────────────────▶ pedal
◀─────────────────── ├ port scan (hotplug, every 1.5 s)
Update ├ Assembler (split SysEx → whole messages)
├ RequestQueue (one SysEx in flight, 1 s timeout)
└ capture replay threadConfig
Rust Config field | Python argument | Default | Meaning |
|---|---|---|---|
client_name | client_name | "Open Stomp" | MIDI client name shown by the OS (ALSA sequencer, CoreMIDI) |
auto_connect | auto_connect | true | Connect to the first pedal-looking port, and again after it is replugged |
sync | sync | true | May send anything at all (startup reads and edits). false = listen only |
reply_timeout | reply_timeout | 1 s (1.0) | How long a SysEx request waits for its reply or ack before the queue moves on |
scan_interval | scan_interval | 1.5 s (1.5) | Port rescan period (hotplug detection) |
bluetooth | bluetooth | true | Also look for the pedal over Bluetooth (Rust: needs feature ble, ignored without it) |
Rust takes Durations; Python takes seconds as floats, all keyword-only:
use std::time::Duration;
use open_stomp::device::{Config, Device};
let dev = Device::spawn(Config {
sync: false, // listen only
reply_timeout: Duration::from_secs(2),
..Config::default()
});dev = Device(sync=False, reply_timeout=2.0) # listen onlyPorts and auto-connect
- Port list: the engine sends
Update::Portswith every MIDI input port name at start and whenever the set changes. - Auto-connect: with
auto_connecton, it connects to the first port for whichis_stomp_port(name)is true, preferring USB over Bluetooth, and reconnects after a replug. - Pedal-looking names:
is_stomp_portmatchesJME,SORANorSTOMPBOX, ignoring case. The official app matches.*JME.*and.*SORAN AMPEY.*. - Connect by name:
connect(port)opens that input and the matching output, and turns auto-connect back on.disconnect()closes the connection and turns auto-connect off. - Output port: the engine opens the output with the exact same name, or else any pedal-looking output (Windows names inputs and outputs differently).
- No output: if no output opens, the engine connects listen-only:
Status::Connected { output: false }and the info "No MIDI output to the pedal: listening only". - USB id:
USB_IDis(0x3962, 0x2000), "JME STOMPBOX".
| Platform | Example port name |
|---|---|
| Linux (ALSA sequencer) | JME STOMPBOX:JME STOMPBOX MIDI 1 24:0 |
| Other systems | Contains JME STOMPBOX, e.g. JME STOMPBOX MIDI 1 |
| Bluetooth (any) | JME STOMPBOX (Bluetooth) |
cargo run --example ports lists the MIDI ports and marks the pedal's.
Commands
Each Command has a helper method; Python has the same methods.
Rust Command | Helper (Rust and Python) | Effect |
|---|---|---|
Connect(port) | connect(port) | Connect to an input port by name (and the matching output); turns auto-connect back on |
Disconnect | disconnect() | Close the connection and turn auto-connect off |
Resync | resync() | Update::Reset, then the full startup read again |
SetSync(bool) | set_sync(on) | Allow or forbid sending; off also drops the queue |
Send(bytes) | send(bytes) | Send a live CC/PC now, bypassing the queue |
Write(msgs) | write(msgs) | Queue messages in order behind pending SysEx; writes wait for their ack |
Replay { path, speed } | replay(path, speed) | Disconnect and play a capture log instead of a pedal (Replaying captures) |
StopReplay | stop_replay() | Stop a replay |
The typed helpers for editing (select_preset, set_param, save_preset, imports and so on) are built on send and write; see Live edits.
Refused sends
In listen-only mode, before a connection, or without an output port, sends are refused. You get an Update::Info { error: true } saying "Not sent: listen-only mode, or no MIDI output to the pedal", and nothing is queued for later.
Updates
Rust Update | Python kind and fields | When |
|---|---|---|
Ports(names) | "ports": ports | At start and whenever the set of MIDI input ports changes |
Status(Disconnected) | "status": status == "disconnected" | The connection closed |
Status(Connected { port, output }) | "status": status == "connected", port, output | Connected; output is false when only listening |
Status(Replaying { file, progress }) | "status": status == "replaying", file, progress | Replay started, and its progress (0.0–1.0) |
Reset | "reset" | A new session starts (connect, resync, replay): reset your DeviceState |
Sync { done, total } | "sync": done, total | Startup sync progress; (0, 0) = no sync running (finished, cancelled or disconnected) |
Message { at, origin, bytes } | "message": at, origin, bytes | One complete MIDI message: Origin::Pedal (received) or Origin::Host (sent by the engine, or by the official app in a replay) |
Mark { at, text } | "mark": at, text | A # MARK annotation in a replayed capture |
Info { at, text, error } | "info": at, text, error | Something to tell the user: connected, unplugged, no reply, refused send |
at: the arrival time for live traffic, the original capture time in a replay. Rust gives aSystemTime; Python gives Unix seconds liketime.time().- Python
Update: one class;kindsays which fields are set, the others areNone.
Receiving
| Rust | Python | Behaviour |
|---|---|---|
recv() | for u in dev: | Block for the next update. Rust returns Err once the engine is gone; Python iteration ends when the device is closed |
recv_timeout(d) | recv(timeout=None) | Wait at most d (Rust: Err on timeout; Python: None after timeout seconds) |
try_recv() | try_recv() | The next update if one is waiting |
drain() | drain() | Everything available now, without blocking (an iterator in Rust, a list in Python); for a render loop |
What happens on connect
The engine sends
Update::Reset, thenUpdate::Status(Connected { .. }).If
syncis on and an output exists, the startup reads go into the queue:queue::handshake(), the official app's sequence (SysEx framing). That is version, product name, settings, current state, drum, the 10 user IR slots, the 10 user AMP slots, the 99 presets, then the edit buffer, looper and tuner: 127 requests, each waiting for its reply.Update::Syncreports progress after each reply or timeout, ending with(0, 0).From then on the engine forwards everything. It also follows up on pedal notifications that carry no data:
Change on the pedal Follow-up read A preset saved on the pedal That preset and the edit buffer The tuner switched on or off The tuner state The signal chain reordered on the pedal The chain order
Presets are read before the edit buffer so DeviceState can identify the active slot by matching the edit buffer against them. No read is known that returns the active slot directly (open questions).
Unsaved edits at connect
If the edit buffer has unsaved edits, the match fails and state.current stays empty (None) until the next preset change.
Wait for the sync
Sending right after spawn doesn't work: the engine hasn't connected yet, so the send is refused. Wait for the end of the startup sync instead; DeviceState then knows the presets and the active slot.
let mut synced = false;
while let Ok(update) = dev.recv() {
match update {
Update::Reset => {
state = DeviceState::default();
synced = false;
}
Update::Message { origin, bytes, .. } => {
state.apply(&bytes, origin);
}
// (0, 0) after the version reply arrived: the sync is done
Update::Sync { total: 0, .. } if !synced && state.firmware.is_some() => {
synced = true;
dev.select_preset(4); // safe to send from here on
}
_ => {}
}
}synced = False
for u in dev:
state.feed(u) # applies messages, resets on "reset"
if u.kind == "reset":
synced = False
elif u.kind == "sync" and u.total == 0 and not synced and state.firmware:
synced = True
dev.select_preset(4) # safe to send from here onUpdate::Status(Connected { output: true, .. }) is enough for live edits that don't depend on the pedal's state.
Listen-only mode
sync: false(Device(sync=False)) guarantees nothing is ever sent: no startup reads, no follow-up reads, no edits.set_sync(false)switches to listen-only at run time and also drops the queue.set_sync(true)allows sending again.- What you still get: every message the pedal sends by itself (knob turns, preset changes, looper, tuner). Without the startup reads,
DeviceStatedoesn't know the stored presets. - Monitor:
cargo run --example monitor -- --listenandmonitor.py --listenrun this way.
Bluetooth
With the pedal's Wireless setting on, the engine also scans for it over Bluetooth LE MIDI (Rust: feature ble, on by default; Python: always built in). No pairing is needed.
- Port: a pedal in range is listed in
Update::Portsas"JME STOMPBOX (Bluetooth)"(is_ble_port(name),BLE_PORT_SUFFIX). From there it works like a USB port:connect, sync, edits, uploads. - Auto-connect prefers USB, and moves to USB when the pedal is plugged in while connected over Bluetooth.
- Dropped link: the engine reports "Bluetooth connection lost", and auto-connect reconnects once the pedal advertises again.
- Turn it off:
Config { bluetooth: false, .. }orDevice(bluetooth=False).
Differences from USB:
| USB | Bluetooth | |
|---|---|---|
| Message pacing | As fast as replies come | At least 15 ms apart (an unpaced burst of 61 CCs froze the pedal until a power cycle) |
| Slider drags | Every CC sent | A CC that only replaces the value of the CC queued just before it overwrites it, so no backlog builds |
| Reply time | Fast (the whole sync is under a second) | About 95 ms (40–240 ms); the startup sync takes about 19 s |
| NAM / IR import | Under a second per upload | About 10 s per upload (each of the ~62 chunks waits for its ack); the official app doesn't offer imports over Bluetooth |
- macOS asks for Bluetooth permission the first time. An app bundle needs
NSBluetoothAlwaysUsageDescriptionin itsInfo.plist, or macOS kills it. - Bluetooth off or refused: the engine says so once ("Bluetooth is unavailable: …") and carries on with USB.
- Linux needs BlueZ, and the D-Bus headers to build.
cargo run --features ble --example ble_check exercises everything against a pedal (Wireless on, USB unplugged) and puts it all back afterwards. It never touches user AMP or IR slots.
Threads, timing and platforms
- Threads: one engine thread per
Device; a replay adds one short-lived thread. midir's input callback forwards raw bytes to the engine over a channel. - Timing: the engine loop ticks every 50 ms when idle. Each request goes out as soon as the previous one is answered, as the official app does (its whole startup sync takes about 320 ms).
- macOS: CoreMIDI only reports hotplugged devices through the run loop of the thread that created the client, so the engine turns its run loop once per tick. Without that, a pedal plugged in after start would never be seen.
- Windows: a MIDI port can be opened by only one program at a time. Quit the official Stomp Manager first.
- Linux: the engine uses ALSA sequencer ports.
Troubleshooting
The engine reports problems as Update::Info messages:
| Info text | Meaning |
|---|---|
| "MIDI is unavailable on this system (could not create a MIDI client)" | midir couldn't open the OS MIDI system |
| "Could not connect: …" | The port is gone or busy (on Windows, another program has it open) |
| "No MIDI output to the pedal: listening only" | Connected, but no output port opened |
| "Not sent: listen-only mode, or no MIDI output to the pedal" | A send was refused |
| "No reply from pedal to …" | A SysEx request timed out; the queue moved on |
| "Pedal unplugged" | The port disappeared |
| "Bluetooth is unavailable: …" | Bluetooth is off, refused or missing; USB still works |
| "Bluetooth connection lost" | The BLE link dropped |
On Linux, check that the system sees the pedal at all:
lsusb | grep 3962 # 3962:2000 SORAN JME STOMPBOX
amidi -l # e.g. IO hw:2,0,0 JME STOMPBOX MIDI 1