Game freezing for short periods of time
by Steve Self · in Torque Game Engine · 12/23/2005 (6:05 pm) · 6 replies
I have been making a small area using the tutorial.base demo and it has been going smoothly. Then I decided to add a sound for when you get an item. Now, about once a minute, the game freezes up for several seconds and not even the cursor will move. It seems to happen to me on starter.fps as well... any idea why this happens? The sound is programmed all into one script, one I made for a simple money system which is in a subfolder of the server folder. The actual sound is in data/sound. The sound-playing script is as follows (I am pretty new to torquescript, so I may be using a bad approach to sound):
The moneyIncrease function occurs when you get coins and the money displayed is less than the actual money (the function makes the displayed money go up by 1 and plays the sound until it gets to the actual money value).
Any ideas on how to stop the freezing? In case it would help:
Windows XP Home Edition
768MB ram
1.8 GHz P4
Radeon 8500
My friend tried it on his computer and it said it didn't freeze.
datablock AudioDescription(MoneySound)
{
volume = 1.0;
isLooping = false;
is3D = false;
type = 2;
};
datablock AudioProfile(MoneySoundPro)
{
filename = "~/data/sound/Money.wav";
description = "MoneySound";
preload = true;
};
function moneyIncrease()
{
if ($moneytemp < $money) {
$moneytemp = $moneytemp + 1;
$moneytext = "Money: $" @ $moneytemp;
schedule(50,0,"moneyIncrease");
alxPlay(MoneySoundPro);
}
}The moneyIncrease function occurs when you get coins and the money displayed is less than the actual money (the function makes the displayed money go up by 1 and plays the sound until it gets to the actual money value).
Any ideas on how to stop the freezing? In case it would help:
Windows XP Home Edition
768MB ram
1.8 GHz P4
Radeon 8500
My friend tried it on his computer and it said it didn't freeze.
#2
12/23/2005 (11:06 pm)
Thanks for the suggestion... but I don't really think it is the function... the reason is that I had the function before I put in the sound... and it didn't freeze. Also, it doesn't freeze when you get the coin (which starts the function off), but randomly when you are walking around the map.
#3
12/23/2005 (11:34 pm)
Many sounds at once may cause the problem, I'd definitely try upping the time delta to about 1000 and seeing if the problem goes away. Since you're starting off many sounds from the function, it might be that not giving them time to finish playing is causing problems.
#4
The "Torque Warzone Demo" and the starter.fps do the exact same thing (not sure about the racing demo), and I know that they have sound in them. Could it be a problem with OpenAL, or maybe a problem with the sound datablock itself?
EDIT: The pause only seems to occur when I have a sound assigned to the datablock. When I comment out the filename line, the problem stops. It's not THAT big of a problem since I am getting a new laptop (and since it is a different computer it will probably work normally) but it would be nice to figure out what is going on.
12/24/2005 (9:25 am)
Thanks, I'll try your suggestion and see if it helps... but I don't think it has to do with the function. The reason is that it freezes even if I haven't gotten a coin yet. Just in case it might be useful, the thing I did before the sound was add environmental mapping to the coin. That is not when it started freezing, though. Also, I made sure to make the sound less than 50 milliseconds long (so that it wouldn't be playing when the next sound started).The "Torque Warzone Demo" and the starter.fps do the exact same thing (not sure about the racing demo), and I know that they have sound in them. Could it be a problem with OpenAL, or maybe a problem with the sound datablock itself?
EDIT: The pause only seems to occur when I have a sound assigned to the datablock. When I comment out the filename line, the problem stops. It's not THAT big of a problem since I am getting a new laptop (and since it is a different computer it will probably work normally) but it would be nice to figure out what is going on.
#5
We're working on an audio layer rewrite that ought to resolve a bunch of this stuff. The current sound code has some lame limitations (some from OpenAL, some from the fact that it was a fast port of a bunch of stuff that depended on Miles).
Did you know that Tribes 2 was originally going to use OAL, then they switched to Miles, and then for Torque had to switch back to OAL?
12/24/2005 (8:12 pm)
Well, if there's no sound and no problem then that definitely means the audio code is the issue. You said the problem occurs even if the sound isn't playing, or before the sound's played?We're working on an audio layer rewrite that ought to resolve a bunch of this stuff. The current sound code has some lame limitations (some from OpenAL, some from the fact that it was a fast port of a bunch of stuff that depended on Miles).
Did you know that Tribes 2 was originally going to use OAL, then they switched to Miles, and then for Torque had to switch back to OAL?
#6
Actually it seems to be freezing less now... but maybe I am just imageining things. Anyway, I'll be watching for the audio update. :)
12/24/2005 (9:42 pm)
Thanks for the information... can't wait till my laptop arrives and it doesn't freeze up!Actually it seems to be freezing less now... but maybe I am just imageining things. Anyway, I'll be watching for the audio update. :)
Torque Owner Demolishun
DemolishunConsulting Rocks!