Crate mseq

Source
Expand description

Library for developing MIDI Sequencers.

To start using mseq, create a struct that implements the Conductor trait.

You can then add tracks to your sequencer by adding fields (to your struct that implements the Conductor trait) of type DeteTrack or more generally fields that implement the trait Track.

Once this is done, you can play your track in the Conductor::update function of your struct that implements the Conductor trait. To do so, call the method MidiController::play_track (of the Context::midi) with the track you want to play as a parameter.

You can find some examples in the examples directory.

Structs§

AcidTrig
Trig used to create acid tracks with DeteTrack::new_acid. Each Trig represents one sixteenth step. AcidTrig provides a similar interface to the original Roland TB-303 with some slight modifications.
ClockDiv
Struct used in DeteTrack::new_clock_div to generate a track with a pattern based on clock divisions.
Context
An object of type Context is passed to the user Conductor at each clock tick through the method Conductor::update. This structure provides the user with a friendly MIDI interface. The user can set some MIDI System Parameters (e.g., Context::set_bpm) or send some MIDI System Messages (e.g., Context::start) using directly the Context methods. The user can also send MIDI Channel Messages (e.g., MidiController::play_note or MidiController::play_track) using the field Context::midi.
DeteTrack
DeteTrack implements the Track trait, so it can be passed to the MidiController to play it. It is defined by a list of notes that will always play at the same time in the track, hence the name (Deterministic Track).
MidiController
The MidiController provides a MIDI interface to the user.
MidiNote
Note that can be sent through a MIDI message.

Enums§

ArpDiv
Time division of the arpeggiator
MSeqError
Error type of mseq
Note
Represents 1 note of the chromatic scale.
Timing
Timing mostly used in AcidTrig to generate acid tracks.

Traits§

Conductor
The Conductor trait is the trait that the user has to implement to be able to use mseq. The user has to implement Conductor::init and Conductor::update, then pass the Conductor to the main entry point crate::run. Refer to these examples for complete implementation examples.
MidiConnection
This trait should not be implemented in the user code. The purpose of this trait is be able to reuse the same code with different midi API, using static dispatch.
Track
The Track trait can be implemented by the client. A struct with the Track trait can be passed to the MidiController to play it through a midi connection. This allows to reduce the amount of code in the Conductor by writing each track independently.

Functions§

param_value
Perform a linear conversion from [0.0, 1.0] to [0, 127]. If v is smaller than 0.0 return 0. If v is greater than 1.0 return 127. The main purpose of this function is to be used with MIDI control changes (CC).
run
mseq entry point. Run the sequencer by providing a conductor implementation. port is the MIDI port id used to send the midi messages. If set to None, information about the MIDI ports will be displayed and the output port will be asked to the user with a prompt.