Skip to main content

Crate deepmind_midi

Crate deepmind_midi 

Source
Expand description

Sans-IO protocol library for Behringer DeepMind synthesizers.

This crate models the DeepMind MIDI protocol and nothing else. It never opens a port, never spawns a thread and never blocks. The host application owns the transport, feeds inbound bytes in and sends outbound bytes out.

DeepMind <--MIDI--> host application <--bytes--> deepmind-midi

§Layout

ModuleResponsibility
idsAddressing primitives: device ID, model, bank, program number
errorCrate-wide error type
wireMIDI bytes: running status, channel messages, SysEx reassembly
sysexDeepMind framing, the packed MS-bit codec, typed messages
paramThe 242 program parameters: names, ranges, value tables, NRPN
effectWhat an effect engine’s twelve bytes are, per algorithm
frontWhat the instrument’s own front panel puts a control under
generatorThe shapes a set of parameters makes, for a host that draws them
pixelsThe one-bit grid of the marks, the source cells and the glyphs
programA program: the 242 bytes, typed accessors, names, value types
syx.syx files: the programs a preset pack carries, and building one
deviceThe state machine: what the synthesizer holds, and what to send
transportThe blocking adapter over a port and a clock (feature transport)
simThe other end of the conversation, for tests (feature sim)

Each layer depends only on those above it: wire does not know what a DeepMind is, and sysex does not know where its bytes came from.

use deepmind_midi::ids::DeviceId;
use deepmind_midi::sysex::{Frame, Message};
use deepmind_midi::wire::{Decoder, Event};

// Bytes off a port, in whatever chunks they arrived in.
let mut decoder: Decoder = Decoder::new();
decoder.feed(&[0xF0, 0x00, 0x20, 0x32, 0x20, 0x00, 0x03, 0xF7], |event| {
    if let Ok(Event::SysEx(bytes)) = event {
        let frame = Frame::parse(bytes).expect("a DeepMind frame");
        assert_eq!(frame.device, DeviceId::Unit(0));
        assert_eq!(frame.message, Message::EditBufferDumpRequest);
    }
});

See docs/architecture.md for the design and docs/midi-spec.md for the protocol itself.

§Feature flags

  • std (default): implies alloc, and adds transport::StdClock when transport is on. The error types implement core::error::Error with or without it.
  • alloc: APIs that allocate, such as bank decoding and .syx handling.
  • serde: Serialize/Deserialize derives on the public data types.
  • transport: the blocking adapter, which is the one part of this crate that knows what IO is. Needs neither std nor an allocator.
  • sim: a synthesizer to talk to, for testing a host without one plugged in.
  • descriptions: what a parameter or an effect slot does, in a sentence. param::ParamId::description and effect::FxSlot::description answer None without it and a sentence with it, so a host writes one code path and an embedded build carries no prose.

Re-exports§

pub use device::Device;
pub use device::Known;
pub use effect::Algorithm;
pub use effect::Engine;
pub use error::Error;
pub use error::Result;
pub use ids::Bank;
pub use ids::DeviceId;
pub use ids::Model;
pub use ids::PatternNumber;
pub use ids::ProgramNumber;
pub use ids::ProtocolVersion;
pub use ids::Slot;
pub use param::Group;
pub use param::NrpnEdit;
pub use param::ParamId;
pub use program::Program;
pub use program::ProgramName;
pub use sysex::Command;
pub use sysex::Frame;
pub use sysex::Message;
pub use transport::Transport;transport
pub use wire::Channel;
pub use wire::ChannelMessage;
pub use wire::Decoder;

Modules§

device
The state machine a host drives: what the synthesizer holds, and what to send.
effect
The effect panels: what an engine’s twelve bytes mean, and which algorithm decides.
error
Crate-wide error type.
front
The front of the synthesizer: which parameters have a physical control, what is printed over them, and which of the panel’s two rows they are in.
generator
The shapes a set of parameters makes, for a host that draws them.
ids
Addressing primitives used throughout the protocol.
param
The parameter table: what each of the 242 program parameters is, and how it reaches the wire.
pixels
A square one-bit grid, for a display too small to stroke anything.
program
A program: the 242 bytes that are one sound, and the types that read them.
simsim
A synthesizer to talk to, made of the same protocol.
sysex
DeepMind SysEx: framing, the packed MS-bit codec and typed messages.
syx
.syx files: the format programs are traded in, read and written.
transporttransport
The blocking adapter: a port, a clock, and the loop between them.
wire
MIDI bytes: status, channel messages and SysEx reassembly.