BluejayUtilsImpl.mesa
Copyright © 1986 by Xerox Corporation. All rights reserved.
Last Edited by: Swinehart, May 17, 1986 3:31:57 pm PDT
DIRECTORY
BluejaySmarts USING [ handle ],
BluejayUtils,
BluejayUtilsRpcControl USING [ ExportInterface, InterfaceName, UnexportInterface ],
Commander USING [ CommandProc, Register ],
Jukebox USING [ CloseTune, CreateTune, DeleteTune, Error, FirstNoisyIntervalIn, Info, OpenTune, Tune, TuneSize ],
LupineRuntime USING [ BindingError ],
Thrush USING [ IntervalSpec, IntervalSpecBody, IntervalSpecs, nullTune, Tune, VoiceInterval, VoiceTime ],
ThVersions USING [ JayVR ],
UserProfile USING [ Token ],
VoiceUtils USING [ CurrentPasskey, Report ]
;
BluejayUtilsImpl: CEDAR PROGRAM
IMPORTS BluejaySmarts, BluejayUtilsRpcControl, Commander, Jukebox, LupineRuntime, ThVersions, UserProfile, VoiceUtils
EXPORTS BluejayUtils = {
myName: BluejayUtilsRpcControl.InterfaceName;
utilsExported: BOOLFALSE;
Tune: TYPE = Thrush.Tune;
DescribeTune: PUBLIC PROC[tune: Tune]
RETURNS [exists: BOOLTRUE, size: INT] = TRUSTED {
t: Jukebox.Tune = Jukebox.OpenTune[self: BluejaySmarts.handle, tuneId: tune, write: FALSE!
Jukebox.Error=>GOTO NoTune];
size ← Jukebox.TuneSize[t];
Jukebox.CloseTune[BluejaySmarts.handle, t];
EXITS
NoTune => exists←FALSE;
};
DescribeInterval: PUBLIC PROC[targetTune: Thrush.Tune, targetInterval: Thrush.VoiceInterval,
minSilence: Thrush.VoiceTime ← 1]
RETURNS [exists: BOOLTRUE, intervals: Thrush.IntervalSpecs←NIL] = TRUSTED {
t: Jukebox.Tune = Jukebox.OpenTune[self: BluejaySmarts.handle, tuneId: targetTune, write: FALSE!
Jukebox.Error=>GOTO NoTune];
lastInterval: Thrush.IntervalSpecs←NIL;
start, length, end, nextStart: INT𡤀
start ← targetInterval.start;
end ← IF targetInterval.length>=0 THEN start + targetInterval.length ELSE LAST[INT];
WHILE start<end DO
int: Thrush.IntervalSpecs;
[start, length, nextStart] ← Jukebox.FirstNoisyIntervalIn[BluejaySmarts.handle, t, start, end-start, minSilence];
IF length<=0 THEN EXIT;
int ← LIST[NEW[Thrush.IntervalSpecBody ← [
tune: targetTune, interval: [start, length], direction: play]]];
IF intervals=NIL THEN intervals ← int ELSE lastInterval.rest ← int;
lastInterval ← int;
start ← MAX[nextStart, start+length];
ENDLOOP;
Jukebox.CloseTune[BluejaySmarts.handle, t];
EXITS
NoTune => exists←FALSE;
};
DeleteTune: PUBLIC PROC[tune: Tune] RETURNS [existed: BOOLTRUE] = TRUSTED {
Jukebox.DeleteTune[BluejaySmarts.handle, tune!Jukebox.Error => GOTO NoTune];
EXITS
NoTune => existed←FALSE;
};
NewTune: PUBLIC PROC RETURNS [tune: Tune←Thrush.nullTune] = TRUSTED {
t: Jukebox.Tune = Jukebox.CreateTune[self: BluejaySmarts.handle, tuneId: -1!Jukebox.Error=>GOTO NoTune];
tune ← t.tuneId;
Jukebox.CloseTune[BluejaySmarts.handle, t!Jukebox.Error=>GOTO NoTune];
EXITS
NoTune => NULL;
};
TunesInJukebox: PUBLIC PROC RETURNS [nTunes: INT𡤀] = TRUSTED {
nTunes ← Jukebox.Info[BluejaySmarts.handle!Jukebox.Error=>GOTO Problem].nTunes;
EXITS
Problem => NULL;
};
InitializeJukebox: PUBLIC PROC = TRUSTED {
nTunes: NAT = TunesInJukebox[];
FOR i: NAT IN [0..nTunes) DO
Jukebox.DeleteTune[BluejaySmarts.handle, i!Jukebox.Error=>CONTINUE]; ENDLOOP;
};
Initialize: PUBLIC PROC = {
Uninitialize[];
myName ← [
type: "BluejayUtils.Lark",
instance: UserProfile.Token[key: "BluejayServerInstance", default: "Lampson.Lark"],
version: ThVersions.JayVR
];
BluejayUtilsRpcControl.ExportInterface[
interfaceName: myName,
user: myName.instance,
password: VoiceUtils.CurrentPasskey[UserProfile.Token[
key: "BluejayServerPassword", default: "MFLFLX"]]];
VoiceUtils.Report["Bluejay Utility interface Initialized and Exported", $Bluejay];
utilsExported ← TRUE;
};
Uninitialize: PUBLIC PROC = {
IF utilsExported THEN {
BluejayUtilsRpcControl.UnexportInterface[!LupineRuntime.BindingError=>CONTINUE];
VoiceUtils.Report["Bluejay Utility interface Unexported", $Bluejay];
};
utilsExported ← FALSE;
};
InitCmd: Commander.CommandProc = TRUSTED { Initialize[]; };
UninitCmd: Commander.CommandProc = TRUSTED { Uninitialize[]; };
Commander.Register["JayUtils", InitCmd, "Start Bluejay Utilities"];
Commander.Register["UnJayUtils", UninitCmd, "Terminate Bluejay Utilities"];
}.
Swinehart, May 17, 1986 3:31:52 pm PDT
Cedar 6.1
changes to: DIRECTORY, BluejayUtilsImpl, Initialize, Uninitialize