Audio handles, channels, profiles.. ahh
by James Petruzzi · in Torque Game Builder · 07/10/2007 (4:23 pm) · 2 replies
So we've ran into some problems with the audio system on our game. Basically, I'm just trying to understand the difference between a profile and handle, and how you can set a handle. Right now we're just doing something simple like this:
then to play:
This is creating a few problems though. For instance, one of our weapons is a shotgun, so when each individual pellet hits an enemy, it plays the blood splat sound that many times (which when its like 10, makes it REALLY loud). So the first problem is checking to see if the sound is playing. I saw the function "alxIsPlaying( handle )" but i don't know how to assign the handle.
The second problem, which seems like an engine problem or directly related to the above, is that occassionally the sound will loop over and over and over forever. I read on some TGE forum pages that the issue is invalid audio handles being assigned (null) and that it can't call it to stop.
Can someone please help??
new AudioDescription(AudioNonLooping)
{
volume = 1.0;
isLooping = false;
is3D = false;
type = 2;
};
new AudioProfile(enemyHit)
{
filename = "~/data/audio/hit_blood_spat.ogg";
description = "AudioNonLooping";
preload = true;
};then to play:
alxplay ( enemyHit );
This is creating a few problems though. For instance, one of our weapons is a shotgun, so when each individual pellet hits an enemy, it plays the blood splat sound that many times (which when its like 10, makes it REALLY loud). So the first problem is checking to see if the sound is playing. I saw the function "alxIsPlaying( handle )" but i don't know how to assign the handle.
The second problem, which seems like an engine problem or directly related to the above, is that occassionally the sound will loop over and over and over forever. I read on some TGE forum pages that the issue is invalid audio handles being assigned (null) and that it can't call it to stop.
Can someone please help??
#2
07/11/2007 (3:09 pm)
Just in case any has this problem in the future, the check to see if its playing seems to have fixed the infinite looping problem. It sounds like it was the same problem as I saw on the TGE posts about invalid handles being created for sounds and then not being able to stop them. It only occured for me when greater than 5 or 10 instances of a sound were being played at the same time with a handle that was a local variable. Hope this helps anyone that runs into this problem!
Torque Owner James Petruzzi
if(!alxIsPlaying($zombieHit)) $zombieHit = alxPlay(enemyHit);Not sure if this had corrected the infinite looping problem though. I will have to do further testing.