Event.mesa
Copyright (C) 1983, 1984 Xerox Corporation. All rights reserved.
Author: John Maxwell
Last Edited by: Maxwell, November 22, 1983 12:06 pm
Last Edited by: Doug Wyatt, June 12, 1984 3:35:08 pm PDT
DIRECTORY
MusicDefs USING [EventPTR, KeySignaturePTR, MeasurePTR, MetronomePTR, NotePTR, ScorePTR, Staff, StavesPTR, SyncPTR, Time, TimeSignaturePTR];
Event: CEDAR DEFINITIONS
= BEGIN OPEN MusicDefs;
Draw: PROC[score: ScorePTR, event: EventPTR];
Invisible: PROC[score: ScorePTR, index: CARDINAL, leftEdge: Time]
RETURNS[BOOLEAN]; -- Hidden
GetScoreIndex: PROC[score: ScorePTR, event: EventPTR] RETURNS[index: CARDINAL];
returns score.length if not found (score[score.length] is always NIL)
************************************************
Type coercion
************************************************
Sync: PROC[event: EventPTR] RETURNS[SyncPTR] ~ INLINE {
RETURN[WITH event SELECT FROM e: SyncPTR => e, ENDCASE => NIL];
};
Staves: PROC[event: EventPTR] RETURNS[StavesPTR] ~ INLINE {
RETURN[WITH event SELECT FROM e: StavesPTR => e, ENDCASE => NIL];
};
Measure: PROC[event: EventPTR] RETURNS[MeasurePTR] ~ INLINE {
RETURN[WITH event SELECT FROM e: MeasurePTR => e, ENDCASE => NIL];
};
Metronome: PROC[event: EventPTR] RETURNS[MetronomePTR] ~ INLINE {
RETURN[WITH event SELECT FROM e: MetronomePTR => e, ENDCASE => NIL];
};
TimeSignature: PROC[event: EventPTR] RETURNS[TimeSignaturePTR] ~ INLINE {
RETURN[WITH event SELECT FROM e: TimeSignaturePTR => e, ENDCASE => NIL];
};
KeySignature: PROC[event: EventPTR] RETURNS[KeySignaturePTR] ~ INLINE {
RETURN[WITH event SELECT FROM e: KeySignaturePTR => e, ENDCASE => NIL];
};
************************************************
Procedures that only apply to staves
************************************************
Octava: PROC[event: EventPTR] RETURNS[BOOLEAN] ~ INLINE {
RETURN[WITH event SELECT FROM
ev: StavesPTR => ev.staves IN[octava1..octava2], ENDCASE => FALSE]
};
Clef: PROC[event: EventPTR] RETURNS[BOOLEAN] ~ INLINE {
RETURN[WITH event SELECT FROM
ev: StavesPTR => ev.staves=clef, ENDCASE => FALSE]
};
GetOctava: PROC[score: ScorePTR, octava: StavesPTR] RETURNS[other: StavesPTR];
SetStave: PROC[score: ScorePTR, oldS, newS: StavesPTR]; -- copy info from old to new
GetStaff: PROC[staves: StavesPTR, staff: CARDINAL] RETURNS[Staff];
************************************************
Procedures that only apply to syncs
************************************************
AddNote: PROC[score: ScorePTR, sync: SyncPTR, note: NotePTR];
RemoveNote: PROC[score: ScorePTR, sync: SyncPTR, note: NotePTR, free: BOOLEANFALSE];
removes note from sync. If sync.length = 0 and free = TRUE, then sync is freed.
Adjust: PROC[score: ScorePTR, s: SyncPTR]; -- space the notes so they don't overlap
NewSync: PROC[score: ScorePTR, length: CARDINAL ← 12] RETURNS[sync: SyncPTR];
Free: PROC[score: ScorePTR, event: EventPTR];
removes sync from anything that points to it
INLINE Procedures
AddTimes: PROC[event: EventPTR, time, toc: Time];
= INLINE { -- add times to notes
sync: SyncPTR;
event.time ← event.time + time;
IF event.type = sync THEN sync ← Sync[event] ELSE RETURN;
FOR i: CARDINAL IN [0..sync.length) DO
sync.note[i].toc ← sync.note[i].toc + toc;
ENDLOOP};
Grace: PROC[sync: SyncPTR] RETURNS[BOOLEAN];
{FOR j: CARDINAL IN [0..sync.length) DO
IF ~sync.note[j].grace THEN RETURN[FALSE];
ENDLOOP;
RETURN[TRUE]};
InVoice: PROC[sync: SyncPTR, voice: CARDINAL] RETURNS[BOOLEAN];
{FOR j: CARDINAL IN [0..sync.length) DO
IF sync.note[j].voice = voice THEN RETURN[TRUE];
ENDLOOP;
RETURN[FALSE]};
END.