Skip to content

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.

rust
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 thread
python
from 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 Device stops the engine, closes the ports and joins the thread. In Python, close() or the end of the with block does the same; after that every call raises RuntimeError.
  • 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.
text
           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 thread

Config ​

Rust Config fieldPython argumentDefaultMeaning
client_nameclient_name"Open Stomp"MIDI client name shown by the OS (ALSA sequencer, CoreMIDI)
auto_connectauto_connecttrueConnect to the first pedal-looking port, and again after it is replugged
syncsynctrueMay send anything at all (startup reads and edits). false = listen only
reply_timeoutreply_timeout1 s (1.0)How long a SysEx request waits for its reply or ack before the queue moves on
scan_intervalscan_interval1.5 s (1.5)Port rescan period (hotplug detection)
bluetoothbluetoothtrueAlso look for the pedal over Bluetooth (Rust: needs feature ble, ignored without it)

Rust takes Durations; Python takes seconds as floats, all keyword-only:

rust
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()
});
python
dev = Device(sync=False, reply_timeout=2.0)  # listen only

Ports and auto-connect ​

  • Port list: the engine sends Update::Ports with every MIDI input port name at start and whenever the set changes.
  • Auto-connect: with auto_connect on, it connects to the first port for which is_stomp_port(name) is true, preferring USB over Bluetooth, and reconnects after a replug.
  • Pedal-looking names: is_stomp_port matches JME, SORAN or STOMPBOX, 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_ID is (0x3962, 0x2000), "JME STOMPBOX".
PlatformExample port name
Linux (ALSA sequencer)JME STOMPBOX:JME STOMPBOX MIDI 1 24:0
Other systemsContains 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 CommandHelper (Rust and Python)Effect
Connect(port)connect(port)Connect to an input port by name (and the matching output); turns auto-connect back on
Disconnectdisconnect()Close the connection and turn auto-connect off
Resyncresync()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)
StopReplaystop_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 UpdatePython kind and fieldsWhen
Ports(names)"ports": portsAt 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, outputConnected; output is false when only listening
Status(Replaying { file, progress })"status": status == "replaying", file, progressReplay 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, totalStartup sync progress; (0, 0) = no sync running (finished, cancelled or disconnected)
Message { at, origin, bytes }"message": at, origin, bytesOne 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, textA # MARK annotation in a replayed capture
Info { at, text, error }"info": at, text, errorSomething 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 a SystemTime; Python gives Unix seconds like time.time().
  • Python Update: one class; kind says which fields are set, the others are None.

Receiving ​

RustPythonBehaviour
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 ​

  1. The engine sends Update::Reset, then Update::Status(Connected { .. }).

  2. If sync is 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.

  3. Update::Sync reports progress after each reply or timeout, ending with (0, 0).

  4. From then on the engine forwards everything. It also follows up on pedal notifications that carry no data:

    Change on the pedalFollow-up read
    A preset saved on the pedalThat preset and the edit buffer
    The tuner switched on or offThe tuner state
    The signal chain reordered on the pedalThe 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.

rust
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
        }
        _ => {}
    }
}
python
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 on

Update::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, DeviceState doesn't know the stored presets.
  • Monitor: cargo run --example monitor -- --listen and monitor.py --listen run 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::Ports as "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, .. } or Device(bluetooth=False).

Differences from USB:

USBBluetooth
Message pacingAs fast as replies comeAt least 15 ms apart (an unpaced burst of 61 CCs froze the pedal until a power cycle)
Slider dragsEvery CC sentA CC that only replaces the value of the CC queued just before it overwrites it, so no backlog builds
Reply timeFast (the whole sync is under a second)About 95 ms (40–240 ms); the startup sync takes about 19 s
NAM / IR importUnder a second per uploadAbout 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 NSBluetoothAlwaysUsageDescription in its Info.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 textMeaning
"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:

sh
lsusb | grep 3962     # 3962:2000 SORAN JME STOMPBOX
amidi -l              # e.g.  IO  hw:2,0,0  JME STOMPBOX MIDI 1

MIT or Apache-2.0. Not affiliated with SORAN.