Decode and play audio to OPTION AUDIO_TARGET. HDMI sends IEC958 stereo on HDMI0. JACK sends PWM to the 3.5mm analogue socket (Pi 3 / Pi 4B). Pi 400 has no analogue jack; use HDMI there. PLAYING() is 1 while audio is playing and not paused.
PLAY STOP PLAY RESET PLAY PAUSE PLAY RESUME PLAY VOLUME left [, right] PLAY TONE left, right [, duration] PLAY MP3 file$ PLAY WAV file$ PLAY MODFILE file$ (PLAY MOD file$) PLAY XM file$ (PLAY XMFILE file$) PLAY S3M file$ (PLAY S3MFILE file$)
BEEP [frequency [, duration]]
left, right - TONE frequencies in Hz, or VOLUME levels frequency - BEEP pitch in Hz (default 800) duration - TONE / BEEP length in milliseconds; for TONE omit to hold
until PLAY STOP (BEEP defaults to 120)
file$ - audio file path
On systems without audio output, files decode but no sound is heard; PLAYING() reflects playback state.
About a third of a second of audio stays queued. The mixer also runs during long screen updates, including a TERM repaint on another console. MM.INFO(“MIXGAP”) is the longest gap between mixer services since PLAY started, in milliseconds. MM.INFO(“UNDERRUN”) counts times the output queue was empty when the mixer ran.
If other USB activity stalls the output device, the mixer restarts the transfer automatically once data is queued again. PLAY RESET is an explicit recovery if artifacts persist: it tears down and re-creates the output device and clears its buffers, without stopping the current track or rebooting. A playing track resumes in place from the mixer’s current position. MM.INFO(“AUDIORESET”) counts how many times PLAY RESET has run.
MOD, XM and S3M modules play through once and then stop (loops and jumps that are part of the arrangement are honoured; the restart/order loop is not). JUKE uses this to advance a folder queue to the next file.
MP3 files are streamed: PLAY reads the file in chunks and can start after a small read-ahead, so a long track does not have to fit in RAM. MM.INFO(“MP3BUF”) reports the peak bytes the decoder allocated. MP3s at 22.05, 32, 44.1 and 48 kHz are resampled to the 44100 Hz mixer, so duration and pitch match the source; MM.INFO(“MP3RATE”), “MP3SRC” and “MP3OUT” report the last file’s source rate and decoded/mixed frame counts.
Example:
OPTION AUDIO_TARGET HDMI
PLAY WAV "tests/TEST.WAV"
PLAY MP3 "tests/TEST.MP3"
PLAY S3M "tests/TEST.S3M"
PRINT PLAYING()
Source: docs/help/play.txt inmmcore. On the computer, typeHELP PLAY.