Recent

Author Topic: [CLOSED] Read MIDI file into messages  (Read 1143 times)

GreatCorn

  • New Member
  • *
  • Posts: 38
    • GreatCorn
[CLOSED] Read MIDI file into messages
« on: May 25, 2020, 08:38:31 am »
I've been trying to find a way to read a MIDI file into messages, process them and if needed, play. I don't need to just play the file (e.g. MCISendString). I can set up a MIDI output with MMSystem, but I just couldn't find a way to read a MIDI file in Pascal. Does anyone know how one could do that? The links I could find only lead to sites that don't exist anymore.
« Last Edit: May 28, 2020, 10:31:16 am by GreatCorn »

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: Read MIDI file into messages
« Reply #1 on: May 25, 2020, 08:58:25 am »
Start with Wikipedia. The key press/release messages are fixed-size words, the only complication will be if you have "song information" etc. that you need to skip.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

GreatCorn

  • New Member
  • *
  • Posts: 38
    • GreatCorn
Re: Read MIDI file into messages
« Reply #2 on: May 25, 2020, 09:36:54 am »
Oh, I guess I focused too much on Pascal and forgot about the basics. Time to get into byte parsing

TRon

  • Hero Member
  • *****
  • Posts: 2498
Re: Read MIDI file into messages
« Reply #3 on: May 25, 2020, 09:47:18 am »
In case you need something and are unable to locate it, then you can always try Tory, in this case https://torry.net/quicksearchd.php?String=midi&Title=Yes

Sometimes the things listed there are not 100% of what you want but at least there usually is some code around that is able to give you a few hints/tips.

MarkMLl

  • Hero Member
  • *****
  • Posts: 6682
Re: Read MIDI file into messages
« Reply #4 on: May 25, 2020, 11:45:21 am »
Oh, I guess I focused too much on Pascal and forgot about the basics. Time to get into byte parsing

I've parsed a data stream on a couple of occasions rather than a file, and broadly speaking there's very few surprises in it.

Remember that "sites that don't exist any more" are likely to be archived at archive.org.

MarkMLl
MT+86 & Turbo Pascal v1 on CCP/M-86, multitasking with LAN & graphics in 128Kb.
Pet hate: people who boast about the size and sophistication of their computer.
GitHub repositories: https://github.com/MarkMLl?tab=repositories

jamie

  • Hero Member
  • *****
  • Posts: 6128
Re: Read MIDI file into messages
« Reply #5 on: May 25, 2020, 12:23:33 pm »
If you want to read the file then this document lays out the format so you can read in chunks..


http://www.personal.kent.edu/~sbirch/Music_Production/MP-II/MIDI/midi_file_format.htm

if you have issues understanding how to parse that just come back...
The only true wisdom is knowing you know nothing

GreatCorn

  • New Member
  • *
  • Posts: 38
    • GreatCorn
Re: Read MIDI file into messages
« Reply #6 on: May 27, 2020, 12:22:56 pm »
Got away with parsing by porting a part of some Python code I found in source of an old program, which helped me understand the raw basics of MIDI files along with reading the articles you provided. Thank you all very much for the help! I could try to make it into a unit and post here for other answer seekers, but I guess this kind of thing was done numerous times. Now to get it to play in a GUI app...
« Last Edit: May 27, 2020, 12:26:05 pm by GreatCorn »

 

TinyPortal © 2005-2018