

If you plan to play a MIDI file quickly and easily, this is it.MIDI itself, which stands for "Musical Instrument Digital Interface", is just a protocol and standard for communication between musical instruments and any device that understands the language. Not to mention that while this is easy, it might break some competition rules - which is why I don't plan to elaborating too much. Good enough for a beginner 64K, don't you think? You might notice that I didn't delete the file later on, I think that it is quite easy and you should be able to learn this on your own.
#Purebasic play midi file .exe#
exe and dump it into the file when the user runs the application. This application here doesn't read the MIDI file straight from memory, it allows you to include a binary file into the. Syntax: WriteData(*MemoryBuffer, LengthToWrite)ĭescription: Write the contents of the specified memory buffer in current file. If you give it the size of the whole file, then it will write the whole file, easy. It makes your job easy as you doesn't have to loop byte per byte.
#Purebasic play midi file code#
The code speaks for itself, no explaination is needed. But you must first create a file using CreateFile(), after you finished writing the data, then close it using CloseFile(). I think that the code speaks for itself, nothing too complex there, except for one. WriteData(*StartFile, *EndFile - *StartFile)ĬreateIncludeFile("canon.mid", ?StartFile_frunlog, ?EndFile_frunlog) Procedure CreateIncludeFile(Name.s, *StartFile, *EndFile) Pure Basic makes it easy to embed data into your. Anyway, it was just a simple binary data writing, the trick is embedding the file and get its memory address. Someone has written an example on including a file and to dump it to disk, but I can't remember who it was.

#Purebasic play midi file how to#
Since Polaris already taught you how to use pecompiler, I'll guess I'll skip that one. Each MIDI loaded must be given a number, and you use that number to play that particular MIDI file. However, the 0 / zero is the MIDI number. Most of the function is self explanatory.


NOTE: For this tutorial, I'm not sure if you can run it using demo version of Pure Basic, this is because it uses Win32 calls.īut as far as simplicity goes, this is all what you need to play a MIDI file inside Pure Basic, MCI way. Just copy/paste to see how other functions works. Open the file to see how to communicate with MCI using Pure Basic, and other available functions. It is supplied with jaPBe, an even more powerfull editor (it's free and open source, written with Pure Basic too -P) for Pure Basic. There is a midi.pbi written by a very helpful person, but I don't know his name. So before I went into some long code, I want to cover music first.įirst, I will give credits where it's due. 1 - graphics programming with Pure Basic is easy. NOTE: I stray away from Polaris' tutorial for a reason. If your idea of music is techno, electronic, etc - this file format might be useless, but having access to a lot of real world musical intruments, and writing tunes & melody using notation software, or MIDI hardware - for a small size file, IT IS GREAT! The MIDI file format is alive, well, and NOT updated means something - it can stand the test of time. If you think that MIDI is dead, think again. It's still a good way to add a music to your demos. Why part 1? Simply, for now I'm teaching you how to play a MIDI file using MCI and NOT DirectX.
