qplay(1)

๐Ÿ“ฆ
this version ยท 2 versions
, in debian bookworm, debian trixie, opensuse-leap 16.0, ubuntu jammy, ubuntu noble, ubuntu questing

โœจ 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 be 2/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 was 6; qplay has a limit of 9. we went higher, no cap ๐Ÿ“ˆ
  • < โ€” decreases octave by 1. octave cannot drop below 0, she has boundaries.

๐ŸŽถ Tone commands

  • A - G โ€” plays a note in the range A-G. the number sign (#) or the plus sign (+) after a note specifies sharp; a minus sign (-) specifies flat. ๐ŸŽน
  • N n โ€” plays note n. the range for n is 0-84 (in the seven possible octaves, there are 84 notes); n = 0 means 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. L4 is a quarter note, L1 is a whole note, etc. the range for n is 1-64. the length may also follow the note, when a change of length only is desired for a particular note. for example, A16 can be equivalent to L16A. same energy, different font ๐Ÿ’…
  • MN โ€” sets "music normal" so that each note will play 7/8 of 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 play 3/4 of the time determined by the length (L).

๐Ÿฅ Tempo commands

  • P n โ€” specifies a pause, ranging from 1-64. this option corresponds to the length of each note, set with L n.
  • T n โ€” sets the "tempo", or the number of L4 quarter notes in one minute. the range for n is 32-255. the default for n is 120.
  • . โ€” a period after a note causes the note to play 3/2 times the length determined by L (length) times T (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 command A. plays 1 + 1/2, or 3/2 times the length, and A.. plays 1 + 1/2 + 1/4, or 7/4 times 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 variable var.

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