Yes, this code works fine with my Lazarus IDE v3.4 on Manjaro Linux.
I am also looking for a lazarus program that can do the reverse, so reading a midi file and show in a form or terminal the start of the notes, the duration, and the velocity.
Would that also be possible, or do you know somebody that wrote someting like that?
Thanks for your feedback germona! Nice to hear that the code also works on Linux.
"I am also looking for a lazarus program that can do the reverse, so reading a midi file and show in a form or terminal the start of the notes, the duration, and the velocity."We are talking about 'MIDI parsing' here I guess.
In other words, how to use Pascal code to extract the musical information from a MIDI file that you want to use for a specific purpose. Reading information from a MIDI file is a much more complex challenge than the fairly simple MIDI file generation code I presented. Above all, it's about what you really want to do, i.e. for what purpose you want to read MIDI information from a MIDI file. Just to list the notes, the duration, and the velocity or develop something more advanced?
MIDI programming is really interesting and there are many different libraries for Pascal as well. However, it is more educational to learn how to manage a MIDI file at a very low level and get to know the structure of a MIDI file from the very start. It may be a long but interesting road.
To read a MIDI file by coding, you need the knowledge about at least the following:
How to handle and read computer file on a byte and bit level. The hexadecimal system. MIDI File Structure overall: Chunk Structure, MIDI Events (Note on/Note off, running status etc.), Meta Events (key signature, time signature, tempo value etc.), Delta Time, Variable-Length Quantity (VLQ) values and so on.
Coding a MIDI parser from scratch can be a great learning experience, but it takes a lot of effort. After you know the basics, it's easier to get familiar with different code libraries.
There are various tutorials on the Internet that are sometimes hard to find. In any case, it is worth starting from the following site:
https://midi.org/standard-midi-files-specificationI'm always looking for good tutorial sites on the internet my self too and would be happy to receive tips.