MIDI-Triggered Samples
mtrack supports triggering audio samples via MIDI events. This is useful for playing one-shot sounds like clicks, cues, sound effects, or drum samples during a performance. Samples are preloaded into memory and transcoded at startup for low-latency playback. Trigger latency is approximately 2x the audio buffer size (e.g., ~11.6ms at 256 samples/44.1kHz).
Global vs Per-Song Samples
Samples can be configured at two levels:
- Global samples - Defined in the main
mtrack.yamlconfiguration file. These are available throughout the entire session. - Per-song samples - Defined in individual song configuration files. These override or extend the global configuration when that song is selected.
Sample Configuration
Samples are defined in two parts: sample definitions (the audio files and their behavior) and sample triggers (the MIDI events that play them).
Sample Definitions
|
|
When using output_track, the sample’s output channels are resolved through the active profile’s track_mappings. This is useful when multiple hosts share a config file but have different channel assignments:
|
|
Sample Triggers
Triggers map MIDI events to samples. For Note On/Off events, only the channel and key are matched — the velocity from the incoming MIDI event is used for volume scaling or layer selection.
The preferred way to define MIDI triggers is as kind: midi inputs in the trigger configuration:
|
|
The legacy top-level sample_triggers format is still supported and automatically converted at startup:
|
|
Velocity Handling Modes
Ignore Mode
Ignores the MIDI velocity and plays at a fixed volume:
|
|
Scale Mode
Scales the playback volume based on MIDI velocity (velocity/127):
|
|
Layers Mode
Selects different audio files based on velocity ranges. Useful for realistic drum sounds:
|
|
Release Behavior
Controls what happens when a voice is released (via MIDI Note Off or audio trigger release):
play_to_completion(default) - Ignores the release, lets the sample play to the end.stop- Immediately stops the sample.fade- Fades out the sample over the configuredfade_time_ms.
Note: In configuration files, both release_behavior and note_off are accepted as key names.
Retrigger Behavior
Controls what happens when a sample is triggered while it’s already playing:
cut(default) - Stops the previous instance and starts a new one.polyphonic- Allows multiple instances to play simultaneously.
Voice Limits
To prevent resource exhaustion, you can limit concurrent voices:
|
|
When limits are exceeded, the oldest voice is stopped to make room for new ones.
Stopping All Samples
All triggered samples can be stopped via:
- OSC: Send a message to
/mtrack/samples/stop(configurable viastop_samplesin OSC controller config) - gRPC: Call the
StopSamplesRPC method
Per-Song Sample Overrides
Individual songs can override or extend the global sample configuration:
|
|