Expand description
§mseq
mseq is a lightweight MIDI sequencer framework written in Rust.
It provides a flexible core for building sequencers that can run in standalone, master, or
slave mode, with synchronization over standard MIDI clock and transport messages.
§Overview
The sequencer is driven by a user-provided Conductor implementation, which defines how the
sequencer initializes, progresses at each clock tick, and reacts to external MIDI messages.
The core engine manages timing, MIDI input/output, and synchronization.
- No input → runs standalone with its internal clock and transport, generating MIDI clock and transport messages but ignoring external MIDI input.
- Master mode → runs with its internal clock while also processing incoming MIDI events (except for external clock/transport).
- Slave mode → synchronizes playback to an external MIDI clock and responds to Start/Stop/Continue messages, dynamically adjusting BPM to match the clock source.
§Usage
The entry point of the crate is the run function:
use mseq::{run, Conductor, Context, Instruction, MidiInParam, MidiMessage};
struct MyConductor;
impl Conductor for MyConductor {
fn init(&mut self, _ctx: &mut Context) -> Vec<Instruction> {
// Return setup instructions (e.g., reset all controllers)
vec![]
}
fn update(&mut self, _ctx: &mut Context) -> Vec<Instruction> {
// Called each clock tick: return note events or other MIDI instructions
vec![]
}
fn handle_input(&mut self, input: MidiMessage, _ctx: &Context) -> Vec<Instruction> {
vec![]
}
}
fn main() -> Result<(), mseq::MSeqError> {
let conductor = MyConductor;
let out_port = None; // Ask user for output port
let midi_in = None; // Run standalone (no input, master clock/transport)
run(conductor, out_port, midi_in)
}§Features
Modules§
- acid
- The
acidmodule provides tools for generating and loading acid-style tracks into MSeq. - arp
- The
arpmodule provides tools for generating and loading arp-style tracks into MSeq. - div
- The
divmodule provides tools for generating and loading clock divider-style tracks into MSeq. - index
- The
indexmodule provides functionality for loading multiple track types into the MSeq sequencer from a unified.tomlindex file. - midi
- The
midimodule provides tools for generating and loading MIDI tracks into MSeq.
Structs§
- Context
- An object of type
Contextis passed to the user’sConductorat each clock tick via theConductor::updatemethod. It provides a high-level interface to send system MIDI messages and modify system parameters. - Dete
Track - A deterministic track implementation.
- Midi
Controller - Provides a reusable MIDI interface and core logic across different platforms.
- Midi
InParam - MIDI input connection parameters.
- Midi
Note - Note that can be sent through a MIDI message.
Enums§
- Ignore
- An enum that is used to specify what kind of MIDI messages should be ignored when receiving messages.
- Instruction
- Represents instructions that can be interpreted and processed by the
MidiController. - MSeq
Error - Error type of mseq
- Midi
Message - Represents a parsed MIDI instruction.
- Note
- Represents 1 note of the chromatic scale.
- Track
Error - An error type representing issues that may occur when loading or generating tracks.
Traits§
- Conductor
- Entry point for user-defined sequencer behavior.
- MidiOut
- This trait is not intended to be implemented by user code.
- Track
- Abstraction for a sequencer track.
Functions§
- param_
value - Performs a linear conversion from
[0.0, 1.0]to [0, 127]. Ifvis smaller than0.0return 0. Ifvis greater than1.0return 127. The main purpose of this function is to be used with MIDI control changes (CC). - run
mseqentry point.
Type Aliases§
- Input
Queue - Inputs queue to process.