DIRECTORY Imager USING [Context], MusicFileDefs USING [AccidentalFormat, DisplayModeFormat, EmbellishmentFormat, NoteValueFormat], Rope USING [ROPE]; MusicDefs: CEDAR DEFINITIONS ~ BEGIN ROPE: TYPE ~ Rope.ROPE; Error: SIGNAL[s: ROPE]; Notify: SIGNAL[s: ROPE]; ScorePTR: TYPE ~ REF ScoreRec; ScoreRec: TYPE ~ RECORD [ name: ROPE _ NIL, -- name of the score beamHeap: BeamHeapPTR _ NIL, -- collection of beams chordHeap: ChordHeapPTR _ NIL, -- collection of chords cache: CachePTR _ NIL, -- current key, time signature, etc. sheet: SheetPTR _ NIL, -- cached information about the sheet (derived from the piece) style: StylePTR _ NIL, -- maxVoice: NAT _ 0, -- index of the highest numbered voice command: BOOL _ FALSE, -- we have a new command flash: BOOL _ FALSE, -- flash the screen for an error length: NAT _ 0, -- length of score event: SEQUENCE max: NAT OF EventPTR -- collection of events ]; ScorePortionPTR: TYPE ~ REF ScorePortionRec; ScorePortionRec: TYPE ~ RECORD[ -- a portion of a score. score: ScorePTR _ NIL, toc: Time _ 0, -- length of portion in seconds of playing time. duration: Time _ 0, -- length in portion in pixels on the screen. ss1, ss2: ScoreStateRec _ [] -- state of score at beginning and end ]; ScoreStatePTR: TYPE ~ REF ScoreStateRec; ScoreStateRec: TYPE ~ RECORD[ key: INTEGER _ 0, style: NAT _ 1, staff: ARRAY [0..4) OF Staff _ ALL[[]] ]; EventPTR: TYPE ~ REF EventRec; EventRec: TYPE ~ RECORD[ time: Time _ 0, -- measured in pixels from beginning of piece variant: SELECT type: EventType FROM sync => [ length: NAT _ 0, -- actual length of the sequence note: SEQUENCE max: NAT OF NotePTR -- collection of notes ], measure => [ measure: MeasureType _ measure, eol: BOOL _ FALSE -- eol => force to end of line ], timeSignature => [ts: TimeSignature _ [4,4]], keySignature => [key: INTEGER _ 0], metronome => [metronome: INTEGER _ 128], staves => [ -- marks a change in staffing staves: StavesType _ style, value: NAT _ 0, -- index of the staff OR style number height: INTEGER _ 0, offset: INTEGER _ 0, length: [0..4] _ 4, -- number of staffs in following array staff: ARRAY [0..4) OF Staff _ ALL[[0, 0]] ], ENDCASE ]; SyncPTR: TYPE ~ REF EventRec[sync]; -- 'sync' comes from 'synchronize' MeasurePTR: TYPE ~ REF EventRec[measure]; TimeSignaturePTR: TYPE ~ REF EventRec[timeSignature]; KeySignaturePTR: TYPE ~ REF EventRec[keySignature]; MetronomePTR: TYPE ~ REF EventRec[metronome]; StavesPTR: TYPE ~ REF EventRec[staves]; Time: TYPE ~ LONG INTEGER; EventType: TYPE ~ {sync, measure, timeSignature, keySignature, metronome, staves}; MeasureType: TYPE ~ {measure, repeat1, repeat2, endMeasure, doubleMeasure, m5}; TimeSignature: TYPE ~ RECORD [top, bottom: [0..32)]; StavesType: TYPE ~ {style, clef, octava1, octava2}; NotePTR: TYPE ~ REF NoteRec; NoteRec: TYPE ~ RECORD[ sync: SyncPTR _ NIL, -- pointer back to sync beam: BeamPTR _ NIL, -- pointer back to beam chord: ChordPTR _ NIL, -- pointer back to chord pitch: INTEGER _ 44, -- pitch of the note voice: NAT _ 0, -- the voice that this note belongs to value: NoteValue _ unknown, -- what is the logical value of this note? spelled: Accidental _ inKey, -- does this note have an explicit spelling on it? rest: BOOL _ FALSE, -- is this a rest note? dotted: BOOL _ FALSE, -- is this note dotted? doubleDotted: BOOL _ FALSE, -- is this note double dotted? grace: BOOL _ FALSE, -- is this a grace note? stemUp: BOOL _ TRUE, -- is the stem up or down? spare1: BOOL _ FALSE, embellish: Embellishment _ none, -- does this note have an embellishment on it? tied: BOOL _ FALSE, -- is this the second note of a tied note? tie: NotePTR _ NIL, -- pointer to the second note of a tie tieHeight: INTEGER _ 0, -- the height of said tie show: BOOL _ FALSE, shown: Accidental _ inKey, -- the accidental displayed on the screen (cached) spare: [0..256) _ 0, staff: [0..16) _ 1, -- the index of the staff that this note is on delta: [-128..128) _ 0, -- how far to move the note relative to the sync accDelta: [-128..128) _ 0, -- how far to move the accidental relative to the sync toc: LONG CARDINAL _ 0, -- physical-note time of occurrence (in clock pulses) duration: CARDINAL _ 0 -- physical-note duration (in clock pulses) ]; NoteValue: TYPE ~ MusicFileDefs.NoteValueFormat; Accidental: TYPE ~ MusicFileDefs.AccidentalFormat; Embellishment: TYPE ~ MusicFileDefs.EmbellishmentFormat; PhysicalNote: TYPE ~ RECORD[ pitch: INTEGER _ 0, duration: CARDINAL _ 0, loudness: CARDINAL _ 0, toc: LONG CARDINAL _ 0 -- toc is the physical time of occurrence ]; ChordPTR: TYPE ~ REF ChordRec; ChordRec: TYPE ~ RECORD[ stemUp: BOOL _ TRUE, delta: INTEGER _ 0, -- offset from center line of sync (cached) length: NAT _ 0, -- length of note sequence note: SEQUENCE max: NAT OF NotePTR ]; BeamPTR: TYPE ~ REF BeamRec; BeamRec: TYPE ~ RECORD[ tilt: REAL _ 0, -- tilt of beam beamed: BOOL _ TRUE, -- does the beam show, or do you use brackets instead? ntuple, against: [0..128) _ 1, -- for ntupled beams; the ratio is what is important sync1, sync2: SyncPTR _ NIL, -- first and last sync in beam (cached) beam: BeamPTR _ NIL, -- beam that this beam belongs to height: INTEGER _ 0, -- height of beam from top of left-most note invisible: BOOL _ FALSE, length: NAT _ 0, -- length of chord sequence staff: NAT _ 0, -- graphical information chord: SEQUENCE max: NAT OF VariousPTR -- chord sequence ]; VariousPTR: TYPE ~ REF; -- NotePTR, ChordPTR, or BeamPTR endOfBeam: VariousPTR ~ NIL; BeamHeapPTR: TYPE ~ REF BeamHeapRec; BeamHeapRec: TYPE ~ RECORD[ length: NAT _ 0, beam: SEQUENCE max: NAT OF BeamPTR ]; ChordHeapPTR: TYPE ~ REF ChordHeapRec; ChordHeapRec: TYPE ~ RECORD[ length: NAT _ 0, chord: SEQUENCE max: NAT OF ChordPTR ]; CachePTR: TYPE ~ REF CacheRec; CacheRec: TYPE ~ RECORD[ -- all of the structural (non-sync) events beamIndex: NAT _ 0, beamQueue: ARRAY [0..3) OF BeamPTR _ ALL[NIL], -- drawn beams key1, key2: KeySignaturePTR _ NIL, -- bracketing keys ts1, ts2: TimeSignaturePTR _ NIL, -- bracketing time signatures met1, met2: MetronomePTR _ NIL -- bracketing metronomes ]; SheetPTR: TYPE ~ REF SheetRec; SheetRec: TYPE ~ RECORD[ context: Imager.Context _ NIL, voice: NAT _ noVoice, -- currently selected voice top: INTEGER _ 0, -- the y position of the top of the score (for scrolling) begin, endTime: Time _ 0, -- start and end of the part of the score that is currently visible dirty1, dirty2: Time _ 0, -- the portion of the score that needs to be repainted scale: INTEGER _ 1, -- normal, hardcopy and overview density: INTEGER _ 256, -- scale factor in physical mode. justification: INTEGER _ 1, -- density of justification. used in graphical mode. accidental: BOOL _ TRUE, notehead: BOOL _ TRUE, sync: BOOL _ FALSE, display: DisplayMode _ graphical, noCarry: BOOL _ FALSE, hardcopy: BOOL _ FALSE, -- display in hardcopy mode printing: BOOL _ FALSE, -- we are printing instead of displaying width: INTEGER _ 550, -- width of staff current: NAT _ 0, -- current section index length: NAT _ 0, -- length of sheet sequence section: SEQUENCE max: NAT OF Section -- sequence of sections ]; Section: TYPE ~ RECORD[ time: Time _ 0, -- actual time of beginning of section. (may be different from staves.time) x, y: INTEGER _ 0, -- position of the lower left corner of the section page: INTEGER _ 0, -- the page that this section is on key: INTEGER _ 0, -- the key for this section staves: StavesPTR _ NIL ]; noVoice: NAT ~ 1000; Staff: TYPE ~ RECORD[ pitch: INTEGER _ 0, -- pitch of note on bottom line y: INTEGER _ 0 -- height relative to bottom line ]; StylePTR: TYPE ~ REF StyleRec; StyleRec: TYPE ~ RECORD[ length: NAT _ 0, style: SEQUENCE max: NAT OF StavesPTR ]; SelectionPTR: TYPE ~ REF SelectionRec; SelectionRec: TYPE ~ RECORD[ lineSelect: BOOL _ FALSE, -- line selection or note selection? score: ScorePTR _ NIL, -- score of primary selection or note selection select1, select2: Time _ 0, -- line selected score2: ScorePTR _ NIL, -- score of secondary selection greySelect1, greySelect2: Time _ 0, -- secondary line selection length: NAT _ 0, -- length of note selection note: SEQUENCE max: NAT OF NotePTR -- notes selected ]; DisplayMode: TYPE ~ MusicFileDefs.DisplayModeFormat; ObjectType: TYPE ~ {measure, note, leftBeam, rightBeam, tie}; LookCommand: TYPE ~ {accidental, graphical, hardcopy, justified, logical, noCarry, notehead, overview, physical, style, sync, voice}; ColorType: TYPE ~ {black, grey, light, white}; FontType: TYPE ~ {text, music}; PaintMode: TYPE ~ {opaque, transparent, invert}; Measure: PROC[event: EventPTR] RETURNS[BOOL] ~ INLINE { WITH event SELECT FROM ev: MeasurePTR => RETURN[TRUE]; ev: StavesPTR => RETURN[ev.staves=style]; ENDCASE => RETURN[FALSE]; }; EndOfScore: PROC[score: ScorePTR] RETURNS[Time] ~ INLINE { IF score.length#0 THEN RETURN[score.event[score.length-1].time+40] ELSE RETURN[10] }; LMod: PROC[m, n: Time] RETURNS[k: Time] ~ INLINE { k _ m - n*(m/n); IF k>n THEN k _ k+n; }; Mod: PROC[m, n: INTEGER] RETURNS[k: INTEGER] ~ INLINE { k _ m MOD n; IF k<0 THEN k _ k+n; }; SetDirty: PROC[score: ScorePTR, begin, end: Time] ~ INLINE { score.sheet.dirty1 _ MIN[score.sheet.dirty1, begin]; score.sheet.dirty2 _ MAX[score.sheet.dirty2, end]; }; END. èMusicDefs.mesa Copyright (C) 1983, 1984 Xerox Corporation. All rights reserved. Author: John Maxwell Last Edited by: Maxwell, November 22, 1983 12:46 pm Last Edited by: Doug Wyatt, June 18, 1984 12:37:59 pm PDT This module gives the types used internally by the editor. MusicFileDefs gives the types used externally in the file format. **************************************************************************** the basic music types **************************************************************************** duration = 0 means score is from synthesizer (ignore ss1 and ss2). ****************************************************************************** other types ****************************************************************************** chordLength: CARDINAL ~ 10; syncLength: CARDINAL ~ 13; beamLength: CARDINAL ~ 16; sheetLength: CARDINAL ~ 350; maxScoreLength: CARDINAL ~ MAX[maxPieceLength,3000]; --6000 maxPieceLength: CARDINAL ~ 1000; maxBeamHeapLength: CARDINAL ~ 1000; --2000 maxChordHeapLength: CARDINAL ~ 1000; --2000 maxSelectionLength: CARDINAL ~ 100; **************************************************************************** INLINE Procedures **************************************************************************** Ê Ä˜šœ™J™@Jšœ™Jšœ3™3Jšœ9™9J™Jšœ:™:JšœA™A—J˜šÏk ˜ Jšœœ ˜JšœœM˜`šœœœ˜J˜——Jšœ œ ˜Jšœ˜J˜Jšœœœ˜J˜Jšœœœ˜Jšœœœ˜J˜JšœL™LJšœ™JšœL™LJ˜Jšœ œœ ˜šœ œœ˜JšœœœÏc˜&Jšœœž˜3Jšœœž˜6Jšœœž$˜;Jšœœž>˜UJšœœž˜Jšœ œž&˜9Jšœ œœž˜/Jšœœœž ˜5Jšœœž˜#Jšœœœœ ž˜˜OJšœœœ˜4Jšœ œ#˜3J˜Jšœ œœ ˜šœ œœ˜Jšœœž˜,Jšœœž˜,Jšœœž˜/Jšœœž˜)Jšœœž&˜6Jšœž*˜FJšœž2˜OJšœœœž˜+Jšœœœž˜-Jšœœœž˜:Jšœœœž˜-Jšœœœž˜/Jšœœœ˜Jšœ!ž.˜OJšœœœž*˜>Jšœœž&˜:Jšœ œž˜1Jšœœœ˜Jšœž2˜MJ˜Jšœž.˜BJšœž0˜HJšœž6˜QJšœœœž5˜MJšœ œž+˜BJšœ˜—J˜Jšœ œ!˜0Jšœ œ"˜2Jšœœ%˜8J˜šœœœ˜Jšœœ˜Jšœ œ˜Jšœ œ˜Jšœœœž)˜@Jšœ˜J˜—Jšœ œœ ˜šœ œœ˜Jšœœœ˜Jšœœž+˜?Jšœœž˜+Jšœœœœ˜"Jšœ˜J˜—Jšœ œœ ˜šœ œœ˜Jšœœž˜Jšœœœž6˜KJšœž4˜SJšœœž'˜DJšœœž!˜6Jšœœž,˜AJšœ œœ˜Jšœœž˜,Jšœœž˜(Jšœœœœ ž˜8Jšœ˜—J˜Jšœ œœž ˜8J˜šœœ˜J˜—JšœN™NJšœ ™ JšœN™NJ˜Jšœ œœ ˜$šœ œœ˜Jšœœ˜Jšœœœœ˜"Jšœ˜—Jšœœœ˜&šœœœ˜Jšœœ˜Jšœœœœ ˜$Jšœ˜J˜—Jšœ œœ ˜šœ œœž*˜CJšœ œ˜Jš œ œœ œœž˜=Jšœœž˜6Jšœœž˜?Jšœž˜7Jšœ˜J˜—Jšœ œœ ˜šœ œœ˜Jšœœ˜Jšœœ ž˜1Jšœœž9˜KJšœžC˜]Jšœž6˜PJšœœž ˜4Jšœ œž!˜9Jšœœž5˜QJšœ œœ˜Jšœ œœ˜Jšœœœ˜J˜!Jšœ œœ˜Jšœ œœž˜3Jšœ œœž(˜@Jšœœž˜'Jšœ œž˜*Jšœœž˜,Jšœ œœœ ž˜=J˜J˜—šœ œœ˜JšœžL˜\Jšœœž3˜FJšœœž#˜6Jšœœž˜-Jšœ˜Jšœ˜J˜—Jšœ œ˜J˜šœœœ˜Jšœœž˜3Jšœœž!˜0Jšœ˜J˜—Jšœ œœ ˜šœ œœ˜Jšœœ˜Jšœœœœ ˜%Jšœ˜J˜—Jšœœœ˜&šœœœ˜Jšœ œœž$˜>Jšœœž/˜FJšœž˜,Jšœœž˜7Jšœ$ž˜?Jšœœž˜,Jšœœœœ ž˜4Jšœ˜J˜—Jšœ œ#˜4J˜Jšœ œ-˜=Jšœ œt˜…J˜Jšœ œ™Jšœ œ™Jšœ œ™Jšœ œ™Jšœœœž™;Jšœœ™ Jšœœ ž™*Jšœœ ž™+Jšœœ™#J˜Jšœ œ˜.Jšœ œ˜Jšœ œ!˜0J˜JšœL™LJšœ™JšœL™LJ˜š Ïnœœœœœ˜7šœœ˜Jšœœœ˜Jšœœ˜)Jšœœœ˜—J˜J˜—šŸ œœœ œ˜:Jš œœœ&œœ˜RJšœ˜J˜—šŸœœ œ œ˜2Jšœœœ ˜%Jšœ˜J˜—š Ÿœœœœœœ˜7Jšœœœœ ˜!Jšœ˜J˜—šŸœœ&œ˜