--Author: John Maxwell --last modified: December 15, 1981 4:52 PM DIRECTORY Beam USING [SetStems], Graphics USING [DisplayContext, DrawRectangle, GetTexture, MakeFont, MoveTo, Scale, SetLineWidth, SetPaint, SetTexture, Texture, Vec], InlineDefs USING [LowHalf], MusicDefs, Piece USING [AddSync, RemoveSync], Score USING [BuildCache, cache, cacheLength, DrawKey, Look], Selection USING [AddLine], Sheet USING [default, FindLine, FindSection, Map, NextLine, NormalPitch, OctavaHeight, PriorLine, Reset, SetBegin], StringDefs USING [AppendDecimal], Sync USING [GetScoreIndex, Hidden, SetStave], Utility USING [DrawChar, DrawLine, DrawString, NewSync, SetFont]; SheetImplA:PROGRAM IMPORTS Beam, Graphics, InlineDefs, MusicDefs, Piece, Score, Selection, Sheet, StringDefs, Sync, Utility EXPORTS MusicDefs, Sheet = BEGIN OPEN MusicDefs, Score, Sheet; begin:PUBLIC Time; endTime:PUBLIC Time; scale,staffLength:PUBLIC INTEGER; --**************************************************************************** --the sheet consists of an array of Sections --**************************************************************************** sheet:PUBLIC ARRAY [0..sheetLength) OF Section; Initialize:PUBLIC PROCEDURE[dc:Graphics.DisplayContext] = BEGIN context _ dc; music _ Graphics.MakeFont["music"]; text _ Graphics.MakeFont["TimesRoman"]; Utility.SetFont[context,music,8]; style _ ALL[[NIL,0,0,0,[[0,0],[0,0],[0,0],[0,0]]]]; -- pianoroll style[0] _ [NIL,0,60,3,,]; style[0].staff _[[72,-32],[48,-88],[27,-136],[3,-196]]; -- one staff style[1] _ [NIL,0,80,3,,]; style[1].staff _[[48,-32],[48,-32],[48,-32],[48,-32]]; -- two staffs style[2] _ [NIL,0,85,3,,]; style[2].staff _[[48,-32],[48,-32],[27,-125],[27,-125]]; style[12] _ [NIL,0,85,3,,]; style[12].staff _[[48,-32],[48,-32],[27,-150],[27,-150]]; -- three staffs style[3] _ [NIL,0,75,3,,]; style[3].staff _[[48,-32],[48,-32],[27,-110],[27,-185]]; style[13] _ [NIL,0,75,3,,]; style[13].staff _[[48,-32],[48,-32],[27,-130],[27,-220]]; -- four staffs style[4] _ [NIL,0,75,3,,]; style[4].staff _[[48,-32],[48,-110],[27,-185],[27,-260]]; show _ [,TRUE,TRUE,FALSE,FALSE,TRUE,graphical]; selection _ ALL[NIL]; selectionLength _ 0; begin _ 0; scale _ 1; staffLength _ 550; TF _ 256; Score.Look[sheet,,2]; Selection.AddLine[0,0]; END; Reset:PUBLIC PROCEDURE= BEGIN sync:SyncPTR_NIL; staves:StavesPTR_NIL; page,pitch:INTEGER_2; v,j,last,next:CARDINAL_0; time,break,lastBreak,cacheTime:Time _ 0; top,height,x,sc,lastHeight:INTEGER _ 0; Score.BuildCache[]; IF scale=2 THEN sc_3 ELSE sc_2*scale; [staves,last,next] _ NextStyle[NIL,0,0,100]; IF staves=NIL THEN RETURN; FOR i:CARDINAL IN [0..cacheLength] DO IF i#cacheLength AND cache[i].type NOT IN SheetSwitch THEN LOOP; IF i=cacheLength THEN cacheTime_LONG[staffLength]*sheetLength ELSE cacheTime_cache[i].time; WHILE time=break THEN { -- new line height _ height-lastHeight; x_ MAX[8,ABS[8*(sheet[j].key)]]; lastBreak _ break; break _ lastBreak+staffLength-x; [staves,last,next] _ NextStyle[staves,last,next,break-20]; lastHeight _ -staves.staff[staves.sl].y+staves.offset; IF top-height>(650*sc)/2 THEN { -- new page top _ height; sheet[j].page_page; page_page+1}}; sheet[j].x _ x; sheet[j].y _ height; sheet[j].staves _ staves; time _ MIN[break,cacheTime]; j _ j + 1; ENDLOOP; IF i=cacheLength THEN EXIT; IF cache[i].type=staves THEN LOOP; Sync.SetStave[staves,cache[i]]; staves_LOOPHOLE[@cache[i].event]; IF cache[i].type#clef THEN LOOP; IF Sync.Hidden[0,Sync.GetScoreIndex[cache[i]],lastBreak] THEN time_lastBreak; ENDLOOP; IF scale=2 THEN Paginate[]; Sheet.SetBegin[begin]; FOR i:CARDINAL IN [0..beamHeapLength) DO IF beamHeap[i].sync2.timemax THEN LOOP; Beam.SetStems[beamHeap[i]]; ENDLOOP; END; NextStyle:PROCEDURE[old:StavesPTR,last,next:CARDINAL, break:Time] RETURNS[StavesPTR,CARDINAL,CARDINAL] = BEGIN temp,new:StavesPTR; newLast,newNext:CARDINAL_0; new _ old; newLast _ last; newNext _ next; FOR i:CARDINAL IN [next..cacheLength) DO IF cache[i].time>=break+40 THEN EXIT; IF cache[i].type#staves THEN LOOP; newNext _ i; IF cache[i].time>=break THEN EXIT; temp _ LOOPHOLE[@cache[i].event]; IF temp=old THEN LOOP; IF new#NIL AND i#next AND new.staff[new.sl].y=time+staffLength THEN EXIT; IF cache[i].type#keySignature THEN LOOP; IF cache[i].time