Playing .midi's?

Blitz3D Forums/Blitz3D Beginners Area/Playing .midi's?

po(Posted 2004) [#1]
I can't seem to figure out how to play .midi music(and loop it) maybe i'm not doing it right. Can someone post and example of how you would play .midi's(I've tried PlayMusic()?


Boiled Sweets(Posted 2004) [#2]
Don't think you can loop midi with standard blitz calls as you need to use LoopSound but it only works on raw/wav/mp3/ogg files.


po(Posted 2004) [#3]
*sigh* Do you know any programs that can convert .midi's into .wav's or .mp3's?


QuickSilva(Posted 2004) [#4]
The point of using midi is to keep file sizes down so by converting to wav\mp3 you may as well be using higher quality tunes in the first place. Saying this there are programs that can convert between the diffrent formats like Audacity and GoldWave (I think...)

You can play midi files using PlayMusic and then just test for when the song has ended maybe with a channelplaying command. If it is false then you can just issue the playmusic command again to restart the midi from the beginning.

I hope this helps,
Jason.


rockford(Posted 2004) [#5]
You can also convert MIDI to XM using Mid2XM (Doh!).

Go here for details - http://www.blitzcoder.com/cgi-bin/articles/show_article.pl?f=norki06212004225707.html

It seems like a lot of hassle, but it doesn't take that long and the results are good. Be sure to download the "kit" though, as the specified file doesn't include the instruments.


BlackD(Posted 2004) [#6]
Hehe - that is a good method. Just tried it. :) Works fairly well, except I found with a lot of MIDs, it records the XM at an octave too high, and there seems no way to change this in the program.

So then, its a matter of opening the XM up in ModPlug and going, CTRL-5 (select pattern) on each pattern, then clicking CTRL-ALT-A (lower-one-octave) then hitting NUMPAD PLUS (move to the next pattern). Adds another 5 minutes onto the production time, but yeah - if you're dead-set on not using MIDs and don't know how to track (write music in a tracker) yourself, then its worth it.

+BlackD


BlackD(Posted 2004) [#7]
Anyway, in answer to your original question, looping MIDIs is exactly as QuickSilva said. Example code:

	music=PlayMusic("test.mid")
	Print "Playing.."
	While Not KeyHit(1)
		If Not ChannelPlaying(music) Then music=PlayMusic("test.mid"):Print "Looping.."
	Wend
	End

In your main loop, just add a check to see if the music is playing, and if not - start playing it. :)

+BlackD

[EDIT: I subconciously forgot to close the test program, and I've just had a midi loop 14 times.. no wonder that tune was starting to get annoying. Here I was thinking "does this stupid song NEVER END?"]


simi(Posted 2004) [#8]
Hello,
I've the opposit of po's problem. When I play a short mid-sound in BB2D, the sound is not stopping, he starts playing again at the end. With BB+ I have not this Problem.
Someone in the German-Forum saids, BB "don't know when the mid-sound ends". Is this nearly a bug?

simi

I hope you understand my terrible englisch....


po(Posted 2004) [#9]
Thanks. The reason I am using .midi's is because I am using Finale 2003 to make the music, which only saves as .midi's and some other junk.