100 PROGRAM "tvcmid2.bas" 110 OUT 191,12 120 TEXT 130 INPUT PROMPT "Midi filename:":FN$ 140 OPEN #1:"file:"&FN$&".mid" ACCESS INPUT 150 LET X$="1" 155 INPUT PROMPT "ADSR; 0-normal 1-piano 2-organ:":ADSR 156 IF ADSR>2 THEN GOTO 155 160 PRINT :PRINT "Initializing..." 170 NUMERIC TRACK1(1 TO 1500),DUR(1 TO 1500),NOTE(31 TO 110) 180 FOR B=31 TO 107 190 READ A 200 LET NOTE(B)=A 210 NEXT 220 PRINT :PRINT "Reading header...":PRINT 230 FOR A=1 TO 22 240 GET #1:A$ 250 NEXT 260 PRINT "Looking for track..." 270 DO 280 GET #1:A$ 290 IF A$=CHR$(144) THEN EXIT DO 300 LOOP 310 PRINT "Track found." 320 PRINT "Converting track..." 330 LET SG=1 340 LET TRACK=1:CALL CONVERT 350 PRINT "Track converted.":PRINT 360 IF X$="1" THEN GOTO 590 370 DEF CONVERT 380 DO 390 GET #1:A$ 400 GET #1:B$ 410 GET #1:C$ 420 IF A$=CHR$(255) AND B$=CHR$(47) AND C$=CHR$(0) THEN EXIT DO 430 IF C$=CHR$(129) THEN 440 GET #1:C2$ 450 LET C$=CHR$(ORD(C$)+ORD(C2$)) 460 END IF 470 GET #1:D$ 480 GET #1:E$ 490 GET #1:F$ 500 IF TRACK=1 THEN 510 LET TRACK1(SG)=NOTE(ORD(A$)) 520 LET DUR(SG)=ORD(C$)/5 530 LET SG=SG+1 540 END IF 550 IF F$<>CHR$(0) AND TRACK=1 THEN LET TRACK1(SG)=4095:LET DUR(SG)=ORD(F$)/5:LET SG=SG+1 560 LOOP 570 !IF TRACK=1 THEN LET TRACK1(SG)=4095:LET DUR(SG)=25:LET SG=SG+1 580 END DEF 590 CLOSE #1 600 PRINT "Saving TVC basic program..." 610 OPEN #2:"file:"&FN$&".txt" ACCESS OUTPUT 620 PRINT #2:" 220 RESTORE" 630 PRINT #2:" 230 FOR A=1 TO "&STR$(SG-1) 640 IF X$="1" THEN 650 PRINT #2:" 240 READ G,I" 651 IF ADSR=0 THEN 652 PRINT #2:" 250 SOUND; PITCH G,DURATION I" !normal 653 PRINT #2:" 260 REM" 654 PRINT #2:" 270 REM" 655 PRINT #2:" 280 REM" 656 END IF 657 IF ADSR=1 THEN 658 PRINT #2:" 250 SOUND; PITCH G,DURATION 2,VOLUME 12" !piano 659 PRINT #2:" 260 SOUND; PITCH G,DURATION 2,VOLUME 10" 660 PRINT #2:" 270 SOUND; PITCH G,DURATION I-2,VOLUME 8" 661 PRINT #2:" 280 REM" 662 END IF 663 IF ADSR=2 THEN 664 PRINT #2:" 250 SOUND; PITCH G,DURATION 2,VOLUME 2" !organ 665 PRINT #2:" 260 SOUND; PITCH G,DURATION 2,VOLUME 4" 666 PRINT #2:" 270 SOUND; PITCH G,DURATION 2,VOLUME 6" 667 PRINT #2:" 280 SOUND; PITCH G,DURATION I*1.3,VOLUME 8" 668 END IF 670 END IF 680 PRINT #2:" 290 NEXT" 690 LET SORSZAM=300 700 PRINT #2:SORSZAM "data "; 710 PRINT "Line number:" 720 PRINT SORSZAM 730 FOR A=1 TO SG-1 740 IF X$="1" THEN PRINT #2:STR$(TRACK1(A))&","&STR$(DUR(A)); 750 IF STR$(A)(LEN(STR$(A)):LEN(STR$(A)))<>"0" THEN 760 PRINT #2:","; 770 ELSE 780 LET SORSZAM=SORSZAM+10:PRINT #2: 790 PRINT #2:SORSZAM "data "; 800 PRINT SORSZAM 810 END IF 820 NEXT 830 PRINT #2: 840 CLOSE #2 850 DATA 110,334,545,744,932 860 DATA 1110,1277,1436,1585,1726,1859,1984,2103,2215,2320,2420,2514 870 DATA 2603,2687,2766,2840,2911,2977,3040,3099,3155,3208,3258,3305 880 DATA 3349,3391,3431,3468,3503,3537,3568,3598,3626,3652,3677,3701 890 DATA 3723,3744,3763,3782,3800,3816,3832,3847,3861,3874,3887,3898 900 DATA 3909,3920,3930,3939,3948,3956,3964,3971,3978,3985,3991,3997 910 DATA 4003,4008,4013,4018,4022,4026,4030,4034,4037,4041,4044,4047