22nd October 2011, 12:43 AM
MCI object bug (revised)
An MCI error occures when you tell the the MCI object to play a tune. The error is that the MCI("status tune mode") commmand returns "playing" as a string even though the music is not playing. Eventually the music will start to play despite this error, but for a duration of 1 or 2 seconds the MCI string will read "playing" when there is nothing being played. MCI("play tune"), MCI("play tune from 0") and MCI("resume") all exhibited the same occasional error. This error causes my game to be unplayable.
In my game there are active objects which fall down the screen, and you must press a particular key when the object has fallen. These active objects fall in time to the music being played by the MCI object. I used MCI because unlike the "play music" action, I can load external audio files. Meaning I can create new levels without editing the .exe by storing the positions of active objects in an ini file.
The basic code works something like this:
#DEFINE PLAYBAR = 8000
int stopnotes = 0
start of frame : centre display at (100,8000)
while (stopnotes == 0) : y("note")++;
always : y("initiate_music_note")++;
if y("note") > PLAYBAR : destory "note"
start of frame : MCI("open "+Appdrive$+Appdir$+"song.mp3 alias tune")
when y("initiate_music_note") > PLAYBAR : MCI("play tune"), destroy("initiate_music_note") , set stopnotes = 1
while (stopnotes == 1) : MCI("status tune mode")
while (stopnotes == 1) : set alterable string of syncstring to MCI(return string)
compair 2 general values , alterable string("syncstring") equals "playing" : set stopnotes = 0
This segment of code will move any number of active object "note" down the screen towards towards an invisible bar. When the note reaches the bar, the note is desroyed. If the note has a disapearing animation of a blue light flashing, you will see flashes in time to the music (provided the notes on the play area are positioned correctly).
Is there an MCI command I am unaware of that flushes the MCI memory? Perhaps there is a set of MCI commands I could use in a specific order to eliminate the error? I've searched the forum for information and found none, and dissected the offical example with no results.
I'm unaware of how the MCI object operates at it's core level. Whether it is part of TGF or if it is a function call to windows is beyond me. However I would like to know this information. I'd like to know if it can or cannot be fixed. What sort of details are there about MCI? All I know is it opens a handful of audio file types and plays them with a bit of control.
22nd October 2011, 11:31 PM
Re: MCI object bug
Here is the finished game so you can see the glitch for yourself. http://www.mediafire.com/?sa8ck3xiswns027
It's 7.3mb. To see the glitch, press play - music editor - type "red_sign" into the text box and hit enter. Then click on "auto" to put a line under it, click on the E letter, then click "load" and wait for the green bar to finish, then click "test". This will automatically play the old song Red Sign.
I am using build 251, on windows vista. Most of the time the song plays at the right moment. But sometimes the MCI returns the string "playing" before the MCI initiates the audio file.
While playing the game you find yourself having to restart the song so you can listen to the song as you play. Also, if this were to be played online, the chance that the MCI glitch occures would increase because more people are playing at the same time. This means that if one player gets the glitch in versus mode, every player must restart! Considering the glitch would be more likely to happen in versus mode, versus mode isn't even worth implementing.
I need there to be a solution to this bug so I can further develop my game and implement online play.
1st November 2011, 03:11 AM
I seem to have got it working. After numerous trials, I cannot make it break. Usually to break the synchronization, I'd run the editor then switch to play mode, and that would induce the off sync effect. I tried repeated times with no failure rate.
All I did to fix the program was uncheck "compress the runtime" and I also disabled the "show debugger" and "enable debugger keyboard shortcuts". I'm not sure not using the debugger would make a difference, but maybe not compressing the runtime did. Any thoughts on this?