qplay(1)
โจ qplay โ convert QBASIC play strings to PCM โจ
okay bestie, welcome to qplay(1) from the hxtools collection ๐ this one is niche but SO fun, stay with me.
๐ธ SYNTAX ๐ธ
qplay [-i part] [-q part] [-r rate] [file...] | aplay -f dat -c 1
๐ DESCRIPTION ๐
so here's the tea: qplay takes QBASIC-style strings โ the ones meant for its PLAY command โ and turns them into linear 16-bit raw PCM. that's it, that's the whole job, and she does it flawlessly ๐
usually you're gonna want to pipe that output straight into a raw PCM player like aplay(1) so it actually comes out of a sound device. and listen โ turn your volume down first ๐ square waves do NOT come to play and they will jumpscare you. not a vibe.
by default, bsvplay will mix 1:1 square:sine waves to give a medium tone hardness. cute, balanced, iconic.
๐ OPTIONS ๐
-q partโ how much square wave to mix in (default:1.0) ๐ฅ-i partโ how much sine wave to mix in (default:1.0). so like, if you pass-q2 -i1, your final PCM output is gonna be2/3*squarepcm + 1/3*sinpcm. math ate, honestly ๐งฎโจ-r rateโ the PCM sample rate (default:48000 Hz) ๐ง
๐ฆ FILE FORMAT / PLAY STATEMENTS ๐ฆ
the file format qplay expects is, obviously, not BASIC โ it's raw PLAY command strings, periodt. any line starting with a leading hash mark (#) gets ignored, like it never happened ๐
commands are case insensitive and whitespace is mostly ignored, live your truth. also the original QBasic manpage is slightly incorrect (not me calling it out ๐ญ); what's below is what qplay actually supports.
๐ต Octave commands
O nโ sets the current octave. there are seven octaves,n = 0-6.>โ increases octave by 1. the upper octave limit in QBasic was6;qplayhas a limit of9. we went higher, no cap ๐<โ decreases octave by 1. octave cannot drop below0, she has boundaries.
๐ถ Tone commands
A-Gโ plays a note in the rangeA-G. the number sign (#) or the plus sign (+) after a note specifies sharp; a minus sign (-) specifies flat. ๐นN nโ plays noten. the range fornis0-84(in the seven possible octaves, there are 84 notes);n = 0means a rest. silence is valid, we love a pause ๐
โจ Suffixes
#or+โ follows a specified note and turns it into a sharp.-โ follows a specified note and turns it into a flat.
โฑ๏ธ Duration commands
L nโ sets the length of each note.L4is a quarter note,L1is a whole note, etc. the range fornis1-64. the length may also follow the note, when a change of length only is desired for a particular note. for example,A16can be equivalent toL16A. same energy, different font ๐MNโ sets "music normal" so that each note will play7/8of the time determined by the length (L).MLโ sets "music legato" so that each note will play the full period set by length (L).MSโ sets "music staccato" so that each note will play3/4of the time determined by the length (L).
๐ฅ Tempo commands
P nโ specifies a pause, ranging from1-64. this option corresponds to the length of each note, set withL n.T nโ sets the "tempo", or the number ofL4quarter notes in one minute. the range fornis32-255. the default fornis120..โ a period after a note causes the note to play3/2times the length determined byL(length) timesT(tempo). the period has the same meaning as in a musical score. multiple periods can appear after a note. each period adds a length equal to one-half the length of the previous period. for example, the commandA.plays1 + 1/2, or3/2times the length, andA..plays1 + 1/2 + 1/4, or7/4times the length. periods can appear after a pause (P). in this case, the pause length is scaled in the same way notes are scaled. dots on dots on dots, she's extra and she earned it โจ
๐ง Variables
X(var)โ play the string in the variablevar.
variable definitions in qplay syntax are for example:
$var = "CDEF";
and they must stand on a single line. one line only bestie, no line breaks, I don't make the rules ๐ซถ
๐ EXAMPLES ๐
echo "L16O2CDEFGAB>CDEFGAB>L4C" | qplay - | aplay -fdat -c1
will play a tone ladder ๐ผ climb that scale, main character energy.
๐ SEE ALSO ๐
aplay(1), bsvplay(1), hxtools(7)
fr fr that's the whole page. go make some square waves and remember: volume down first, or the jumpscare is on you ๐ญ๐
mwah ๐ this was hxtools, dated 2008-02-06 โ old but iconic, she's been serving since forever ๐
๐ฆ where this page comes from
- debian bookworm: hxtools 20221119-1 ยท MIT
- debian trixie: hxtools 20231224-2+b2 ยท MIT
- opensuse-leap 16.0: hxtools-man 20231224-bp160.1.12 ยท GPL-2.0-or-later AND WTFPL
- ubuntu jammy: hxtools 20211204-1 ยท GPL-2.0-or-later OR GPL-2+3 OR WTFPL
- ubuntu noble: hxtools 20231224-2ubuntu1 ยท MIT
- ubuntu questing: hxtools 20231224-2ubuntu1
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms