Skip to content

🎬 tracks

tracks

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.

Cookbook

Setup tracks

tracks.setup([
    tracks.mk('sampler', 0),
    tracks.mk('sampler', 1),
    tracks.mk('sampler', 2),
])

Get current tracks

trks = tracks.layout()

Reference

Track(instrument=None, track=None, muted=None, volume=None, pan=None, extra=None) dataclass

Representation of a Soir track.

Attributes:

Name Type Description
instrument str

The instrument type.

track int

The track id.

muted bool | None

The muted state. Defaults to None.

volume float | None

The volume. Defaults to None.

pan float | None

The pan. Defaults to None.

extra dict | None

Extra parameters. Defaults to None.

layout()

Get the current tracks.

Returns:

Type Description
list[Track]

list[Track]: The current tracks.

Raises:

Type Description
InLoopException

If called from inside a loop.

mk(instrument, track, muted=None, volume=None, pan=None, extra=None)

Creates a new track.

Parameters:

Name Type Description Default
instrument str

The instrument type.

required
track int

The track number.

required
muted bool

The muted state. Defaults to None.

None
volume float

The volume. Defaults to None.

None
pan float

The pan. Defaults to None.

None
extra dict

Extra parameters. Defaults to None.

None

mk_midi(track, muted=None, volume=None, pan=None, midi_device=0, audio_device=0)

Creates a new midi track.

Parameters:

Name Type Description Default
track int

The track id.

required
muted bool

The muted state. Defaults to None.

None
volume float

The volume. Defaults to None.

None
pan float

The pan. Defaults to None.

None
midi_device int

The midi device. Defaults to -1.

0
audio_device int

The audio device. Defaults to -1.

0

mk_sampler(track, muted=None, volume=None, pan=None, extra=None)

Creates a new sampler track.

Parameters:

Name Type Description Default
track int

The track id.

required
muted bool

The muted state. Defaults to None.

None
volume float

The volume. Defaults to None.

None
pan float

The pan. Defaults to None.

None
extra dict

Extra parameters. Defaults to None.

None

setup(tracks)

Setup tracks.

Parameters:

Name Type Description Default
tracks list[Track]

The tracks to setup.

required

Raises:

Type Description
InLoopException

If called from inside a loop.