Available on: c128z c128 sg1000 c64 vic20 atari to8 plus4 pc128op cpc sc3000 coleco coco3 msx1 coco

MUSIC

The MUSIC command starts a piece of music from the music variable. This music will be played independently of your program, without affecting it in the slightest.

Normally, it's possible to store several complete arrangements. Each composition is assigned its own individual music variable.

The music system is intelligent, and will automatically suspend your music for the duration of any subsequent sound effects on the current channel. When the sound has finished, your tune will be restarted from its previous position.

The command accepts an additional keyword, LOOP, which allows you to indicate that the piece of music must be played without ever ending playback: ugBASIC will make it start again from the beginning, once playback has finished.

Finally, the command accepts the indication of the format in which the music is stored in the variable. This specification is necessary only if the audio file was not loaded by the LOAD MUSIC command. The LOAD MUSIC command takes care of converting one of the supported formats into the internal (IAF) ugBASIC format. However, ugBASIC can play formats compatible with your audio hardware. In this case, by specifying the format in which the data is prepared, it is possible to follow up on this request.

Each target has a specific list of supported audio formats.

SYNTAX

 MUSIC [LOOP] music [format]
 MUSIC music [format] [LOOP]


Legend
  • id : identifier
  • type : datatype
  • v : value
  • "..." : string
  • [...] : optional

EXAMPLE

 MUSIC fugue
 MUSIC backmusic LOOP
 MUSIC soundtrack PSG


ABBREVIATION: Mus

Join BASIC 10Liner Contest with ugBASIC!

An interesting competition is held at the beginning of each year: the BASIC 10Liner Contest. It is possible to use ugBASIC to participate in the next "BASIC10Liner" competition, in the following categories:

  • PUR-120 - A game in 10 lines of max 120 characters (w/abbrev.)
  • EXTREME-256 - A game in 10 lines of max 256 characters (w/abbrev.)
  • SCHAU - Any program in 10 lines of max 256 characters (w/abbrev.)
In order to reduce space you can use this abbreviation for this instruction:

MUSIC ↔ Mus

Any problem?

If you have found a problem with this keyword, if you think there is a bug or, more simply, you would like it to be improved, open an issue for this example on GitHub.
Thank you!

open an issue BACK TO KEYWORDS