--Author: John Maxwell --last modified: November 23, 1981 11:10 AM DIRECTORY Graphics USING [DisplayContext,Texture], MusicDefs: FROM "MusicDefs"; Sheet: DEFINITIONS IMPORTS MusicDefs = BEGIN OPEN MusicDefs; Draw:PROCEDURE; DrawClef:PROCEDURE[pitch,staff:INTEGER,time:Time]; DrawOctava:PROCEDURE[pitch,staff,height:INTEGER,t1,t2:Time]; FindLine:PROCEDURE[t:Time] RETURNS[INTEGER]; FindSection:PROCEDURE[t:Time] RETURNS[INTEGER]; GetStyle:PROCEDURE[time:Time] RETURNS[INTEGER]; HiLite:PROCEDURE[tex:Graphics.Texture,t1,t2:Time]; Initialize:PROCEDURE[dc:Graphics.DisplayContext]; Reset:PROCEDURE; Scale:PROCEDURE[newScale:INTEGER]; Scroll:PROCEDURE[lines:INTEGER]; -- "currentLine _ currentLine+lines" SetBegin:PROCEDURE[now:Time]; SetClef:PROCEDURE[pitch,staff:INTEGER,time:Time]; SetOctava:PROCEDURE[pitch,staff,height:INTEGER,t1,t2:Time]; SetStyle:PROCEDURE[index:INTEGER,t1,t2:Time]; --INLINE Procedures Last:PROCEDURE[l:CARDINAL] RETURNS[CARDINAL] = INLINE {FOR i:CARDINAL IN [l..sheetLength-1) DO IF sheet[i].time#sheet[i+1].time THEN RETURN[i]; ENDLOOP; RETURN[sheetLength-1]}; LineNumber:PROCEDURE[l:CARDINAL] RETURNS[n:CARDINAL_1] = INLINE {FOR i:CARDINAL IN (0..l] DO IF sheet[i].y#sheet[i-1].y THEN n_n+1; ENDLOOP}; NextLine:PROCEDURE[l:CARDINAL] RETURNS[CARDINAL] = INLINE {FOR i:CARDINAL IN (l..sheetLength) DO IF sheet[i].y=sheet[l].y THEN LOOP; RETURN[Last[i]]; ENDLOOP; RETURN[sheetLength-1]}; NextStaff:PROCEDURE[s:CARDINAL,t:Time] RETURNS[CARDINAL] = INLINE {staves:StavesPTR = sheet[FindSection[t]].staves; FOR i:CARDINAL IN (s..staves.sl] DO IF staves.staff[i].y#staves.staff[s].y THEN RETURN[i]; ENDLOOP; RETURN[s]}; NormalPitch:PROCEDURE[staff:CARDINAL] RETURNS[INTEGER] = INLINE {RETURN[IF staff IN [0..1] THEN 48 ELSE 27]}; PriorLine:PROCEDURE[l:CARDINAL] RETURNS[CARDINAL] = INLINE {FOR i:CARDINAL DECREASING IN [0..l) DO IF sheet[i].y#sheet[l].y THEN {l_i; EXIT}; ENDLOOP; FOR i:CARDINAL DECREASING IN [0..l) DO IF sheet[i].y#sheet[l].y THEN RETURN[Last[i+1]]; ENDLOOP; RETURN[Last[0]]}; PriorStaff:PROCEDURE[s:CARDINAL,t:Time] RETURNS[CARDINAL] = INLINE {staves:StavesPTR = sheet[FindSection[t]].staves; FOR i:CARDINAL DECREASING IN [0..s) DO IF staves.staff[i].y#staves.staff[s].y THEN RETURN[i]; ENDLOOP; RETURN[s]}; OctavaHeight:PROCEDURE[pitch,height:INTEGER] RETURNS[INTEGER] = INLINE {IF pitch=60 AND height<40 THEN RETURN[40]; IF pitch=60 AND height>90 THEN RETURN[90]; IF pitch=15 AND height<-40 THEN RETURN[-40]; IF pitch=15 AND height>-8 THEN RETURN[-8]; RETURN[height]}; --************************************************************************* --mapping from sheet to screen and vice-versa --************************************************************************* --NotePTR => [Time,Pitch,Staff] => [Time,Height] => ScreenPoint; UNAMBIGUOUSLY! --[Time,Height] <= ScreenPoint; ambiguous when point is between lines --[Time,Pitch,Staff] <= [Time,Height]; ambiguous when between staffs --NotePTR <= [Time,Pitch,Staff]; ambiguous because of graphical adjustments default:INTEGER = 1000; AlternateTime:PROCEDURE[t1:Time,h1,lines:INTEGER] RETURNS[time:Time,height:INTEGER]; Height:PROCEDURE[t:Time,pitch:INTEGER_default,staff:CARDINAL] RETURNS[INTEGER]; NearestStaff:PROCEDURE[t:Time,height:INTEGER] RETURNS[INTEGER]; NearestTime:PROCEDURE[x,y:INTEGER_default] RETURNS[time:Time,height:INTEGER]; Map:PROCEDURE[t:Time,pitch:INTEGER_default,staff:CARDINAL] RETURNS[x,y:INTEGER]; MapHeight:PROCEDURE[t:Time,height:INTEGER] RETURNS[x,y:INTEGER]; MapNote:PROCEDURE[n:NotePTR] RETURNS[x,y:INTEGER]; Pitch:PROCEDURE[t:Time,height:INTEGER,staff:CARDINAL] RETURNS[INTEGER]; ScreenPoint:PROCEDURE RETURNS[x,y:INTEGER]; END..(0,4224)\214b4B12b8B43b10B51b8B37b11B37b8B40b6B45b10B40b5B12b5B31b6B30i33I2b8B22b7B43b9B51b8B60b4B184b10B138b8B188b9B235b11B105b9B274b10B237b12B349i43I142i13I34i37I41i29I35i44bI7B19b13B72b6B74b12B52b11B67b3B78b9B56b7B44b5B67b11B