100 OPEN #3,con_430x100a50x16:SCALE #3,100,0,-100:PAPER #3,4:INK #3,0:OVER #3,1
110 OPEN #4,scr_400x100a80x16:PAPER #4,4:CLS
140 DIM notes(45),position(45):notes$="":RESTORE 5000
150 FOR i=0 TO 45:READ line$,notes(i),position(i):notes$=notes$&line$
160 DIM time(3):FOR i=0 TO 3:READ time(i)
170 DIM music$(500)
500 l_note=0:draw_scale
1000 c_note=1:pos=0:key1=0
1010 REPeat key
1020 CURSOR #3,30+pos*20,30
1030 IF key1 THEN key=key1:key1=0:ELSE Q_CURSON #3:key=CODE(INKEY$(#3,-1)):Q_CURSOFF #3
1040 SELect ON key
1050 =192
1060 note_l
1070 =200
1080 note_r
1090 =202,204
1100 IF c_note<l_note THEN music$(c_note+1 TO l_note)=music$(c_note TO l_note+1)
1110 l_note=l_note+1:music$(c_note)=CHR$(46):ins_note pos,c_note
1120 =194,196
1130 IF l_note<1 THEN NEXT key
1140 IF c_note<l_note THEN music$(c_note TO l_note-1)=music$(c_note+1 TO l_note)
1150 IF c_note<=l_note THEN l_note=l_note-1:del_note pos,c_note
1170 =208
1180 j=CODE(music$(c_note)):IF l_note<1 OR j MOD 64<1 THEN NEXT key
1190 upd_note j-1
1200 =216
1210 j=CODE(music$(c_note)):IF l_note<1 OR j MOD 64>45 THEN NEXT key
1220 upd_note j+1
1230 =209,212
1240 j=CODE(music$(c_note)):IF l_note<1 OR j<64 THEN NEXT key
1250 upd_note j-64
1260 =217,220
1270 j=CODE(music$(c_note)):IF l_note<1 OR j>192 THEN NEXT key
1280 upd_note j+64
1290 =65 TO 71,97 TO 103
1300 note$=CHR$(key)&" ":Q_CURSON #3:key1=CODE(INKEY$(#3,-1)):Q_CURSOFF #3
1310 SELect ON key1=35,183:note$(2)=CHR$(key1):Q_CURSON #3:key1=CODE(INKEY$(#3,-1)):Q_CURSOFF #3
1320 IF key1<48 OR key1>52 THEN NEXT key
1330 i=(CHR$(key1)&note$) INSTR notes$:key1=0:IF i<1 THEN NEXT key
1335 upd_note (i-1)/3:l_note=l_note+(c_note>l_note)
1340 =240
1350 i=c_note-pos:IF i+19>l_note THEN play_notes i,l_note:ELSE play_notes i,i+19
1360 =244
1370 play_notes 1,l_note
1380 =232
1390 AT 15,0:INPUT "ENTER LOAD FILE NAME"!fname$
1400 IF fname$="" THEN CLS 3:NEXT key
1410 OPEN_IN #5,fname$:j=0
1420 REPeat lines
1430 IF EOF(#5) THEN EXIT lines
1440 INPUT #5,line$
1450 FOR i=1 TO LEN(line$)-3 STEP 4
1460 j=j+1:music$(j)=CHR$(line$(i)*64+(line$(i+1 TO i+3) INSTR notes$-1)/3)
1470 END FOR i
1480 END REPeat lines
1490 CLOSE #5:c_note=1:pos=0:l_note=j:CLS 3:draw_scale
1495 FOR i=1 TO 20:IF i<=l_note THEN dis_note i-1,i
1500 =236
1510 AT 15,0:INPUT "ENTER SAVE FILE NAME"!fname$
1520 IF fname$="" THEN CLS 3:NEXT key
1530 DELETE fname$:OPEN_NEW #5,fname$
1540 FOR i=1 TO l_note
1550 j=CODE(music$(i)):PRINT #5,j DIV 64;:j=j MOD 64*3+1:PRINT #5,notes$(j TO j+2);
1560 IF i MOD 18=17 THEN PRINT #5
1570 END FOR i
1580 PRINT #5:CLOSE #5:CLS 3
1900 =27:EXIT key
1910 END SELect 
1920 END REPeat key
3000 DEFine PROCedure dis_note(pos,c_note)
3010 LOCal x,y,y1,d,i
3020 note=CODE(music$(c_note)):d_note=note DIV 64:note=note MOD 64
3025 IF note>45 THEN RETurn 
3030 x=pos*15+25:y=-6-position(note)*3
3040 i=note*3+1:CURSOR #3,x,y+4,4:PRINT #3,notes$(i+2);
3050 CURSOR #3,30+pos*20,90:PRINT #3,notes$(i TO i+1);
3060 FILL #3,d_note>1:CIRCLE #3,x,y,2:FILL #3,0:IF d_note<1 THEN RETurn 
3070 IF note>19 THEN d=1:y1=y+16:ELSE d=-1:y1=y-16
3080 x=x+2:LINE #3,x,y TO x,y1:IF d_note<3 THEN RETurn 
3090 FOR i=3 TO d_note:LINE #3,x,y1 TO x-4,y1-4*d:y1=y1-d*4
3100 END DEFine 
3110 DEFine PROCedure clr_block(pos)
3120 LOCal k
3130 j=30+pos*20:BLOCK #3,16,100,j,0,4
3140 FOR k=9 TO 33 STEP 6:BLOCK #3,16,1,j,k,7:BLOCK #3,16,1,j,k+36,7
3150 END DEFine 
3160 DEFine PROCedure play_notes(s_note,e_note)
3170 LOCal i,col
3180 draw_scale:col=99:note_t=0:TIMER_RST
3190 FOR i=s_note TO e_note:play col,i
3200 note_t=note_t-TIMER:IF note_t>0 THEN PAUSE note_t
3205 BEEP:PAUSE:draw_scale
3210 FOR i=0 TO 19:IF c_note-pos+i>l_note THEN RETurn :ELSE dis_note i,c_note-pos+i
3220 END DEFine 
3230 DEFine PROCedure play(pos,c_note)
3240 LOCal j
3250 pos=(pos+1)*(pos<19):clr_block pos
3255 note=CODE(music$(c_note)):d_note=note DIV 64:note=note MOD 64
3257 note_t=note_t-TIMER:IF note_t>0 THEN PAUSE note_t:ELSE PRINT #0,"wait";
3260 BEEP:PAUSE 1:IF note>45 THEN RETurn 
3270 BEEP 0,notes(note):TIMER_RST:note_t=time(d_note)
3280 CURSOR #3,j,position(note)*3+1:PRINT #3,"o";notes$(note*3+3);
3290 END DEFine 
3300 DEFine PROCedure draw_scale
3310 CLS #3:BLOCK #3,3,25,0,9,7:BLOCK #3,3,25,0,45,7
3320 FOR i=9 TO 36 STEP 6:BLOCK #3,430,1,0,i,7:BLOCK #3,430,1,0,i+36,7
3330 END DEFine 
3340 DEFine PROCedure note_r
3350 IF c_note>l_note THEN RETurn 
3360 c_note=c_note+1:IF pos<19 THEN pos=pos+1:ELSE del_note 0,c_note-20
3370 END DEFine 
3380 DEFine PROCedure note_l
3390 IF c_note<=1 THEN RETurn 
3400 c_note=c_note-1:IF pos>0 THEN pos=pos-1:ELSE ins_note 0,c_note
3410 END DEFine 
3420 DEFine PROCedure del_note(pos,c_note)
3430 LOCal k
3440 WINDOW #4,400-pos*20,100,80+pos*20,16:PAN #4,-20
3450 FOR k=9 TO 33 STEP 6:BLOCK #3,20,1,410,k,7:BLOCK #3,20,1,410,k+36,7
3460 IF c_note+20-pos<l_note THEN dis_note 19,c_note+20-pos
3470 END DEFine 
3480 DEFine PROCedure ins_note(pos,c_note)
3490 LOCal k
3500 WINDOW #4,400-pos*20,100,80+pos*20,16:PAN #4,20
3510 FOR k=9 TO 33 STEP 6:BLOCK #4,20,1,0,k,7:BLOCK #4,20,1,0,k+36,7
3520 dis_note pos,c_note
3530 END DEFine 
3540 DEFine PROCedure upd_note(note)
3550 music$(c_note)=CHR$(note):clr_block pos:dis_note pos,c_note
3560 IF note<46 THEN BEEP 2000,notes(note)
3570 END DEFine 
5000 DATA "0a ",3,0,"1g#",3,1,"1g ",4,1,"1f#",5,2,"1f ",6,2,"1e ",7,3,"1e",8,3
5010 DATA "1d ",9,4,"1c#",10,5,"1c ",11,5,"1b ",12,6,"1b",13,6,"1a ",15,7
5020 DATA "2g#",16,8,"2g ",18,8,"2f#",20,9,"2f ",22,9,"2e ",24,10,"2e",26,10
5030 DATA "2d ",28,11,"2c#",30,12,"2c ",33,12,"2b ",36,13,"2b",38,13,"2a ",41,14
5040 DATA "3g#",43,15,"3g ",46,15,"3f#",50,16,"3f ",54,16,"3e ",58,17,"3e",62,17
5050 DATA "3d ",66,18,"3c#",71,19,"3c ",76,19,"3b ",82,20,"3b",87,20,"3a ",92,21
5060 DATA "4g#",97,22,"4g ",103,22,"4f#",111,23,"4f ",120,23,"4e ",127,24,"4e",134,24
5070 DATA "4d ",142,25,"4c#",152,26,"4c ",162,26
5080 DATA 64,32,16,8
