mtrack 0.12.0

A multitrack audio and MIDI player for live performances.
Documentation
// Copyright (C) 2026 Michael Wilson <mike@mdwn.dev>
//
// This program is free software: you can redistribute it and/or modify it under
// the terms of the GNU General Public License as published by the Free Software
// Foundation, version 3.
//
// This program is distributed in the hope that it will be useful, but WITHOUT
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// this program. If not, see <https://www.gnu.org/licenses/>.
//
mod audio;
mod controller;
mod dmx;
mod error;
mod hostname;
pub mod lighting;
#[cfg(test)]
pub mod midi;
#[cfg(not(test))]
mod midi;
pub mod notification;
mod player;
mod playlist;
mod profile;
pub mod samples;
mod song;
mod statusevents;
pub mod store;
mod track;
mod trackmappings;
pub mod trigger;

pub use self::audio::{Audio, ResamplerType, StreamBufferSize};
pub use self::controller::Controller;
pub use self::controller::CustomModel;
pub use self::controller::GrpcController;
pub use self::controller::MidiController;
pub use self::controller::MorningstarConfig;
pub use self::controller::MorningstarModel;
pub use self::controller::OscController;
pub use self::controller::DEFAULT_GRPC_PORT;
pub use self::dmx::Dmx;
pub use self::dmx::Universe;
pub use self::error::ConfigError;
pub use self::lighting::Lighting;
pub use self::midi::Midi;
pub use self::midi::MidiTransformer;
pub use self::midi::ToMidiEvent;
pub use self::player::Player;
pub use self::playlist::Playlist;
// Sample types are exported for external configuration
pub use self::hostname::resolve_hostname;
pub use self::notification::{NotificationConfig, SongNotificationConfig};
pub use self::profile::Profile;
#[allow(unused_imports)]
pub use self::samples::{
    ReleaseBehavior, RetriggerBehavior, SampleDefinition, SampleTrigger, SamplesConfig,
    VelocityConfig, VelocityLayer, VelocityMode,
};
pub use self::song::{LightShow, LightingShow, MidiPlayback, Section, Song};
pub use self::statusevents::StatusEvents;
pub use self::store::ConfigStore;
pub use self::track::Track;

mod kind;
pub use self::kind::{peek_kind, ConfigKind};

use std::time::Duration;

/// Parses an optional duration string (e.g. "500ms") into a `Duration`,
/// returning `default` when `raw` is `None`.
pub(crate) fn parse_playback_delay(
    raw: &Option<String>,
    default: Duration,
) -> Result<Duration, Box<dyn std::error::Error>> {
    match raw {
        Some(s) => Ok(duration_string::DurationString::from_string(s.clone())?.into()),
        None => Ok(default),
    }
}