trackplayer – Single Track component of songplayer

trackplayer

Simple player: Single track with single voice, using sleep for timing

class trackplayer.TrackPlayer(tone, track=[], bpm=60, articulation=0.05)[source]

Player for music tracks

Initialize track player

Parameters
  • tone (sound) – A sound from soundlib.SoundMaker.

  • track (list) – The notes of your song. A list of (pitch, duration) tuples. Units are (Hz, Beats).

  • bpm (int) – Tempo. The speed of your song in beats-per-minute.

  • articulation (float) – Articulation gap between notes. The fraction of duration to use as a gap. 0=”slur notes together”.

play()[source]

Play the track! Will block, and return when track is finished playing.

set_bpm(bpm)[source]

Set a new tempo to use for this player.

Parameters

bpm (int) – Tempo. The speed of your song in beats-per-minute.

set_tone(tone)[source]

Set a new tone to use for this player.

Parameters

tone (sound) – A sound from soundlib.SoundMaker.

set_track(track)[source]

Set a new track list to use for this player.

Parameters

track (list) – The notes of your song. A list of (pitch, duration) tuples.

Download Source