soir

OVERVIEW

The tracks module provides a way to setup and control tracks in the

soir engine. A track has an instrument type and a set of parameters and effects. Once a track is created, loops can be scheduled on it. Tracks can be added & removed in real-time using the setup() function, existing tracks are untouched.

@public

tracks.setup({
    'bass': tracks.mk_sampler(fxs={
        'reverb': fx.mk_reverb(mix=0.2),
    }),
    'melody': tracks.mk_sampler()
})

CLASS

Track

Track(name: str = 'unnamed', instrument: str = 'unknown', muted: bool | None = None, volume: float | soir.rt.ctrls.Control = 1.0, pan: float | soir.rt.ctrls.Control = 0.0, fxs: dict[str, soir.rt.fx.Fx] = <factory>, extra: str | None = None) -> None

Representation of a Soir track.

Arguments

Name Type Description
name The track name.
instrument The instrument type.
muted The muted state. Defaults to None.
volume The volume in the [0.0, 1.0] range. Defaults to 1.0.
pan The pan in the [-1.0, 1.0] range. Defaults to 0.0.
fxs The effects as an ordered dict mapping names to Fx objects.
extra Extra parameters, JSON encoded. Defaults to None.

FUNCTION

layout

layout() -> dict[str, soir.rt.tracks.Track]

Get the current tracks.

Returns

dict[Track] – The current tracks.

Raises

Exception Description
InLoopException If called from inside a loop.

mk

mk(instrument: str, muted: bool | None = None, volume: float | soir.rt.ctrls.Control = 1.0, pan: float | soir.rt.ctrls.Control = 0.0, fxs: dict[str, soir.rt.fx.Fx] | None = None, extra: dict[str, object] | None = None) -> soir.rt.tracks.Track

Creates a new track.

Arguments

Name Type Description
instrument str The instrument type.
muted bool The muted state. Defaults to None.
volume float | Control The volume in the [0.0, 1.0] range. Defaults to 1.0.
pan float | Control The pan in the [-1.0, 1.0] range. Defaults to 0.0.
fxs The effects to apply to the track, as an ordered dict.
extra dict Extra parameters. Defaults to None.

mk_external

mk_external(muted: bool | None = None, volume: float | soir.rt.ctrls.Control = 1.0, pan: float | soir.rt.ctrls.Control = 0.0, midi_out: str | None = None, audio_in: str | None = None, audio_chans: list[int] | None = None, fxs: dict[str, soir.rt.fx.Fx] | None = None) -> soir.rt.tracks.Track

Creates a new external device track.

Arguments

Name Type Description
muted The muted state.
volume The volume in [0.0, 1.0].
pan The pan in [-1.0, 1.0].
midi_out MIDI output device name.
audio_in Audio input device name.
audio_chans Channel mapping [L_source, R_source]. Required if audio_in set.
fxs The effects to apply to the track, as an ordered dict.

mk_sampler

mk_sampler(muted: bool | None = None, volume: float | soir.rt.ctrls.Control = 1.0, pan: float | soir.rt.ctrls.Control = 0.0, fxs: dict[str, soir.rt.fx.Fx] | None = None) -> soir.rt.tracks.Track

Creates a new sampler track.

Arguments

Name Type Description
muted bool The muted state. Defaults to None.
volume float | Control The volume in the [0.0, 1.0] range. Defaults to 1.0.
pan float | Control The pan in the [-1.0, 1.0] range. Defaults to 0.0.
fxs The effects to apply to the track, as an ordered dict.

setup

setup(tracks: dict[str, soir.rt.tracks.Track]) -> bool

Setup tracks.

Arguments

Name Type Description
tracks dict[str, Track] The tracks to setup.

Raises

Exception Description
InLoopException If called from inside a loop.