![]() |
|
![]() |
| ClearKey | NameToNumber | NumberToFrequency | PlayLine |
| PlayNote | PlayTune | SetKey | SetTempo |
PROCEDURE NumberToFrequency
(CONST noteNum : CARDINAL;
VAR frequency : CARDINAL);
(**
NumberToFrequency - Change a note number to a frequency in Hertz.
This procedure converts a note number to a frequency measured
in Hertz.
CALLING SEQUENCE -
NumberToFrequency (noteNum, frequency)
ENTRY -
noteNum : CARDINAL
The note number where 1=the A three below middle C,
2=A sharp (B flat), 3=B, etc. There are 13 notes in
an octave from A to A, C to C, etc.
EXIT -
frequency : CARDINAL
The frequency (in Hertz) of the given note.
*)
PROCEDURE NameToNumber
(CONST noteName : ARRAY OF CHAR;
VAR noteNum : CARDINAL);
(**
NameToNumber - Convert a notes name to a number.
This procedure converts a note's name to a note number.
CALLING SEQUENCE -
NameToNumber (noteName, noteNum)
ENTRY -
noteName : ARRAY OF CHAR
Name of the note. Example are
1A - A 3 below middle C.
3As - A Sharp 1 below middle C.
3C - Middle C
3Ef - E flat 1 above middle C.
4Fn - F natural 2 above middle C (the natural setting
is only useful if a prior SetKey causes F
to be flat or sharp).
R - A rest
note - The number preceding the note tells the
octave in which the note resides. No octave number
will default to 3. An "s" or "f" may follow the note
signifying a sharp or flat.
EXIT -
noteNum : CARDINAL
The note number where 1=the A three below middle C,
2=A sharp (B flat), 3=B, etc. There are 13 notes in
an octave from A to A, C to C, etc.
*)
PROCEDURE SetKey
(CONST note : CHAR;
CONST setting : KeySet);
(**
SetKey - Define a notes flat or sharp for the current key.
This procedure allows definition of a note's flat or sharp for
the a musical key. For example, in the key of C, all notes
are set to Natural (see ClearKey), in the key of G, F is set
to Sharp, in the key of D the SetKey procedure is called twice
to set both F and C to sharp, etc.
CALLING SEQUENCE -
SetKey (note, setting)
ENTRY -
note : CHAR
The note to set ("A" .."G").
setting : KeySet
Flat, Natural, or Sharp.
*)
PROCEDURE ClearKey;
(**
ClearKey - Clear the key settings to the key of C.
This procedure clears the key settings so that all keys are
natural or in the key of C.
*)
PROCEDURE SetTempo
(CONST beatsPerMinute : CARDINAL);
(**
SetTempo - Set the music tempo.
This procedure allows the setting of the number of beats per
minute.
CALLING SEQUENCE -
SetTempo (beatsPerMinute)
ENTRY -
beatsPerMinute : CARDINAL
Number of beats per minute. When playing a note, each
beat is equivalent to one count.
*)
PROCEDURE PlayNote
(CONST noteNum : CARDINAL;
CONST Count : REAL);
(**
PlayNote - Play a note.
This procedure plays the specified note for the required
number of counts. The length of a count is dependant upon the
current tempo (see SetTempo procedure).
CALLING SEQUENCE -
PlayNote (noteNum, count)
ENTRY -
noteNum : CARDINAL
The note number where 1=the A three below middle C,
2=A sharp (B flat), 3=B, etc. There are 13 notes in
an octave from A to A, C to C, etc. 0 is a rest.
count : CARDINAL
The count (or length of duration) of the note to be
played. If the tempo was defined as 60 beats/minute
and the count was 1.0 then the note would be played
for 1 second.
*)
PROCEDURE PlayLine
(CONST musicLine : ARRAY OF CHAR;
CONST keyInterrupt : BOOLEAN;
VAR interrupted : BOOLEAN);
(**
PlayLine - Play a line of music.
This procedure plays a tune or commands as stored on a file.
The line may contain pairs of data which represent the note
(or rest) to be played and its duration. It also contains
the key to play in and the tempo definition.
Special keywords may begin a line such as,
"TEMPO", "FLAT", or "SHARP". The Open-Paren and Asterick
pair of characters will begin a comment and the
Asterick and Close-Paren pair will end it.
"1A 2 3C .5 4D 1.5"
CALLING SEQUENCE -
PlayTune (fileName, keyInterrupt)
ENTRY -
musicLine : ARRAY OF CHAR
Array containing music instructions.
keyInterrupt : BOOLEAN
Tune will quite when the user presses any key (TRUE).
EXIT -
interrupted : BOOLEAN
Music interrupted by a user keystroke.
*)
PROCEDURE PlayTune
(CONST FileName : ARRAY OF CHAR;
CONST keyInterrupt : BOOLEAN);
(**
PlayTune - Play a tune as stored on a file.
This procedure plays a tune as stored on a file. The file
contains pairs of data which represent the note (or rest) to
be played and its duration. It also contains the key to play
in and the tempo definition. Special keywords may begin a
line such as, "TEMPO", "FLAT", or "SHARP".
The Open-Paren and Asterick pair of characters will begin a
comment and the Asterick and Close-Paren pair will end it.
TEMPO 96 -- 96 beats/minute
SHARP F C -- F & C are sharp - key of D
1A 2 3C .5 4D 1.5
R 4 3C 1
CALLING SEQUENCE -
PlayTune (fileName, keyInterrupt)
ENTRY -
fileName : ARRAY OF CHAR
Name of file containing tune code.
keyInterrupt : BOOLEAN
Tune will quite when the user presses any key (TRUE).
*)
Send mail to
warren.merrill@inl.gov
with questions or comments about this web site.
Copyright © 1989-2006 Battelle Energy Alliance