|
This thread is locked; no one can reply to it. |
1
2
|
Midi temporarly chokes for a moment after playing a bit. How to fix? |
Alex Hanson-White
Member #6,657
December 2005
|
Been trying to find an answer to this problem all day. I searched all over this forum to see if there was anything that'd help, but now I come and post this topic. The problem is, that I can get a midi playing.. but after a while of it playing, it stutters a bit and then chokes(the whole program) for a few seconds, and then it unchokes and then the midi speeds up to catch up to its place. Any ideas what could be causeing this? It only chokes when its playing the midi. |
Inphernic
Member #1,111
March 2001
|
Can you post some code (playing parts, main loop, etc)? The whole program choking does not necessarily sound like a MIDI-specific problem, there could be something wrong in for ex the frame limiter, if you have one. And welcome, awesome pixel art you have there (and on your site). -- |
Alex Hanson-White
Member #6,657
December 2005
|
thanks, here's some code to help find the problem, hopefully..
and here is the frame limit function since you mentioned it.. volatile long speed_counter = 0; // A long integer which will store the value of the // speed counter. void increment_speed_counter() // A function to increment the speed counter { speed_counter++; // This will just increment the speed counter by one. :) } END_OF_FUNCTION(increment_speed_counter); // Make sure you tell it that it's the end of the // function
|
Onewing
Member #6,152
August 2005
|
Are you trying to loop the midi? Why not use: Also, have you tried loading a different midi song to see if it "chokes" as well? ------------ |
Alex Hanson-White
Member #6,657
December 2005
|
looping is not a problem, it chokes even when it runs the midi once. |
Inphernic
Member #1,111
March 2001
|
There doesn't seem to be anything wrong with that code (pertaining to this particular problem - you should check whether the bitmap/midi loads were successful though + some other unrelated things ). Try examples/exmidi and tests/miditest, do they exhibit the same problem? What compiler/OS/midi synth are you using? -- |
Steve Terry
Member #1,989
March 2002
|
Is speed_counter initialized properly? ___________________________________ |
Alex Hanson-White
Member #6,657
December 2005
|
I dont know how to get exmidi.exe to play a midi file, but I downloaded someones allegro game which played midis, and it played fine in their game. when i run miditest.exe it says microsoft midi mapper under the driver.. |
Inphernic
Member #1,111
March 2001
|
exmidi.exe <filename> -- |
Alex Hanson-White
Member #6,657
December 2005
|
oh ok, yeah, driver is microsoft midi mapper, and the music plays fine in exmidi.exe I notice when I change the bps to like 6000 or some big number, it takes forever for the program to quit while it just keeps playing the music with a black screen(when the program shuts down). dunno if that has any significance.. |
Billybob
Member #3,136
January 2003
|
Why not just play_midi before the loop, instead of inside of it?
|
Alex Hanson-White
Member #6,657
December 2005
|
i tried that too, it makes no difference. I tried takeing out the timer function stuff, and it had no difference either. |
Arthur Kalliokoski
Second in Command
February 2005
|
In Windows9x I've noticed that any huge disk access will cause any midi player stuff to "choke", seems that the multitasker is locked out or something. They all watch too much MSNBC... they get ideas. |
Onewing
Member #6,152
August 2005
|
Quote: The problem is, that I can get a midi playing.. but after a while of it playing, it stutters a bit and then chokes(the whole program) for a few seconds, and then it unchokes and then the midi speeds up to catch up to its place. Hmmm...reading that again makes me think that something is making the sound driver "think" or the processor or something. At this point, I would just make a small program and just focus directly on the playing the midi without any stuttering. Something like: int main(int argc, char *argv[]) { allegro_init(); install_keyboard(); install_sound(DIGI_AUTODETECT, MIDI_AUTODETECT, argv[0]); midi_intro = load_midi("intro_temp.mid"); play_looped_midi(midi_intro, 0, -1); while(!key[ESCAPE]){} return 0; } END_OF_MAIN();
------------ |
Alex Hanson-White
Member #6,657
December 2005
|
hm.. odd. I did a small program:
and it still has the choking problem.. |
Onewing
Member #6,152
August 2005
|
Quote: do you think maybe it's my compiler? No. Like you said, without the midi, it runs fine. I doubt that has anything to do with it. Is it choking in the same parts or is it relatively sporadic? ------------ |
Inphernic
Member #1,111
March 2001
|
Alex Hanson-White
Member #6,657
December 2005
|
its relatively sporadic.. EDIT!: EDIT2: |
Inphernic
Member #1,111
March 2001
|
The OS' scheduler may throttle your application in order to give some CPU time for other processes. If another process (perhaps even with a higher priority) wants to do something intensive, your program could be affected by that. If the choking seems to be periodic, that might help you to identify the offending process (if any). Rest(1) effectively introduces a delay of 1ms (due to granularity, more like 10ms) to your program, by which it makes sure that it's not hogging all the CPU time. Considering that adding it had a positive effect, I'd say the problem is indeed related to some sort of throttling. I'm not an expert on scheduling though, so take this with a grain of salt. Quote: this sux that i cant post consecutive replies.. You can use the "Send to top" button after a period of inactivity to send this thread right back to the top without making a reply (useful if you just edit your last message). Don't abuse it, though. -- |
Steve++
Member #1,816
January 2002
|
You will notice that if you play a MIDI in Windows Media Player or WinAmp (just to name a couple), you will not get these problems. That is because those programs fully delegate the MIDI functionality to Windows, which in turn uses its own real-time services to ensure stuttering doesn't occur (except under extreme load). Allegro programs on the other hand take full control of the MIDI sequence and send MIDI events to the OS's MIDI mapper (or its own if that's what you choose) and are therefore at the mercy of the operating system's multitasking. There are other related problems of course, such as the Allegro MIDI routines stripping out XG and GS events, and even some GM events. MIDI is bad enough without it being clobbered by Allegro. The only solution is don't use Allegro MIDI. Ever. |
Inphernic
Member #1,111
March 2001
|
And by relying on plain MIDI altogether, your songs can end up sounding totally different on different setups. What goes for alternatives: go for XM/IT if file size is a priority, MP3/OGG if quality is a priority (this is a bit of a simplified statement, but anyway). -- |
Simon Parzer
Member #3,330
March 2003
|
MIDI is also very bad when it comes to Linux compatibility. In the most cases the only way to play them is using Timidity, which gives very crappy sound at the cost of very much CPU time. My personal advice: Go for IT! Use Schism Tracker for creating the music (Win32 builds here) and DUMB for playing it in your Allegro program. |
miran
Member #2,407
June 2002
|
@ Schism Tracker -- |
Alex Hanson-White
Member #6,657
December 2005
|
hm, i see.. Well, before all of this, i did try to use dumb, but I was unable to make it work, because the instructions to get it incorporated into a project were confuseing for me. If someone could help me with that, maybe I can try it again.. |
Corelian
Member #3,376
March 2003
|
Quote: Schism Tracker Woah! Looks just like Scream Tracker 3. That was a sweet piece of software back in the day. |
|
1
2
|