Home | Reviews | GUIpedia | Forum | Fun500


QMidi looping
Hey, How do I loop A Midi, or how do I detect if a midi is playing or not? thanks. I want looping music in my game, Kase-block.
2009-02-221:06 AM

ToddRe:QMidi looping
I never really got MIDIs working in DOS but I'd imagine you'd have to find the loop you are using to play the MIDI and sync it with the loop for the game. Technically, you'd have to combine the loops to play tunes along with the game play. To tell if a MIDI is playing, just check to see if you're not at the EOF or see that your SEEK index is less than or equal to the LOF. The problem with MIDIs is that they do not work the same way as WAV or MP3 files. MIDIs use a soundboard built into the sound card and extended by the operating system or a program (if you use SoundBlaster with DOS). The soundboard produces the sound according to the notes the MIDI makes so all the tunes are pre-recorded either through the sound card or the soundboard extension of the OS. I never really had much luck getting MIDIs to play in DOS. Since I never had a soundboard extension for QBasic or DOS, it could never play.
2009-02-229:26 AM

Re:QMidi looping
QMidi uses Assembly to play the music. I have to run. SBMIDI and SBSIM to make make the midis work properly.
2009-02-224:04 PM

ToddRe:QMidi looping
SBMIDI probably provides the MIDI soundboard extension for your sound card. SBSIM is the interface module for your sound card in DOS. You said it uses Assembly. Does it use QB's INTERRUPT method or is it a compiled LIB file?
2009-02-225:16 PM

Re:QMidi looping
http://www.petesqbsite.com/downloads/qmidi41.zip I don't understand. DW. just have a look around the code. :)
2009-02-231:24 AM

ToddRe:QMidi looping
It does use INTERRUPTs. Looking at the code, there are subroutines like "StopMIDI" and a function called "TimeMIDI" to return the playback time. My guess would be that you could loop it but you'd just have to know how long your MIDI plays and then every interval, play the MIDI again.
2009-02-238:50 AM

Re:QMidi looping
Ok, for my song it's 109. Thank you a ton! :)
2009-02-233:37 PM

Re:QMidi looping
There is a MIDILoop function in QMIDI.BAS You can either call this function in a loop or you can modify this function - split it at two functions: IS_playing and Play_if_not_playing. I also wrote a port of this library for Pascal (works in Turbo pascal and Freepascal) http://www.laaca.borec.cz/soubory/midipas.zip
2009-02-285:40 AM

Re:QMidi looping
Which version of QMidi would it be? I don't I downloaded the latest one. Version 3.5?
2009-02-286:13 PM

Re:QMidi looping
Update: There's a 'user friendly' version called midilib. It has LoopMIDI, Thanks so much! :cheer: :cheer: :cheer:
2009-02-286:17 PM

BASIC Programming Help


2021 Brandon Cornell