<> <> <> <> <> DIRECTORY Beam USING [Drawn], Event USING [Adjust, Draw, GetScoreIndex], MusicDefs, Note USING [DrawTie, InVoice], Piece USING [NearestEvent], Score USING [Draw, GetKey, Justify, LogicalToPhysical, ScalePhysical, SetStyle, ShowPitch], Selection USING [Draw, selection], Sheet USING [default, Draw, FindStaves, Height, HiLite, MapNote, Scale, SetBegin], Utility; ScoreImplB: CEDAR PROGRAM IMPORTS Beam, Event, MusicDefs, Note, Piece, Score, Selection, Sheet, Utility EXPORTS Score = BEGIN OPEN MusicDefs; <<****************************************************************************>> <> <<****************************************************************************>> <> <> <<[] _ Graphics.SetPaintMode[score.sheet.context, pnt];>> <<};>> <<>> Draw: PUBLIC PROC[score: ScorePTR, erase: BOOL _ FALSE] = { sheet: SheetPTR _ score.sheet; Selection.Draw[]; -- remove selection from screen <> <> <> <> <> <<};>> DrawInterval[score, sheet.begin, sheet.endTime]; Selection.Draw[]; }; Redraw: PUBLIC PROC[score: ScorePTR, t1, t2: Time] = { x, y: INTEGER; select: BOOLEAN; selection: SelectionPTR _ Selection.selection; Utility.SetBrush[score.sheet.context, black, transparent]; SELECT score.sheet.scale FROM 1 => IF t2-t1 > 700 THEN {Score.Draw[score]; RETURN}; 2 => IF t2-t1 > 2000 THEN {Score.Draw[score]; RETURN}; 4 => IF t2-t1 > 8000 THEN {Score.Draw[score]; RETURN}; ENDCASE; select _ selection.lineSelect AND selection.select2 > t1-40 AND selection.select1 < t2+50; IF select THEN Selection.Draw[]; -- remove selection from screen Sheet.HiLite[score.sheet, white, t1-20, t2+30]; DrawInterval[score, t1-30, t2+40]; IF select THEN Selection.Draw[]; IF selection.lineSelect THEN RETURN; Utility.SetBrush[score.sheet.context, black, invert]; FOR i: CARDINAL IN [0..selection.length) DO IF selection.note[i] = NIL THEN LOOP; IF selection[i].sync.time > t2+40 OR selection[i].sync.time < t1-30 THEN LOOP; IF ~Note.InVoice[selection[i], score.sheet.voice] THEN LOOP; [x, y] _ Sheet.MapNote[score.sheet, selection[i]]; Utility.SetCP[score.sheet.context, x, y]; Utility.DrawChar[score.sheet.context, 170C]; ENDLOOP; }; debug: BOOL _ TRUE; DrawInterval: PROC[score: ScorePTR, t1, t2: Time] = { staves: StavesPTR; j: CARDINAL _ 0; sheet: SheetPTR _ score.sheet; IF debug THEN Sheet.Draw[sheet]; [] _ Beam.Drawn[score, NIL]; -- clears the beam cache Utility.SetBrush[score.sheet.context, black, transparent]; <> staves _ Sheet.FindStaves[sheet, t1]; IF staves#NIL THEN FOR i: NAT IN[0..staves.length) DO staff: Staff ~ staves.staff[i]; IF staff.pitch # 15 AND staff.pitch # 60 THEN LOOP; FOR j: NAT DECREASING IN[0..score.length) DO -- search backward for last octava before t1 event: EventPTR ~ score.event[j]; IF event.time IF ev.value=i THEN SELECT ev.staves FROM octava1 => { Event.Draw[score, ev]; EXIT }; octava2 => EXIT; ENDCASE; ENDCASE; ENDLOOP; ENDLOOP; <> j _ 0; IF score.sheet.display = graphical THEN FOR i: NAT IN[0..score.length) DO event: EventPTR ~ score.event[i]; IF event.time < t1 THEN LOOP; IF event.time > t2 THEN EXIT; WITH event SELECT FROM sync: SyncPTR => { Event.Adjust[score, sync]; IF j<10 THEN j _ j+1 ELSE EXIT }; ENDCASE; ENDLOOP; <> j _ 0; FOR i: NAT IN [0..score.length) DO IF score.event[i].time < t1 THEN LOOP; IF score.event[i].time > t2 THEN {j _ i; EXIT}; IF score.sheet.display = graphical THEN { plus10: NAT ~ MIN[i+10, score.length-1]; WITH score.event[plus10] SELECT FROM sync: SyncPTR => Event.Adjust[score, sync]; ENDCASE; }; Event.Draw[score, score.event[i]]; <> ENDLOOP; <> IF j # 0 THEN FOR i: NAT IN [j..score.length) DO event: EventPTR ~ score.event[i]; IF event.time > t2+200 THEN EXIT; WITH event SELECT FROM sync: SyncPTR => { FOR j: NAT IN [0..sync.length) DO n: NotePTR ~ sync.note[j]; IF n=NIL THEN EXIT; IF n.tie#NIL AND n.tie.sync.time<=t2 THEN { Utility.SetColor[score.sheet.context, IF Note.InVoice[n, score.sheet.voice] THEN black ELSE light]; Note.DrawTie[score, n]; }; ENDLOOP; }; ENDCASE; ENDLOOP; [] _ Beam.Drawn[score, NIL]; }; <<****************************************************************************>> <> <<****************************************************************************>> Print: PUBLIC PROC[score: ScorePTR, splines: BOOLEAN] = {}; <<****************************************************************************>> <> <<****************************************************************************>> Look: PUBLIC PROC[score: ScorePTR, look: LookCommand, switch: BOOLEAN, n: INTEGER] = { < IF score = old THEN score _ new;>> draw: BOOLEAN _ TRUE; SELECT look FROM accidental => score.sheet.accidental _ switch; hardcopy => { Sheet.Scale[score, IF switch THEN 2 ELSE 1]; score.sheet.hardcopy _ switch}; justified => { score.sheet.density _ n; Score.Justify[score, Selection.selection.select1, Selection.selection.select2]}; logical => Score.LogicalToPhysical[score, Selection.selection.select1, Selection.selection.select2]; noCarry => score.sheet.noCarry _ switch; notehead => score.sheet.notehead _ switch; overview => Overview[score, switch]; physical => Score.ScalePhysical[score, 512/n]; style => Score.SetStyle[score, n, 0, EndOfScore[score]]; sync => score.sheet.sync _ switch; voice => {score.sheet.voice _ IF ~switch THEN noVoice ELSE n}; ENDCASE; }; Overview: PROC[score: ScorePTR, switch: BOOLEAN] = { <> <> SELECT TRUE FROM score.sheet.scale < 4 AND ~switch => {score.flash _ TRUE; RETURN}; score.sheet.scale > 2 AND switch => {score.flash _ TRUE; RETURN}; switch => {Sheet.Scale[score, 4]; Sheet.SetBegin[score.sheet, 0]}; < {>> <<[x, y] _ Sheet.ScreenPoint[score.sheet];>> <