Reading pedal state
How DeviceState follows the pedal from its MIDI traffic, what each Event tells you, and where to find presets, the live sound, looper, drum, tuner, settings and user slots. The state module is pure, so it works with the engine or with your own transport.
Apply every message
DeviceState is a model of the pedal. Apply every complete MIDI message to it, from either direction, and reset it when a new session starts.
use open_stomp::device::Update;
use open_stomp::{Category, DeviceState};
let mut state = DeviceState::default();
while let Ok(update) = dev.recv() {
match update {
Update::Reset => state = DeviceState::default(),
Update::Message { origin, bytes, .. } => {
let ev = state.apply(&bytes, origin);
if ev.category != Category::Protocol && !ev.redundant {
println!("{:8} {} = {}", ev.category.label(), ev.subject, ev.value);
}
}
_ => {}
}
}from open_stomp import DeviceState
state = DeviceState()
for u in dev:
ev = state.feed(u) # applies "message", clears on "reset", else None
if ev and ev.category != "protocol" and not ev.redundant:
print(ev) # AMP Mar J800 · GAIN = 64apply(bytes, origin)applies one complete message and returns anEvent. Python also hasfeed(update), which handlesUpdates directly.- Your own edits: the pedal never echoes host messages. The engine reports everything it sends as an
Origin::Hostmessage, so applying everyUpdate::Messagekeeps the state right for your edits too. - Sent another way? If you send through another path, apply your bytes yourself with
Origin::Host.
Events
Event field | Meaning |
|---|---|
origin | Origin::Pedal (pedal → host) or Origin::Host (host → pedal: your program, or the official app in a replay) |
category | What kind of change; see the table below |
subject, value | Plain English, e.g. "Mar J800 · GAIN" and "64" |
coalesce | A key: consecutive events with the same key are one gesture (a knob sweep) and can be merged in a log |
redundant | The message changed nothing (the CC burst after a preset change repeating known values, values for unused parameter slots) |
raw | The message bytes |
Rust Category | label() | Python category |
|---|---|---|
Preset | PRESET | "preset" |
Effect(Module) | The module name, e.g. AMP | "effect" (the module is in ev.module) |
Volume | VOLUME | "volume" |
Navigation | PAGE | "navigation" |
Looper | LOOPER | "looper" |
Drum | DRUM | "drum" |
Tuner | TUNER | "tuner" |
Settings | SETTINGS | "settings" |
Device | DEVICE | "device" |
Protocol | SYSEX | "protocol": request/reply plumbing (handshake reads, acks, upload chunks) |
Unknown | ??? | "unknown" |
In Python the display label is ev.label, and str(ev) joins label, subject and value.
What it tracks
| Field | What | Filled by |
|---|---|---|
firmware, model_id, product | "V1.1.1", "JME-01", "JME STOMPBOX" | Version and product short frames |
presets | 99 × Option<Preset> (None until read) | 0x0B replies and writes |
current | Active preset index (0-based), or None | Program changes; edit-buffer matching after the sync |
live, live_known | The edit buffer: the stored preset plus every change since | Preset changes, CCs (heads, params, volume), renames, chain moves |
page | The module the pedal's display shows | CC 0x3B |
looper, drum, tuner | See below | Their CCs and SysEx records |
settings | Option<Settings> | 0x14 replies and writes |
user_amps, user_irs | 10 × Option<String>: user slot names | Slot-info replies, imports, renames |
The byte layouts behind these are on the Preset record and Other records pages.
Presets, live sound and changes
presets[i]is the stored preset in sloti(P01 = 0), once the sync has read it.currentis the active slot. It isNoneuntil a program change, or until the edit buffer matched a stored preset after the sync.liveis what the pedal plays now.live_knownsays whether it has been read or loaded from a stored preset yet.modified()is true whenlivesounds different from the stored preset (unused parameter slots are ignored).
| Method | Returns |
|---|---|
stored(i) | The stored preset in slot i, if read |
preset_name(i) | Its name, if read |
modified() | Whether the live sound differs from the stored preset |
model_name(module, model) | A model's display name, using user slot names for user models |
select_preset(i) | Updates the model only: sets current and loads the stored preset into live. It sends nothing; to switch presets on the pedal use Device::select_preset |
When the active slot is identified after the sync, the edit buffer is matched against the stored presets. If the edit buffer has unsaved edits, the match fails and current stays None until the next preset change.
if let Some(i) = state.current {
let name = state.preset_name(i).unwrap_or("?");
let star = if state.modified() { "*" } else { "" };
println!("{} {name}{star}", open_stomp::state::preset_label(i)); // P05 Lead*
}from open_stomp.records import preset_label
if state.current is not None:
star = "*" if state.modified() else ""
print(preset_label(state.current), state.preset_name(state.current), star)Looper, drum and tuner
looper field | Meaning |
|---|---|
state | 0 empty, 1 recording, 2 playing, 3 overdubbing, 4 stopped; state_name() gives the word |
layers | 0x1 = an overdub layer on top (undo available), 0x2 = base layer only |
rec_level, play_level | Record and playback levels, 0–100 |
sync | LOOP SYNC on or off |
mode | 0 NR, 1 AR |
drum field | Meaning |
|---|---|
playing | Running or stopped |
pattern | Flat pattern number, style × 10 + pattern; catalog::drum_pattern_name(v) gives e.g. "Rock 04" |
level | 0–100 |
bpm | Tempo; it only travels in SysEx 0x19 (there is no tempo CC) |
tuner field | Meaning |
|---|---|
active | Tuner mode on |
detected | A note is being detected |
note | Index into catalog::NOTES ("C", "C#", …) |
cents | Raw, 50 = in tune; cents_offset() gives −50…+50 |
Fields that the pedal hasn't reported yet are None. In Python state_name and cents_offset are properties.
Settings
state.settings holds the global settings record once the sync has read it: input trim, global EQ, wireless and loopback. To change them, see Presets and settings.
User slots
user_amps[i],user_irs[i]: the names of USER AMP and USER IR slotsi(0–9). An empty user AMP slot reads back as"USER AMP NN".- In events: user models are amp and cab models 30–39, and
model_name()shows the slot's name next to the model name. - Imports and renames update these names: the state applies the name records they send, and renames and deletes re-read the slot (User AMP and IR slots).
Python attributes are snapshots
Changing a copy changes nothing
state.live, state.presets[3], preset.modules and so on return copies; the model changes only through apply or feed. To edit, take a copy, change it, and send it (saving a preset).
Helpers
| Rust | Python | Gives |
|---|---|---|
state::preset_label(i) | records.preset_label(i) | "P01" for 0 |
state::chain_label(&chain) | "GATE > OD/FX > AMP > …" | |
state::looper_state_name(s) | state.looper_state_name(s) | "Recording" and so on |
catalog::drum_pattern_name(v) | catalog.drum_pattern_name(v) | "Rock 04" for 13 |
catalog::NOTES | catalog.NOTES | Tuner note names |
