Game Development Community

AudioProfile Network trouble

by Jeff Trier · in Torque Game Engine · 07/09/2006 (8:01 pm) · 13 replies

Hi all,

I am having some trouble with my 'audioprofile' not being found on a client.

In my networked game I have a time system (Thanks Bil Simser!) that is modified to sound off a 'ding' on all of the clients for every new game hour. It only makes the sound for the hosting player, and on the clients player I get the message Unable to locate audio profile 'timeHourAudio'.

Here is what I have:

Begins when TimeManager::update is called from the server.

(in file: ~/server/scripts/time.cs)
function updateAllClientTime(%gameTimeStr){
	%count = ClientGroup.getCount();
	for (%i=0;%i < %count;%i++){
		%client = ClientGroup.getObject(%i);
		commandToClient(%client,'updateTimeInfo',%gameTimeStr);
	}	
}

function serverCmdDoTime(%client)
{
... Removed for brevity
   // Update info to all clients
   updateAllClientTime(%gameTimeStr);
}

function TimeManager::update(%this)
{

... Removed for brevity

   // update time for clients every game hour
   commandToServer('DoTime');
}

(in file: ~/client/scripts/client.cs)
function clientCmdUpdateTimeInfo(%str){
	timeInfo.setText(%str);
	// later set to play chime 'x' * %hour_of_day
	alxPlay(timeHourAudio);
}

(in file: ~/server/scripts/audioProfiles.cs)
new AudioProfile(timeHourAudio){
	filename = "~/data/sound/guis/BoxPlain.wav";
	description = "Audio2d";
};

I should also mention that I have tried moving the above audio profile to various locations and I get the same result... Client/Server sounds off the audio... other client doesn't.

Thanks guys and gals!

-Jeff

About the author

Originally a Classical/Metal musician, I've always been attracted to anything involving computers, including: Networking, PC Building and Repair, software design and coding. I've been involved with game design and development for over 10 years.


#1
07/09/2006 (9:30 pm)
This is a relatively simple fix. You are creating a client-side AudioProfile (via "new") on the system running the server but not on any clients that are being run.

What you want to do is replace your "new" with a "datablock" tag to ensure it's a networked datablock object. For example:

datablock AudioProfile(timeHourAudio)
{
    filename = "~/data/sound/guis/BoxPlain.wav";
    description = "Audio2D";
};
#2
07/10/2006 (7:47 am)
Thanks, I'll give that a shot!

So when would you want to use 'new' instead of 'datablock' for audio profiles?

Thanks again!

-Jeff
#3
07/10/2006 (7:57 am)
Hi Jeff,

Datablocks can be transfered over the network while new scriptObjects cannot.
#4
07/10/2006 (9:56 am)
Ahh! Thanks... What through me off was looking at some of the audio profiles on the example (in fact mine is just a copy/paste with only the audio profiles name and file path modified). It didn't occure to me that some sounds you wouldn't want to hear on a client... that seems odd.

But, thanks a lot for the explanation guys, it makes more sense now. :)

-Jeff
#5
07/10/2006 (4:34 pm)
Hmm... changing 'new' to 'datablock' has the same effect. I even deleted all of the old dso's.

Gah! lol


-Jeff
#6
07/11/2006 (6:02 am)
Try move your audioprofile to client/audioprofiles.cs.
This is close to what i do with my chatsound and it works .
Dont forget to put new before the audioprofile if you place it there !
#7
07/11/2006 (6:48 am)
Basically:

All the sounds that are client only should be 'new'.
[client/scripts/audioProfiles.cs]
Examples: Gui Sounds, music.

Sounds that happen ingame and which the server will trigger for the client, should be 'datablock'.
[server/scripts/audioProfiles.cs]
Examples: Explosions, weapon sounds, player sounds.
#8
07/11/2006 (6:55 am)
Thanks for the idea Billy, but that's one of the first things I tried (actually the profile was in... client/scripts/audioprofiles.cs with the other stock profiles as well as being set to new). But just for kicks I tried it again which resulted in no audio for that effect at all... client or client/server.

This is really baffeling me, but I feel if I can get this to work it would really get me going in the world of networking.

I was wondering if someone can post a very simple code example of one client pressing a key and having a sound go off on all clients. I think this would get my head around this. From what I read in TDN and the forum, I should be doing everything right (to the best of my understanding).

Thanks for your time guys!

-Jeff
#9
07/11/2006 (8:26 am)
@Stefan:

Thanks! So it seems that my sound is caught somewhere in the middle. The server tells the client that a new hour has occured so the client knows to make a ding sound when it's GUI gets updated with that info (i.e. The GUI's clock updates it's time).

If I am understanding this correctly, my initial thought was right in assuming that the sound should be client side. I must have jacked the code somehow... does anyone see a problem with the code posted above? Let me know if you need more of it for contextual purposes. I really want to know what I am doing wrong.

Again... thanks for your time in all of this!

-Jeff
#10
07/11/2006 (8:46 am)
Hi Jeff,

That would be a 'new', then. The server tells the client (via TCP or commandToClient) that it (see, the client) needs to play a sound. This is slightly confusing I know, as one would think that the server *told* the client to play the sound, which kinda is not the case. The server tells the client to run a function, and then the client reacts.. you with me?

I'm sorry I can't explain much better, I'm not a native english speaker (or writer, either :p)

- Taking a look at your code though, the one thing I can spot is that you're using Audio2D which is not a client side description, it's serverside. You'd have to use AudioGui or AudioMessage.

Audio2D or Audio3D would be correct for a DATABLOCK sound, where the server transmits the sound to the client.

I hope this helps you :)

Edit: I love my grammar.
#11
07/11/2006 (1:28 pm)
Hey, I bet using Audio2D is my problem then!

I understood your explanation perfectly, thanks. :) Btw... your English is good enough for me to think it was your first language... no accent or nothing! lol

I'll give the fix a whirl when I get home. Thanks again.

-Jeff
#12
07/11/2006 (4:20 pm)
That was it Stefan! Thanks :)
#13
07/11/2006 (6:50 pm)
Quote:You'd have to use AudioGui or AudioMessage
To add to this you could made another one like new AudioDescription(AudioTimeMessage)
and used that.
What they are called in names doesn't matter's the important thing is that they exist on right places and are declared right.