Skip to content
Kyuchumimo edited this page Jul 13, 2022 · 22 revisions

music

⚠️ This function contains default parameter values differences from the source, but for practical purposes, they do not affect its functionality. it will be fixed soon
⚠️ This function does not work properly in Pygame version 2.0.2 and higher in GNU/Linux based operating system. See: https://github.com/pygame/pygame/issues/3103
⚠️ This function does not work properly at all in Microsoft Windows operating system.
🎵 This function depends on music modules provided in assets/music filepath.

music [track=-1] [frame=0] [row=0] [loop=True] [sustain=False][NOT SUPPORTED] [tempo=-1][NOT SUPPORTED] [speed=-1][NOT SUPPORTED]

...or to stop the music:

music

Parameters

  • track : the id of the track to play (0..n)
  • frame : the index of the frame to play from (0..254)
  • row : the index of the row to play from (0..63)
  • loop : loop music (True) or play it once (False)
  • sustain : sustain notes after the end of each frame or stop them (True/False)
  • tempo : play track with the specified tempo
  • speed : play track with the specified speed

Description

This function starts playing a track

Tip

If you call music() within while True:, the specified track will restart 60 times per second - probably not what was intended! You'll need to add conditional logic to ensure that the track isn't continuously restarted, for example:

musicplaying = False

def TIC():
    # ensure we only start the music a single time
    if not musicplaying:
        music(0)
        musicplaying = true

#####################################
Clone this wiki locally