Qmidi Quick Reference
Learn using QMidi in a Blast!

We suppose that SBMIDI and SBSIM are loaded correctly in memory, so the library can allocate them. Those are the steps to add music to your game.

Note: I use the OBJ version of the lib, which you can stick into your LIB/QLB very easily. You can get it here: http://usuarios.lycos.es/firstqbasicforum/qmidiobj.html

0.- Use driversloaded to initialise the sound library [in the OBJ version of QMIDI] (*):

 FUNCTION DRIVERSLOADED% '(Returns the state of the drivers 1- SBSIM loaded
'256 SBMIDI loaded 257 both loaded 0 nothing loaded)

1.- You need an integer handle. Let's say "myMusic%"
2.- You load your midi using myMusic% = loadMIDI%("FILE.MID")
3.- Now you can play it. Before you loop starts, call playMIDI myMusic%.
4.- Inside your loop, do a call to loopMIDI. This function just looks if the song has finished and it triggers it again if it has.
5.- Once you need to change your music, you...
5.1.- STOP the midi: call stopMIDI .
5.2.- Unload the midi: call unloadMIDI myMusic% . This is very important.
6.- Now you can jump to #2 to load another tune.

(*) I've noticed that in QMidi 4.1 (the .BAS version) this function differs quite a bit. Check it in the DOC file. The rest is just the same.

QmidiQuickReference - page last edited 2004-01-02 08:28:08 by (home) (edit)
Blast WIKI - by RoboticBoy - edited and tweaked for our evil purposes by Hexadecimal Disaster