sync on:sync rate 0
create bitmap 1,640,480:set current bitmap 1
open to read 1,"ares.mid"
Header$=ByteChunk$(1,3)
print Header$
HeaderSize$=ByteHex$(1,3)
print HeaderSize$
MidiFormat$=ByteHex$(1,1)
print MidiFormat$
MidiTracks$=ByteHex$(1,1)
print MidiTracks$
DeltaTime$=ByteHex$(1,1)
print DeltaTime$
tracknex:
print
TrackHeader$=ByteChunk$(1,3)
print TrackHeader$
MidiData$=ByteHex$(1,3)
print MidiData$
recall:
Delta=hexval(bytehex$(1,0))
print "DeltaTime - "+str$(Delta)
if MSB(Delta)=1 then goto recall:
aftercall:
Dat$=ByteHex$(1,0)
if Dat$="FF " then goto metaevent:
`---------------------------- MIDI RUNNING EVENTS ----------------------
Command$=left$(Dat$,1):Channel=hexval("0"+right$(Dat$,2))
if Command$="0"
print "Unknown (0x)"
endif
if Command$="1"
print "Unknown (1x)"
endif
if Command$="2"
print "Unknown (2x)"
endif
if Command$="3"
print "Unknown (3x)"
endif
if Command$="4"
print "Unknown (4x)"
endif
if Command$="5"
print "Unknown (5x)"
endif
if Command$="6"
print "Unknown (6x)"
endif
if Command$="7"
print "Unknown (7x)"
endif
if Command$="8"
print "Key Release (Note Off) (8x)"
print "Channel:"+str$(Channel):Note=hexval(ByteHex$(1,0))
print "Note:"+str$(Note):Velocity=hexval(bytehex$(1,0))
print "Translated Note:"+Transcribe$(Note)
print "Velocity:"+str$(Velocity)
endif
if Command$="9"
print "Key Pressed (Note On) (9x)"
print "Channel:"+str$(Channel):Note=hexval(ByteHex$(1,0))
print "Note:"+str$(Note):Velocity=hexval(bytehex$(1,0))
print "Translated Note:"+Transcribe$(Note)
print "Velocity:"+str$(Velocity)
endif
if Command$="A"
print "Key After-Touch (Ax)"
print "Channel:"+str$(Channel):Note=hexval(ByteHex$(1,0))
print "Note:"+str$(Note):Velocity=hexval(bytehex$(1,0))
print "Translated Note:"+Transcribe$(Note)
print "Velocity:"+str$(Velocity)
endif
if Command$="B"
print "Control Change (Bx)"
print "Channel:"+str$(Channel):Control=hexval(ByteHex$(1,0))
print "Controller Number:"+str$(Control):NewNum=hexval(bytehex$(1,0))
print "Change Value:"+str$(NewNum)
endif
if Command$="C"
print "Instrument (Patch) Change (Cx)"
print "Channel:"+str$(Channel):Patch=hexval(ByteHex$(1,0))
print "Instrument Number:"+str$(Patch)
endif
if Command$="D"
print "Channel After-Touch (Dx)"
print "Channel:"+str$(Channel):ChanNum=hexval(ByteHex$(1,0))
print "Channel Number:"+str$(ChanNum)
endif
if Command$="E"
print "Pitch Wheel Change (Ex)"
print "Channel:"+str$(Channel):Wheel$=ByteHex$(1,1)
print "Change:"+Wheel$
endif
if Command$="F"
print "Unknown (Fx)"
endif
copy bitmap 1,0:sync:cls:Pause(180)
goto recall:
`---------------- MIDI META EVENTS ----------------------------
metaevent:
Print "Midi Meta Event FF:"
Cmd$=ByteHex$(1,0):TrackGo=0:print cmd$
if Cmd$="00 "
print "Set Sequence Number (00)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$
if lng$"00 " then Para$=ByteHex$(1,1):print "Parameters:"+Para$
endif
if Cmd$="01 "
print "Text Event (01)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TxtBytes=HexVal(Lng$)
print "Translated Length:"+str$(TxtBytes)
Para$=ByteChunk$(1,TxtBytes-1)
print "Text:"+Para$
endif
if Cmd$="02 "
print "CopyRight Info (02)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TxtBytes=HexVal(Lng$)
print "Translated Length:"+str$(TxtBytes)
Para$=ByteChunk$(1,TxtBytes-1)
print "Info:"+Para$
endif
if Cmd$="03 "
print "Sequence Or Track Name (03)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TxtBytes=HexVal(Lng$)
print "Translated Length:"+str$(TxtBytes)
Para$=ByteChunk$(1,TxtBytes-1)
print "Name:"+Para$
endif
if Cmd$="04 "
print "Track Instrument Name (04)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TxtBytes=HexVal(Lng$)
print "Translated Length:"+str$(TxtBytes)
Para$=ByteChunk$(1,TxtBytes-1)
print "Name:"+Para$
endif
if Cmd$="05 "
print "Lyric Words (05)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TxtBytes=HexVal(Lng$)
print "Translated Length:"+str$(TxtBytes)
Para$=ByteChunk$(1,TxtBytes-1)
print "Lyric:"+Para$
endif
if Cmd$="06 "
print "Marker (06)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TxtBytes=HexVal(Lng$)
print "Translated Length:"+str$(TxtBytes)
Para$=ByteChunk$(1,TxtBytes-1)
print "Mark:"+Para$
endif
if Cmd$="07 "
print "Cue Point (07)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TxtBytes=HexVal(Lng$)
print "Translated Length:"+str$(TxtBytes)
Para$=ByteChunk$(1,TxtBytes-1)
print "Cue:"+Para$
endif
if Cmd$="20 "
print "Midi Channel Prefix (20)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:Para$=ByteHex$(1,0)
print "Parameters:"+Para$
endif
if Cmd$="21 "
print "Midi Port (21)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:Para$=ByteHex$(1,0)
print "Parameters:"+Para$
endif
if Cmd$="51 "
print "Set Tempo (51)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:Para$=ByteHex$(1,2)
print "Parameters:"+Para$
endif
if Cmd$="54 "
print "SMPTE Time Code (54)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:Para$=ByteHex$(1,4)
print "Parameters:"+Para$
endif
if Cmd$="58 "
print "Time Singature (58)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:Para$=ByteHex$(1,3)
print "Parameters:"+Para$
endif
if Cmd$="59 "
print "Key Singature (59)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:Para$=ByteHex$(1,1)
print "Parameters:"+Para$
endif
if Cmd$="2F "
print "End Track (2F)":Lng$=ByteHex$(1,0)
print "Parameter Length:"+Lng$:TrackGo=1
endif
copy bitmap 1,0:sync:cls:Pause(180)
if TrackGo=1 then goto tracknex:
goto recall:
`-------------------------------------------------------------------------
function ByteChunk$(Filenumber,Chunklength)
tmp$=""
for i=0 to Chunklength
read byte Filenumber,N
tmp$=tmp$+chr$(N)
next i
endfunction tmp$
function ByteHex$(Filenumber,Chunklength)
tmp$=""
for i=0 to Chunklength
read byte Filenumber,N
if len(Hex$(N))=1 then fore$="0"+Hex$(N) else fore$=Hex$(N)
tmp$=tmp$+fore$+" "
next i
endfunction tmp$
function HexVal(hexnum$)
if len(hexnum$)=1 then h$="0"+hexnum$:hexnum$=h$
NYBBLE$=mid$(hexnum$,1):V=0
if val(NYBBLE$)>0 then V=Val(NYBBLE$)
if NYBBLE$="A" then V=10
if NYBBLE$="B" then V=11
if NYBBLE$="C" then V=12
if NYBBLE$="D" then V=13
if NYBBLE$="E" then V=14
if NYBBLE$="F" then V=15
NYBBLE$=mid$(hexnum$,2):V2=V*16:V=0
if val(NYBBLE$)>0 then V=Val(NYBBLE$)
if NYBBLE$="A" then V=10
if NYBBLE$="B" then V=11
if NYBBLE$="C" then V=12
if NYBBLE$="D" then V=13
if NYBBLE$="E" then V=14
if NYBBLE$="F" then V=15
endfunction V2+V
function BSL(Initial,ShiftAmount)
ANW=Initial*(2^ShiftAmount)
endfunction ANW
function MSB(v)
B$=Right$(Bin$(v),8):C$=Left$(B$,1):Toggle=Val(C$)
endfunction toggle
Function Transcribe$(note)
Octive=0
While Note>11
Dec Note,12:Inc Octive,1
endwhile
if Note=0 then NL$="C"
if Note=1 then NL$="C#"
if Note=2 then NL$="D"
if Note=3 then NL$="D#"
if Note=4 then NL$="E"
if Note=5 then NL$="F"
if Note=6 then NL$="F#"
if Note=7 then NL$="G"
if Note=8 then NL$="G#"
if Note=9 then NL$="A"
if Note=10 then NL$="A#"
if Note=11 then NL$="B"
TMP$=NL$+" ["+str$(Octive)+"]"
endfunction TMP$
Function Pause(t)
tmp=timer()+t
while tmp>timer()
sync:endwhile
endfunction