ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
What if I wanted to write a program where I could say play play note A for 2 seconds and use the Oboe and then save it as an midi file? Where is the best place to learn how to construct midi files?
Depending on which language you wish to use, you may find a library that will do this for you.
If you wish to understand the format, you might find this midi specification and file format useful. The format consists of some encapsulation headers, and the midi data is stored as a sequence of(delta) timestamps and events.
For example, the following sample C code will produce a midi file that plays concert A on the oboe for 2 seconds.
The code uses macros for byte reversal (because midi is big-endian); this is not portable. It also uses macros for the midi time stamps (because these are variable in length and use the high bit of each byte as an extension bit) to keep the sample code manageable, but in practice you should use a function to produce these.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.