VoiceRecordImpl.mesa
Copyright Ó 1987 by Xerox Corporation. All rights reserved.
Ades, September 24, 1986 5:11:21 pm PDT
Swinehart, February 28, 1988 11:42:05 pm PST
Polle Zellweger (PTZ) September 12, 1988 8:39:59 pm PDT
Venkat Rangan November 4, 1989 4:36:44 pm PST
DIRECTORY
BasicTime USING [GetClockPulses, MicrosecondsToPulses, Pulses, PulsesToMicroseconds ],
Convert USING [RopeFromInt],
FinchSmarts USING [RegisterForReports, ReportConversationStateProc, ReportRequestStateProc],
MessageWindow USING [Append, Blink ],
Process USING [Detach, MsecToTicks, Pause, Priority, priorityRealTime, SetPriority ],
Rope USING [Concat, ROPE ],
TextEdit USING [GetCharProp, InsertChar, PutCharProp, Size ],
TextLooks USING [RopeToLooks ],
TextNode USING [Ref],
TiogaButtons USING [TextNodeRef],
TiogaExtraOps USING [GetTextKey, PutTextKey, RemoveTextKey, TextKeyNotFound ],
TiogaOps USING [CallWithLocks, CommandProc, FirstChild, GetSelection, NoSelection, Root, SelectionGrain, SetSelection, ViewerDoc ],
TiogaOpsDefs USING [Location, Ref ],
TiogaVoicePrivate USING [ ApplyToLockedChars, BuildVoiceViewer, ButtonParams, CancelPlayBack, DeleteVoiceFromChar, DescribeSelection, LockedAddCharMark, MakeVoiceEdited, PlayBackInProgress, RedrawViewer, ReplaceSelectionWithSavedInterval, Selection, SelectionRec, SelectionsAfterRedraw, SetParentViewer, SetPlayBackState, SetViewerContents, SetVoiceViewerEditStatus, SoundChars, SoundInterval, SoundIntervalRec, SoundList, SoundListFromIntervalSpecs, soundRopeCharLength, soundRopeCharsPerSecond, thrushHandle, VoiceViewerInfo, VoiceWindowRec ],
ViewerClasses USING [MouseButton, Viewer ],
ViewerOps USING [DestroyViewer, FetchProp],
VoiceRope USING [DescribeRope, GetClientData, NB, NewRequestID, RecordNB, RequestID, StopNB, VoiceRope, VoiceRopeInterval ]
;
VoiceRecordImpl:
CEDAR
MONITOR
IMPORTS BasicTime, Convert, FinchSmarts, MessageWindow, Process, Rope, TextEdit, TextLooks, TiogaButtons, TiogaExtraOps, TiogaOps, TiogaVoicePrivate, ViewerOps, VoiceRope EXPORTS TiogaVoicePrivate = {
basic code to add voice to windows of both text and voice, also the DictationMachine button which transfers input from a current window to a newly created dictation window
recordingState:
RECORD [
recordingInProgress: BOOLEAN ← FALSE,
addingIntoTextViewer:
BOOLEAN,
the selection where the voice is to be added, as a TiogaOps node: a text key gives the position within the node but that is implicitly represented by the atom $recordingMark
node: TiogaOpsDefs.Ref,
the selection where the voice is to be added, as a TiogaOps node: a text key gives the position within the node but that is implicitly represented by the atom $recordingMark
textViewer: ViewerClasses.Viewer,
the viewer where the voice is to be added, if a text viewer
soundSelection: TiogaVoicePrivate.Selection,
the selection where the voice is to be added, as a TiogaVoicePrivate selection
cueInsertPosition: INT, -- where the little arrows will go
timeInSoundChars:
INT,
how long has the recording been going on, in terms of sound characters generated
requestID: VoiceRope.RequestID,
nb: VoiceRope.NB,
nextWakeUp: BasicTime.Pulses, -- clock for timing recording
timerState: {off, quit, on},
newRope: VoiceRope.VoiceRope
the rope that is created as the result of this recording process
timerOff, recordingDone:
CONDITION;
RecordingInProgress:
PUBLIC
PROC
RETURNS [
BOOLEAN] = {
RETURN [recordingState.recordingInProgress] };
CancelProc:
PUBLIC TiogaOps.CommandProc = {
PROC [viewer: Viewer ← NIL] RETURNS [recordAtom: BOOL ← TRUE, quit: BOOL ← FALSE]; viewer prop $ButtonParams = TiogaVoicePrivate.ButtonParams
IF VoiceRope.StopNB[TiogaVoicePrivate.thrushHandle] # $success
THEN {
StopRecording[];
TiogaVoicePrivate.CancelPlayBack[];
Otherwise these shouldn't be needed - $finished reports should clear recording/playback queues automatically.
};
};
AddVoiceProc:
PUBLIC
ENTRY TiogaOps.CommandProc = {
PROC [viewer: Viewer ← NIL] RETURNS [recordAtom: BOOL ← TRUE, quit: BOOL ← FALSE]; viewer prop $ButtonParams = TiogaVoicePrivate.ButtonParams
the procedure behind all AddVoice buttons
buttonParams: TiogaVoicePrivate.ButtonParams ← NARROW[ViewerOps.FetchProp[viewer, $ButtonParams]];
mouseButton: ViewerClasses.MouseButton ← IF buttonParams#NIL THEN buttonParams.mouseButton ELSE $red;
IF recordingState.recordingInProgress
THEN {
BlinkMessageWindow["Already recording"];
RETURN;
};
IF TiogaVoicePrivate.PlayBackInProgress[]
THEN {
BlinkMessageWindow["Cancel playback before trying to record"];
RETURN;
}; -- PlayBackInProgress is only a hint: to be sure we'll do a cancel to avoid race conditions
TiogaVoicePrivate.CancelPlayBack[];
IF ~PrepareSelection[] THEN RETURN;
StartRecording[mouseButton = $red];
};
PrepareSelection:
INTERNAL
PROC
RETURNS [succeeded:
BOOLEAN ←
FALSE] = {
this procedure locks the selection and fills in the TiogaOps target info above. If the selection is a voice selection then recordingState.soundSelection is set up. If the selection is text then a text key is placed in the text. If the selection is pending delete then the delete is done. If the selection is a voice selection then the viewer is locked [against other voice edits]
targetViewer: ViewerClasses.Viewer;
targetStart, targetEnd: TiogaOpsDefs.Location;
targetCaretBefore, targetPendingDelete: BOOLEAN;
alreadyBeingEdited: BOOLEAN ← FALSE;
alreadyVoiceThere: BOOLEAN ← FALSE;
suitableViewer: BOOLEAN;
DoIt:
INTERNAL
PROC [root: TiogaOpsDefs.Ref] = {
level: TiogaOps.SelectionGrain;
[viewer: targetViewer, start: targetStart, end: targetEnd, caretBefore: targetCaretBefore, pendingDelete: targetPendingDelete, level: level] ← TiogaOps.GetSelection[];
suitableViewer ← targetViewer.class.flavor = $Text;
IF suitableViewer
THEN {
recordingState.addingIntoTextViewer ← ViewerOps.FetchProp[targetViewer, $voiceViewerInfo] = NIL;
IF recordingState.addingIntoTextViewer
THEN {
targetChar: TiogaOpsDefs.Location ← IF targetCaretBefore THEN targetStart ELSE targetEnd;
node: TextNode.Ref ← TiogaButtons.TextNodeRef[targetChar.node]; -- just a type convertor
IF targetPendingDelete
THEN {
TiogaVoicePrivate.ApplyToLockedChars[TiogaVoicePrivate.DeleteVoiceFromChar];
TiogaOps.SetSelection[viewer: targetViewer, start: targetStart, end: targetEnd, level: level, caretBefore: targetCaretBefore,
pendingDelete: FALSE, which: primary] -- simply makes not pending delete
};
IF TextEdit.Size[node] <= targetChar.where
THEN
point selection with no following char, try preceding char if there is one
targetChar.where ← MAX[targetChar.where-1, 0];
alreadyVoiceThere ← TextEdit.GetCharProp[node, targetChar.where, $voice] # NIL;
recordingState.node ← targetChar.node;
recordingState.textViewer ← targetViewer;
IF ~alreadyVoiceThere THEN TiogaExtraOps.PutTextKey[targetChar.node, targetChar.where, $recordingMark]
}
ELSE {
[selection: recordingState.soundSelection, failed: alreadyBeingEdited] ← TiogaVoicePrivate.DescribeSelection[which: primary, forceDelete: FALSE, returnSoundInterval: FALSE];
IF alreadyBeingEdited THEN RETURN;
IF recordingState.soundSelection.ropeInterval.length # 0
-- pending delete
AND TiogaVoicePrivate.ReplaceSelectionWithSavedInterval[
recordingState.soundSelection, NIL, FALSE].viewerDeleted
THEN NewDictationWindow[]; -- this means "if applicable, do the pending delete. If that delete should reduce the window contents to zero it will disappear, so create a new one"
recordingState.cueInsertPosition ← MIN [targetSoundSelection.ropeInterval.start/TiogaVoicePrivate.soundRopeCharLength, TextEdit.Size[TiogaButtons.TextNodeRef[TiogaOps.FirstChild[TiogaOps.ViewerDoc[targetSoundSelection.viewer]]]]-1] -- because you can't position the cursor as a point after the last character
recordingState.cueInsertPosition ← recordingState.soundSelection.ropeInterval.start/ TiogaVoicePrivate.soundRopeCharLength
}
}
}; -- end of DoIt
TiogaOps.CallWithLocks[DoIt ! TiogaOps.NoSelection => {suitableViewer ← FALSE; CONTINUE}];
test for failure conditions and report them to the user after releasing the viewer lock
SELECT
TRUE
FROM
NOT suitableViewer => BlinkMessageWindow["Make a selection in a Tioga viewer first"];
alreadyBeingEdited => BlinkMessageWindow["Previous voice editing operation has yet to complete"];
alreadyVoiceThere => BlinkMessageWindow["Cannot add sound on top of another sound"];
ENDCASE => succeeded ← TRUE;
}; -- end of PrepareSelection
BlinkMessageWindow:
PROC [r: Rope.
ROPE] ~ {
MessageWindow.Append[r, TRUE];
MessageWindow.Blink[];
};
StartRecording:
INTERNAL
PROC[selfElseOther:
BOOL←
TRUE] = {
recordingState.recordingInProgress ← TRUE;
recordingState.timerState ← off;
recordingState.newRope ← NIL;
recordingState.timeInSoundChars ← 0;
recordingState.requestID ← VoiceRope.NewRequestID[];
recordingState.nb ← $success;
Fork process to call VoiceRope.RecordNB. It will return when a VoiceRope.StopNB occurs. It will then place the ID of the Rope in the appropriate state variable, where the routine called when the $finished report is received can get it.
Process to time the recording will be forked when the $started report is received, and will be terminated when the $finished report is received or the conversation fails.
TRUSTED {Process.Detach[FORK RecordNewRope[selfElseOther]]};
};
RecordNewRope:
PROC[selfElseOther:
BOOL] = {
BroadcastRecordingDone: ENTRY PROC = { BROADCAST recordingDone }; -- keeps the compiler happy!
[nb: recordingState.nb, voiceRope: recordingState.newRope] ← VoiceRope.RecordNB[handle: TiogaVoicePrivate.thrushHandle, requestID: recordingState.requestID, clientData: $TiogaVoice, selfElseOther: selfElseOther];
SELECT recordingState.nb
FROM
$success, $noLength => BroadcastRecordingDone[];
ENDCASE => StopRecording[];
something failed in conversation or recording setup; guaranteed not to WAIT for recordingDone This control mechanism is pretty kludgy
};
RecordingTimer:
PROC = {
aVeryLongTime: BasicTime.Pulses = BasicTime.MicrosecondsToPulses[300000000];
see comments in VoicePlayBackImpl on this constant
cuePriority: Process.Priority = Process.priorityRealTime;
Process.SetPriority[cuePriority];
try to keep this process up to time: however there is compensation for delay in each wake-up by looking at a real time clock; see below
recordingState.nextWakeUp ← BasicTime.GetClockPulses[];
recordingState.timerState ← on;
DO
now: BasicTime.Pulses ← BasicTime.GetClockPulses[];
IF recordingState.nextWakeUp - now < aVeryLongTime -- so as to cope properly with wrap-around
THEN Process.Pause[Process.MsecToTicks[BasicTime.PulsesToMicroseconds[ recordingState.nextWakeUp-now]/1000]];
IF ~ IncrementRecordTimer[] THEN RETURN;
ENDLOOP;
};
IncrementRecordTimer:
ENTRY
PROC
RETURNS [stillRunning:
BOOLEAN ←
TRUE] = {
IF recordingState.timerState # on THEN
{ recordingState.timerState ← off;
BROADCAST timerOff;
RETURN [FALSE]
};
recordingState.nextWakeUp ← recordingState.nextWakeUp + BasicTime.MicrosecondsToPulses[ 1000000/TiogaVoicePrivate.soundRopeCharsPerSecond];
recordingState.timeInSoundChars ← recordingState.timeInSoundChars + 1;
IF ~recordingState.addingIntoTextViewer
THEN
NewRecordingMarker[recordingState.soundSelection.viewer, recordingState.cueInsertPosition + recordingState.timeInSoundChars - 1];
};
NewRecordingMarker:
INTERNAL
PROC [viewer: ViewerClasses.Viewer, loc:
INT] ~ {
this code adds another marker into a voice viewer to indicate how much has been recorded
DoIt:
PROC [root: TiogaOpsDefs.Ref] ~ {
Note: all voice viewers contain only one node.
IF NOT viewer.newVersion THEN TiogaVoicePrivate.MakeVoiceEdited[viewer];
[] ← TextEdit.InsertChar[root: TiogaButtons.TextNodeRef[root], dest: TiogaButtons.TextNodeRef[TiogaOps.FirstChild[root]], char: '>, destLoc: loc, inherit:
FALSE, looks: TextLooks.RopeToLooks["v"]];
'> is used as an 'inserting voice' indicator
};
TiogaOps.CallWithLocks[DoIt, TiogaOps.ViewerDoc[viewer]];
};
StopRecording:
PUBLIC
ENTRY
PROC = {
this gets called every time a STOP button is clicked, after VoiceRope.StopNB has been called
IF ~recordingState.recordingInProgress THEN RETURN;
IF recordingState.timerState = on THEN recordingState.timerState ← quit;
WHILE recordingState.newRope =
NIL
AND recordingState.nb = $success
DO
WAIT recordingDone
ENDLOOP;
WHILE recordingState.timerState # off DO WAIT timerOff ENDLOOP;
recordingState.recordingInProgress ← FALSE;
IF recordingState.addingIntoTextViewer
THEN {
badTarget: BOOLEAN ← FALSE;
IF recordingState.newRope =
NIL
OR recordingState.newRope.length = 0
THEN
BlinkMessageWindow["Zero length voice annotation - discarding"]
ELSE {
AddVoice:
PROC [root: TiogaOpsDefs.Ref] = {
TextEdit.PutCharProp[node, targetChar.where, $voice, recordingState.newRope.ropeID];
next line places a 'talks bubble' on the selected character - see TalksBubbleImpl
TextEdit.PutCharProp[node, targetChar.where, $Artwork, NARROW["TalksBubble", Rope.ROPE]]; -- the NARROW prevents a REF TEXT being created
};
targetChar: TiogaOpsDefs.Location;
node: TextNode.Ref;
targetChar ← TiogaExtraOps.GetTextKey[recordingState.node, $recordingMark ! TiogaExtraOps.TextKeyNotFound => {badTarget ← TRUE; CONTINUE}];
node ← TiogaButtons.TextNodeRef[targetChar.node]; -- just a type convertor
IF TextEdit.Size[node] <= targetChar.where
OR badTarget
OR TextEdit.GetCharProp[node, targetChar.where, $voice] #
NIL
THEN {
A store might have been performed in the intervening time, or there might be just a point selection at the end of some node.
voiceViewer: ViewerClasses.Viewer;
[viewer: voiceViewer] ← TiogaVoicePrivate.BuildVoiceViewer[recordingState.newRope.ropeID, NIL, TRUE];
TiogaVoicePrivate.MakeVoiceEdited[voiceViewer];
BlinkMessageWindow["No character to add voice to; new voice viewer contains voice just recorded"];
}
ELSE {
TiogaExtraOps.RemoveTextKey[recordingState.node, $recordingMark];
TiogaOps.CallWithLocks[AddVoice, TiogaOps.Root[targetChar.node]];
Called locked because otherwise Tioga doesn't immediately repaint the artwork
}
}
}
ELSE
IF recordingState.soundSelection.voiceViewerInfo.ropeInterval.ropeID =
NIL
THEN {
This is a new dictation window, so just set its contents to the new rope
IF recordingState.newRope =
NIL
OR recordingState.newRope.length = 0
THEN {
BlinkMessageWindow["Zero length voice dictation - destroying window"];
recordingState.soundSelection.voiceViewerInfo.editInProgress ←
FALSE;
just making sure; so the old voice viewer will allow itself to be destroyed
ViewerOps.DestroyViewer[recordingState.soundSelection.viewer.parent]
this will cause the event proc which clears down the voiceViewerInfo etc. to be called
}
ELSE {
TiogaVoicePrivate.MakeVoiceEdited[recordingState.soundSelection.viewer];
Shouldn't be needed - should have already been done while recording the new rope.
TiogaVoicePrivate.SetViewerContents[recordingState.soundSelection.viewer, recordingState.soundSelection.voiceViewerInfo, recordingState.newRope.ropeID, NIL, TRUE]
}
}
ELSE
IF recordingState.newRope =
NIL
OR recordingState.newRope.length = 0
THEN {
If the new rope to be added is of zero length then just redraw the viewer
trueContents: Rope.ROPE ← TiogaVoicePrivate.SoundChars[recordingState.soundSelection.voiceViewerInfo].soundRope;
MessageWindow.Append["Zero length voice addition - viewer contents unchanged", TRUE];
[] ← TiogaVoicePrivate.RedrawViewer[recordingState.soundSelection.viewer, trueContents, 0, 0, 0, recordingState.soundSelection.voiceViewerInfo.remnant, FALSE, deSelected];
TiogaVoicePrivate.SetVoiceViewerEditStatus[recordingState.soundSelection.viewer];
This will always say edited now, because we make the voice viewer edited in NewRecordingMarker when we put the first '> character in
recordingState.soundSelection.voiceViewerInfo.editInProgress ← FALSE
}
ELSE {
newSoundList: TiogaVoicePrivate.SoundList ← TiogaVoicePrivate.SoundListFromIntervalSpecs [VoiceRope.DescribeRope[TiogaVoicePrivate.thrushHandle, recordingState.newRope], recordingState.newRope.length];
newSound: TiogaVoicePrivate.SoundInterval ← NEW [TiogaVoicePrivate.SoundIntervalRec ← [ropeInterval: recordingState.newRope^, soundList: newSoundList]];
recordingState.soundSelection.ropeInterval.length ← 0;
This may already be the case, but if not we already did the delete before starting to record, so set it zero. If we did the delete then recordingState.soundSelection.ropeInterval will not bear the correct ropeID but recordingState.soundSelection.voiceViewerInfo will and that is the ropeID which is used
TiogaVoicePrivate.MakeVoiceEdited[recordingState.soundSelection.viewer];
Shouldn't be needed - should have already been done while recording the new rope.
[] ← TiogaVoicePrivate.ReplaceSelectionWithSavedInterval[recordingState.soundSelection, newSound, TRUE];
recordingState.soundSelection.voiceViewerInfo.editInProgress ← FALSE
}
};
NewDictationWindow:
INTERNAL
PROC = {
Creates a new dictation window and sets recordingState.soundSelection up correctly to refer to it, also sets recordingState.addingIntoTextViewer false
recordingState.addingIntoTextViewer ← FALSE;
recordingState.soundSelection ← NEW [TiogaVoicePrivate.SelectionRec];
[viewerInfo: recordingState.soundSelection.voiceViewerInfo, viewer: recordingState.soundSelection.viewer] ← TiogaVoicePrivate.BuildVoiceViewer[NIL, NIL, TRUE];
BuildVoiceViewer[NIL] will set the voiceRope represented by the rope to NIL, the test used for a currently 'empty' viewer in StopRecording above
recordingState.cueInsertPosition ← 1
};
Dictation machine creation stuff [the previous procedure is a general one for creating window with no voice in it]:
DictationMachine:
PUBLIC
ENTRY TiogaOps.CommandProc = {
PROC [viewer: Viewer ← NIL] RETURNS [recordAtom: BOOL ← TRUE, quit: BOOL ← FALSE]; viewer prop $ButtonParams = TiogaVoicePrivate.ButtonParams
the procedure behind all DictationMachine buttons: if a recording is in progress then transfer it into another [newly created] window, otherwise make a new window and start recording
IF recordingState.recordingInProgress THEN
{ ChangeVoiceInputFocus[];
-- the non-trivial case - recording in progress
RETURN
};
the rest of this procedure implements the case of DictationMachine bugged when no recording is in progress: create a new viewer and start recording into it
IF TiogaVoicePrivate.PlayBackInProgress[]
THEN {
BlinkMessageWindow["Cancel playback before trying to record"];
RETURN
}; -- PlayBackInProgress is only a hint: to be sure we'll do a cancel to avoid race conditions
TiogaVoicePrivate.CancelPlayBack[];
NewDictationWindow[];
StartRecording[];
};
ChangeVoiceInputFocus:
INTERNAL
PROC = {
DictationMachine was bugged when a recording was in progress: create a new voice viewer and alter the recording focus to it. In the case where recording into a voice viewer, leave a marker where the focus was. In the case where recording into a text viewer, place a VoiceWindow marker where the focus was.
IF ~recordingState.addingIntoTextViewer THEN
{
IF recordingState.soundSelection.voiceViewerInfo.ropeInterval.ropeID =
NIL
THEN
{ BlinkMessageWindow["You're already using a dictation viewer."];
RETURN
};
TiogaVoicePrivate.LockedAddCharMark[recordingState.soundSelection.viewer, MAX [recordingState.soundSelection.ropeInterval.start/TiogaVoicePrivate.soundRopeCharLength-1, 0]];
this procedure not only sets the mark but also redraws the viewer, removing the voice input markers
MessageWindow.Append["Marker set where you were inserting voice", TRUE];
recordingState.soundSelection.voiceViewerInfo.editInProgress ← FALSE
};
{ currentContents: Rope.
ROPE ← " ";
wasIntoText: BOOLEAN ← recordingState.addingIntoTextViewer; -- gets altered by NewDictationWindow
NewDictationWindow[]; -- that's an empty one: set its contents to reflect the sound already recorded
IF wasIntoText THEN
{
AddVoiceWindowMarker:
PROC [root: TiogaOpsDefs.Ref] = {
**** this is all a bit dubious - the pointer enables a SAVE of the voice to work, but if the text is SAVED before the voice is either saved or destroyed, the bubble will hang around without voice underneath it **** no longer true, uses record
alreadyEdited: BOOLEAN ← recordingState.textViewer.newVersion;
this line places a 'talks bubble' on the selected character - see TalksBubbleImpl
TextEdit.PutCharProp[node, targetChar.where, $Artwork, NARROW["TalksBubble", Rope.ROPE]]; -- the NARROW prevents a REF TEXT being created
TextEdit.PutCharProp[node, targetChar.where, $voiceWindow, NEW[TiogaVoicePrivate.VoiceWindowRec ← [label: Rope.Concat["Sound Viewer #", Convert.RopeFromInt[recordingState.soundSelection.voiceViewerInfo.viewerNumber]]]]];
TiogaVoicePrivate.SetParentViewer[recordingState.soundSelection.voiceViewerInfo, recordingState.textViewer, targetChar];
because we are under a Tioga lock, it is safe to muck with the 'edited' status of the viewer
philosophically, putting a source marker in a voice viewer does not constitute editing it, so keep the 'edited' status of the viewer constant through this operation
IF ~alreadyEdited THEN
{ recordingState.textViewer.newVersion ← FALSE;
ViewerOps.PaintViewer[recordingState.textViewer, caption, FALSE]
} -- not needed with container-based voice viewers: PTZ, January 12, 1988
};
targetChar: TiogaOpsDefs.Location ← TiogaExtraOps.GetTextKey[recordingState.node, $recordingMark];
node: TextNode.Ref ← TiogaButtons.TextNodeRef[targetChar.node]; -- just a type convertor
IF recordingState.node # targetChar.node THEN ERROR; -- **** because you've caught all those !!!
TiogaExtraOps.RemoveTextKey[recordingState.node, $recordingMark];
IF TextEdit.GetCharProp[node, targetChar.where, $voice] # NIL THEN RETURN; -- can happen - a store might have been performed in the intervening time
IF TextEdit.GetCharProp[node, targetChar.where, $voiceWindow] # NIL THEN RETURN;
TiogaOps.CallWithLocks[AddVoiceWindowMarker, TiogaOps.Root[targetChar.node]] -- called locked because otherwise Tioga doesn't immediately repaint the artwork, also so we can muck with the 'edited' status of the viewer
};
FOR i: INT IN [1..recordingState.timeInSoundChars] DO currentContents ← currentContents.Concat[">"] ENDLOOP;
currentContents ← currentContents.Concat[" "];
[] ← TiogaVoicePrivate.RedrawViewer[recordingState.soundSelection.viewer, currentContents, 0, 0, 0, 0, FALSE, deSelected]
}
};
RecordInPlaceOfSelection:
PUBLIC
ENTRY
PROC [selection: TiogaVoicePrivate.Selection] = {
this gets called by TiogaVoicePrivate when a selection [possibly zero length, in which case don't delete it] is to be replaced by new voice input: the selection is assumed to be locked with GetVoiceLock and there is assumed to be no playback or recording in progress at the time of the call
recordingState.soundSelection ← selection;
recordingState.addingIntoTextViewer ← FALSE;
IF recordingState.soundSelection.ropeInterval.length # 0
THEN
-- i.e. pending delete
IF TiogaVoicePrivate.ReplaceSelectionWithSavedInterval
[recordingState.soundSelection,
NIL,
FALSE].viewerDeleted
THEN
NewDictationWindow[]; -- this means "if applicable, do the pending delete. If that delete should reduce the window contents to zero it will disappear, so create a new one"
recordingState.cueInsertPosition ← recordingState.soundSelection.ropeInterval.start/TiogaVoicePrivate.soundRopeCharLength;
StartRecording[];
};
ForkStopRecording:
PROC = {
TRUSTED {Process.Detach[
FORK StopRecording[]]} };
StopRecording may WAIT; don't want to hang up FinchSmarts reporting process
ConversationReport: FinchSmarts.ReportConversationStateProc ~ {
[ nb: NB, cDesc: ConvDesc, remark: ROPE←NIL ]
IF cDesc = NIL THEN-- RETURN;
IF
NARROW[VoiceRope.GetClientData[handle: TiogaVoicePrivate.thrushHandle, cDesc: cDesc],
ATOM] = $TiogaVoice
THEN
likely to be ours
SELECT cDesc.situation.self.state
FROM
$active => NULL;
$idle, $neverWas, $failed => {
restore quiescent state: stop all cues, discard pending requests
TiogaVoicePrivate.CancelPlayBack[];
ForkStopRecording[];
};
ENDCASE;
};
RequestReport: FinchSmarts.ReportRequestStateProc ~ {
[ cDesc: ConvDesc, actionReport: Thrush.ActionReport, actionRequest: REF ] RETURNS [betterActionRequest: REF]
betterActionRequest ← actionRequest;
IF cDesc = NIL THEN RETURN;
IF
NARROW[VoiceRope.GetClientData[handle: TiogaVoicePrivate.thrushHandle, cDesc: cDesc],
ATOM] = $TiogaVoice
THEN
likely to be ours
SELECT actionReport.actionClass
FROM
$recording => {
IF actionReport.actionID = recordingState.requestID
THEN
SELECT actionReport.actionType
FROM
$scheduled => NULL;
$started => TRUSTED {Process.Detach[FORK RecordingTimer[]]};
$finished, $flushed => ForkStopRecording[];
ENDCASE;
};
$playback => {
SELECT actionReport.actionType
FROM
$scheduled => RETURN;
$started => TiogaVoicePrivate.SetPlayBackState[actionReport.actionID, busy];
$finished, $flushed => TiogaVoicePrivate.SetPlayBackState[actionReport.actionID, done];
$paused => TiogaVoicePrivate.SetPlayBackState[actionReport.actionID, paused];
$resumed => TiogaVoicePrivate.SetPlayBackState[actionReport.actionID,
ENDCASE;
betterActionRequest ← actionRequest; -- a place to stand during debugging
};
Initialization
FinchSmarts.RegisterForReports[key: $TiogaVoice, c: ConversationReport, r: RequestReport, other: $VoiceRope, before: FALSE];
}.
Swinehart, April 10, 1987 9:38:29 am PDT
Merged VoicePlayImpl and VoiceRecordImpl, from Ades. Fixed some nested ML problems resulting from merging two MONITORs.
changes to: AddVoiceProc, DictationMachine, AbortCues, CancelPlayBack
Polle Zellweger (PTZ) May 22, 1987 5:15:23 pm PDT
Split back into VoicePlaybackImpl and VoiceRecordImpl: too many monitor lock difficulties to fix quickly.
changes to: DIRECTORY, AddVoiceProc, DictationMachine
Polle Zellweger (PTZ) June 15, 1987 4:24:18 pm PDT
Avoid blowing up if the user has a point selection (or some other difficulty) at the end of recording; open a voice viewer on the voice rope to allow user to store elsewhere.
changes to: DIRECTORY, StopRecording
Polle Zellweger (PTZ) June 17, 1987 11:13:54 am PDT
Notice when voice viewer has been edited & change icon.
changes to: DIRECTORY, NewRecordingMarker, StopRecording
Polle Zellweger (PTZ) July 17, 1987 6:24:28 pm PDT
Register with FinchSmarts for request/connection reports; base timing of cues on reports; notice when conversation fails & clean up.
changes to: DIRECTORY, timerState, AddVoiceProc, RecordNewRope, StopRecording, RecordInPlaceOfSelection
new: recordingRequestID, recordingNB, convDesc, StartRecording, ConversationReport, RequestReport, initialization
Polle Zellweger (PTZ) July 20, 1987 5:16:41 pm PDT
More of the above.
changes to: CancelProc, RequestReport, StartRecording, RecordNewRope, RecordInPlaceOfSelection, ConversationReport, DIRECTORY
Polle Zellweger (PTZ) July 21, 1987 12:27:42 pm PDT
Create recordingState record.
changes to: recordingState, timerState, RecordingInProgress, AddVoiceProc, PrepareSelection, StartRecording, RecordNewRope, RecordingTimer, IncrementRecordTimer, StopRecording, AddVoice (local of StopRecording), NewDictationWindow, DictationMachine, ChangeVoiceInputFocus, AddVoiceWindowMarker (local of ChangeVoiceInputFocus), RecordInPlaceOfSelection, RequestReport, DIRECTORY, CancelProc, VoiceRecordImpl
Polle Zellweger (PTZ) July 27, 1987 4:52:06 pm PDT
changes to: DIRECTORY, VoiceRecordImpl, StartRecording, RecordNewRope, ForkStopRecording, ConversationReport, RequestReport, RecordingTimer, StopRecording
Polle Zellweger (PTZ) July 27, 1987 5:25:56 pm PDT
changes to: DictationMachine
Polle Zellweger (PTZ) November 5, 1987 2:19:54 pm PST
Interface to reporting seems to have changed: must return non-NIL actionRequest.
changes to: RequestReport
Polle Zellweger (PTZ) January 11, 1988 2:26:51 pm PST
Remove ToggleDictationMenu (part of installing PopUpButtons)
changes to: DIRECTORY, DictationMachine, ChangeVoiceInputFocus
Polle Zellweger (PTZ) January 12, 1988 7:12:21 pm PST
Make AddVoice act the same as the new Store (Store fix in VoiceInTextImpl). Also random cleanup.
changes to: DIRECTORY, PrepareSelection, DoIt (local of PrepareSelection), BlinkMessageWindow, ChangeVoiceInputFocus, AddVoiceWindowMarker (local of ChangeVoiceInputFocus)
Polle Zellweger (PTZ) January 20, 1988 11:34:18 am PST
Set editInProgress for old viewer FALSE so it can be destroyed; refer to outer container when destroying voice viewer.
changes to: StopRecording
Polle Zellweger (PTZ) September 12, 1988 8:39:59 pm PDT
Changes to allow clients to alter button behaviors via Tioga registry (for WalnutTiogaVoice).
changes to: DIRECTORY, CancelProc, AddVoiceProc, DictationMachine