Game Development Community

How to solve this audio problem

by Rubes · in Torque Game Engine · 03/07/2007 (7:59 pm) · 8 replies

Looking for some help with setting up an audio system to do the following:

In my game, I have several NPCs who interact with the player via dialog. This dialog is recorded audio, so I need to have the ability to play any of several different recordings for each NPC at any time, depending on which question the player asks.

Since I would like the sound to be 3D, I was thinking I would create an AudioEmitter for each NPC and attach it to the NPC, if possible (since some of them move around while talking). Then I was thinking I would just create an AudioProfile for each recording that I have.

The main problem, as I see it, is that an AudioEmitter cannot be told to play a sound on command (ie, there is no "play" method), nor can it change the sound it plays on the fly unless it's valid to switch AudioProfiles.

I could just define AudioProfiles for each recording and alxPlay them as needed, but if I understand right these would be 2D sounds that are not attached to any NPC.

I've searched and searched on this with no luck. Am I missing something? Is there some relatively simple way to accomplish what I would like?

#1
03/07/2007 (9:12 pm)
There's a much simpler way:

serverPlay3D(yourSound, %NPC.getTransform());
#2
03/07/2007 (9:24 pm)
That's a good idea, although those sounds would not be attached to any object. So if an NPC is moving across a room, the sound would originate only from the NPC's starting position.

That would sound like the best solution at this point, but is there is any way to make a "moving 3D sound"?

Edit: Ah, hold the presses...I think this is what the %object.PlayAudio() function would be for...
#3
03/07/2007 (11:29 pm)
%player.playAudio(%slot, audioProfile);

That's the ticket!
#4
03/08/2007 (6:49 pm)
Well, it's the ticket but it's not doing what I'd like it to do.

It works well enough to play a sound at the location of a DTS object (like an NPC), but even though the sound is set up with an AudioProfile and an AudioDescription, it doesn't seem to play as a 3D sound. The same appears to be true for the serverPlay3D command.

The values that I use for the AudioDescription appear to only partially work; the values for ReferenceDistance and MaxDistance work, but none of the cone values seem to have any effect, and I can't seem to get any left/right direction to the sounds, either.

I know that directional and 3D sound works with TGE, since I can hear those effects when I use AFX or other demos. But those use different means to play sounds. Is there some type of setting I don't know about that would make this work?
#5
03/08/2007 (6:55 pm)
%player.playAudio(%slot, audioProfile);

I tested it and it worked just fine for me.

You do realize that a 3D sound has to be mono and not stereo?
#6
03/08/2007 (6:58 pm)
Yup, just figured that out!
#7
03/08/2007 (7:50 pm)
Glad to hear it!

That's always a trap for young players. It makes perfect sense when you think about it logically.

So you're all good now?
#8
03/08/2007 (8:23 pm)
It's all good. Thanks for the help...