TuneParse.mesa
Derived from LarkPlay.mesa
Copyright Ó 1984, 1992 by Xerox Corporation. All rights reserved.
Last Edited by: Pier, May 4, 1984 11:58:31 am PDT
Last Edited by: Swinehart, September 29, 1992 4:56 pm PDT
DIRECTORY Rope USING [ROPE];
TuneParse: CEDAR DEFINITIONS = {
Hertz: TYPE ~ INT;
Milliseconds: TYPE ~ INT;
Db: TYPE ~ INT;
Tone: TYPE = RECORD [
f1: Hertz, -- Hertz.
f2: Hertz, -- Hertz.
on, off: Milliseconds, -- Tone will be played at f2 Hz. for on ms.; then off ms. of silence.
repetitions: INT¬1 -- specifies number of repetitions of this toned
];
ToneList: TYPE = LIST OF Tone;
ToneSpec: TYPE = REF ToneSpecRec;
ToneSpecRec: TYPE = RECORD [
repeatIndefinitely: BOOL¬TRUE, -- else play just once
volume: Db¬0,
tones: ToneList¬NIL,
asRope: Rope.ROPE¬NIL -- if derived from a rope, here it is
];
ParseTune: PROCEDURE [tune: Rope.ROPE, volume: Db]
RETURNS[tones: ToneSpec];
tune is a rope of musical characters encoded via the ancient Etherphone runTune encoding.
Volume is a default: can be overridden in tune. It should be specified first, though, and be constant throughout. It is specified in -db?
MergeToneSpecs: PROCEDURE [t1, t2: ToneSpec, t2Divisor: INT¬1, t2Delay: INT¬0, volumeIncrement: Db¬0]
RETURNS [ts: ToneSpec];
Divisor and delay apply to the second tune. Delay is an additional rest, expressed in milliseconds, applied to the beginning of t2; divisor is used to change its frequency downward (designed to be used with values 1 and 2). This is specifically designed to deal with Etherphone ring tunes, where the caller's tune is to be delayed by a measure and dropped an octave.
Volume of result is volumeIncrement + volume of first tune, or something.
ts.repeatIndefinitely ← t1.repeatIndefinitely
}.