Name

qplay — convert QBASIC play strings to PCM

Syntax

qplay [-i part] [-q part] [-r rate] [ file...] | aplay -f dat -c 1

Description

qplay will convert QBASIC-style strings for its "PLAY" command to linear 16-bit raw PCM. Normally, you will be wanting to pipe it into a raw PCM player like aplay(1) to actually output it to a sound device. Be sure to lower the volume beforehand to avoid nasty surprises that come with square waves. By default, bsvplay will mix 1:1 square:sine waves to give a medium tone hardness.

Options

-q part
Part to mix square waves in (default: 1.0)
-i part
Part to mix sine waves in (default: 1.0). If -q2 -i1 is specified for example, the final PCM output will consist of 2/3*squarepcm + 1/3*sinpcm.
-r rate
PCM sample rate (default: 48000 Hz)

File format / PLAY statements

The file format qplay expects is of course not BASIC, but raw PLAY command strings. Lines that start with a leading hash mark (' #') are ignored.
Commands are case insensitive and whitespace is mostly ignored. The original QBasic manpage is slightly incorrect; below is what qplay supports.

Octave commands

on
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.
<
Decreases octave by 1. Octave cannot drop below 0.

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.

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 particualr note. For example, A16 can be equivalent to L16A.
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 lengt (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.

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.

Examples

	echo "L16O2CDEFGAB>CDEFGAB>L4C" | qplay - | aplay -fdat -c1
will play a tone ladder.

See also

aplay(1), bsvplay(1), hxtools(7)

Recommended readings

Pages related to qplay you should read also: