ChannelPlaying/Playmusic and Midi

Blitz3D Forums/Blitz3D Programming/ChannelPlaying/Playmusic and Midi

JoeRetro(Posted 2004) [#1]
I've notice some odd behavior playing midi files as compared to ogg and mp3 files. The midi files continue to loop whereas the ogg/mp3 files finish playing and stop (no looping) when using PlayMusic. Also, when I call ChannelPlaying on midi files I get a huge performance hit (each time I call) as opposed to ogg/mp3 files.

Has anyone else notice this behavior?


Rob Farley(Posted 2004) [#2]
Nope... but what's your point?


Damien Sturdy(Posted 2004) [#3]
i get that. i dont use midi files anymore.


JoeRetro(Posted 2004) [#4]
I have now reproduced it on 3 different computer systems. So it would appear there is a bug in the PlayMusic/ChannelPlaying functions when accessing midi files.


Rob Farley(Posted 2004) [#5]
As Damien says... Don't use Midi files, they're dreadful things anyway.


starfox(Posted 2004) [#6]
soooo....

its still a problem that needs to be solved..

it happens on other formats too


aab(Posted 2004) [#7]
Yep... but using Midi's wasnt something that helped quality anyway so im able to accept it myself


JoeRetro(Posted 2004) [#8]
The point is that some shareware developers (as myself) would like to use midi for present and future projects regardless if one thinks that ogg/mp3's are the way to go which is debatable anyway. It's all about your niche.


John Blackledge(Posted 2004) [#9]
I spent 3 years writing a midi sequencer, so if anyone should be wedded to midi it's me.

But for use with Blitz you can't beat wav/mp3/ogg because then you know exactly what the user is going to hear, not some poxy squeaks and buzzes from an onboard sound chip.

I still use a sequencer, but I take the output (usually from my XG card) back in to the PC, and record as audio, save as WAV, then convert to OGG. The quality is brilliant.


Damien Sturdy(Posted 2004) [#10]
John, i realy, REALY would apreciate some help from you... do you know the midi format well?

Ive been struggling to write an "importer" for weeks!!!!!!!!


John Blackledge(Posted 2004) [#11]
No! No! Trust me, you do not wanna do this!
Kiss your life goodbye, and really be known as a geek!
(Writing the sequencer cost me a marriage.)
Give me a really good reason why I should help you commit intellectual suicide.


John Blackledge(Posted 2004) [#12]
Anyway, how are you going to detect midi input for recording? That's definitely a low-level Windows function (and to my knowledge not available from within Blitz).

If you are going to read in midifiles from disk, once you've decoded the midi, and you can 'play it back' within your code, what are you going to apply the notes to - there's no frequency-based sound generator that I'm aware of that Blitz can drive.

Trust me, if you must do this, Blitz is _not_ the language.


IPete2(Posted 2004) [#13]
John's right man!

(...as usual) lol!

Anyways This is not an Amiga or an Atari we are talking about here. It is a PC and the performance and quality would vary so much between users as to make it a rather unworkable to any acceptable level.

If you are having a performance hit with midi you should certainly look at other formats. Wav and particularly ogg are acceptable, legal formats with little or no restraints upon them. Look at reducing the voice down to 11,025 and musci down to 22,050 (mono 16 bit) for very aceptable quality and very reduced performance hits.

IPete2.


Damien Sturdy(Posted 2004) [#14]
Im just looking to learn a few things. ive written a MIDI synth before but not a midi file.. hehe... Just want to import a Midi file, and have its data stored somewhere in memory, in a more easily usable way.
Once ive done it once, im likely not going to do it again. Would have been great if i was still doing ND Music Technology... :/


there's no frequency-based sound generator that I'm aware of that Blitz can drive.



Oh no? what did i just write? *evil grin*

Its not spectacular, but its there....
http://www.blitzbasic.com/codearcs/codearcs.php?code=1201

I'm sorry it cost you a marriage though.. sad ending there :(.


IM not actually writing a synth, just a bit of a tracker, for learning purposes, and later il be writing a proper one.

its just the decoding of the .MID i need to do :/ got it almost sussed (my sound system plays Super Mario to me)

Can you help at all? its no worries if not (of course...) but this simple little function.. okay, so its not so simple... would teach me a thing or two!

I couldnt decipher the old Midi in Qbasic thing, though i did write a Softsynth in QB once. :/


John Blackledge(Posted 2004) [#15]
You're obviously well ahead enough that you can read Note On/ Note Off/ Program Controls information.

Really, if you must do this, then the .MID reader _must_ be your own - the techniques are very much up to you.
I do remember that my .MID read-in function was an absolute pain - I hated the format - I remember that at one point in the code I had to (file) SEEK backwards, to reread the data, then forwards again. Urgh.
It's a crap format, which is why all sequencer writers create their own load/save format.

Also my program (called 'Midistudio') was written for the Atari and was written in GFA Basic, which like Blitz was a piece of genius that gave assembler-like speed; so it would be a little hard to give you the code.

Good luck.
Email me directly if you want to bounce any more ideas off me.


Luke.H(Posted 2004) [#16]
Why don't you delay with a counter after you call PlayMusic.

like this:

If MusicDelay=0 And ChannelPlaying(MusicChannel)=0 Then
MusicChannel=PlayMusic("Music.mp3")
MusicDelay=100
end if
if MusicDelay>0 then MusicDelay=MusicDelay-1



I do not know but for me it seemed that while the music was reloading, ChannelPlaying equalled 0


Damien Sturdy(Posted 2004) [#17]
mines doing the seek thing too. hehehe.. it is indeed a right pain in the ass....


You're obviously well ahead enough that you can read Note On/ Note Off/ Program Controls information.



Wrong- i seem to be getting note on/note off, but its 1) getting incorrect Delta time at some point (i cant figure it out). and 2) sometimes it seems to miss the "command" and then all goes horribly wrong.

If i cant sus it shortly, il email you- Prolly just asking about your technique.

Cheers :)