program Poly2Ly; uses SysUtils, Algemeen, MidiDoos; var ch : integer; Bron,Doel : string; procedure Some_Help; begin Writeln('POLY2LY'); Writeln; Writeln('Which PolyText channel as Lyric'); Writeln; writeln('Syntax: [program] [IMF] [OMF] [CH]'); Writeln; Writeln('IMF = name of Input MidiFile'); Writeln('OMF = name of Output MidiFile'); Writeln(' CH = channel-number [0,15]'); end; procedure Read_Parameters(var OK : boolean); var woord : string; begin OK := true; if ParamCount <> 3 then begin Some_Help; OK := false; Exit; end; Bron := ParamStr(1); Doel := ParamStr(2); woord := ParamStr(3); ch := getnum(woord); if (ch < 0) or (ch > 15) then begin Writeln('Channel ',ch,' out of [0,15] range'); OK := false; Exit; end; if not FileExists(Bron) then begin Writeln(Bron + ': does Not exist'); OK := false; Exit; end; end; procedure Poly2Ly_(MF : Midi; ch : integer); var punt,aantal : integer; trk,p,q : integer; OK : boolean; let : byte; riedel : bytes; begin punt := 14; for trk := 0 to MF.Tracks-1 do begin MF.Check_Track_Header(punt,aantal,OK); p := punt; while (p < punt+aantal) do begin MF.Skip_Delta_Time(p); q := p; MF.Copy_Any_Event(p,riedel); let := riedel[0]; if not ($FF = let) then Continue; let := riedel[1]; if not ((let and $F0) = $10) then Continue; if (let and $0F) = ch then MF.invoer[q+1] := $05; end; punt := punt+aantal; end; end; procedure HoofdRoutine; { Beginning of Main program } var OK : boolean; MF : Midi; begin Read_Parameters(OK); if not OK then Exit; MF := Midi.Create; MF.Read_MidiFile(Bron); MF.Check_Structure(OK); if not OK then Exit; Poly2Ly_(MF,ch); MF.Write_MidiFile(Doel); end; BEGIN HoofdRoutine; END.