Game Development Community

Is it possible to play multiple sound files in one state?

by Lenny Shkirenko · in Torque Game Engine · 06/16/2002 (8:15 am) · 6 replies

Hi all,

I'm new to this forum and new to the world of game developement. I'm involved in starting development on an FPS game with my friend to satisfy a number of inadequecies with other engines (Half-Life, Quake, Unreal, etc..)

My question is:

Is there a way to play multiple sound files in a single state one after the other?
If so, then can a delay be introduced between them?

Example (from Rifle.cs):

// Play the reload animation, and transition into
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.01;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateScript[4] = "onReload";
stateSound[4] = "RifleMagOutSound";
stateSound[4] = "RifleMagInSound";
stateSound[4] = "RifleCockSound";


Only the last stateSound is played. I would like to know if there is a way to concatenate them together. I would like to avoid editing the audio to merge the 3 sounds together into one file.

Thanks for any help.

#1
06/16/2002 (8:24 am)
Well, there are 2 problems with the code you posted / the intention you have...
first, you are using the different state sounds of the rifle - they are played according to the state the rifle is actually in (no ammo, reload, fire, ...)

Then, there is an error with your array, you are simply overwriting the state sound #4, so it's totally normal that only the last one is played...

What exactly do you want to play and when? I guess the rifle isn't a good example... or do you really want to play e.g. 3 different sounds for one shot, reload, ...?
#2
06/16/2002 (8:34 am)
I see what you're saying about the first part. I had a suspicion that it was an array that's being loaded.

What I'm trying to do is quite simple:

I want to generate the sound of a magazine being taken out, then a new magazine being placed in to the weapon, and then the weapon is charged with the first round (or cocked).

I'm just playing around right now in an effort to understand how the state system functions. I'll fine tune it once I understand it. I see no other states where these sounds can be played. The only other modification that I would do is when the very first magazine is picked up and inserted into the rifle but this assumes that the rifle starts out empty when picked up for the first time. I'm not sure if I'll use that.

I hope that explains thing more clearly.

Thanks.
#3
06/16/2002 (8:35 am)
I think the gist of the question/problem is

Quote:Is there a way to play multiple sound files in a single state one after the other?
#4
06/16/2002 (8:48 am)
Well, then the simple answer is: YES ...
IF you modify shapeImage.cc to allow multiple sounds for one state...
or, much easier, change the sound for the state... ;-)
#5
06/16/2002 (9:08 am)
Thanks for the reply.

I was hopping to avoid any source code shenanigans this early in the game (no pun intended).

And by "..changing the sound for the state..." do you mean creating one audio file from multiple ones through editing?
#6
06/16/2002 (9:17 am)
Yes, that would be the easiest way (and the only one without engine changes, I think): make one sound file containing all the sounds you desire for that state...
Well, in the case of reloading, you could probably hack something in the scripts, e.g. set a dummy sound file for the state array (or leave it empty?) and then manually play the "real" sounds (with alxPlay()) in RifleImage::onReload() e.g., but that's not a really clean solution... anyhow, you could try something like that if you want ...