Archived

This topic is now archived and is closed to further replies.

Seeking info on DirectAudio/Sound/Music

This topic is 5149 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Speaking on multiplayer gaming here, what makes a sound play? I mean, I can load a zone for instance and the zone itself may have some music (winds, random birds, etc) that can play individually of what the network says. But some noises like howling wind or players casting spells will be decided if the server says there is a storm brewing or player casting. Also, if another player walks up and casts a spell then a spell casting sound should be played. But, what kind of message do I send? Does the server send a packet stating what sound to play (packet says PLAY_SOUND_XXX)? Or does the server send a packet stating what is happening and the client code decides ("Ohh, I should play this sound now along with this casting animation and this spell effect")? Also, things like sound interruptions. Picture a person casting a powerful lightning spell that takes 10 seconds. He clicks the cast spell icon which generates a request to cast the spell. The server receives this, checks to make sure the char can actually cast the spell and then returns a PLAYER_CASTS_SPELL_X to everyone in the vicinity (including the original player). All clients would see this and say ("Ohh, I need to play spell_animation and spell_sound"). But what if the player is interrupted in mid cast? Since the server ultimately decides if the spell is interrupted then do I send a specific packet that says PLAYER_XXX_STOP_CAST? Or some other method? I realize this is more of a multiplayer issue, but the control of the sound would work the same in single player I think? Do I just find the sound in question and Stop() it right then? Or some sort of fade to quiet on the sound. Also, are sounds dependent on game frame rate? Or does DirectAudio control them so that they are played in real time regardless of frame rate? Finally, in regards to listeners. The SDK says that all sounds have to have a unique listener. Now, if the listener (the character) is always in the same position for all sounds, can I just use the same listener for every sound? Or does the listener really have to be unique? Getting really annoyed with books that just scratch the surface and show nothing more than how to Init() directX obejcts and don''t really show how to use them effectively in games TIA for any help, Webby

Share this post


Link to post
Share on other sites
I have DSound working in my game, but only at a very basic level (I play a "click" sound when an interface button is pushed), so I probably couldn''t tell you any more than what your books are telling you

If it were me, though, I''d have the clients decide when to play sounds based on input from the server. After all, you will have to tell your clients about actions made by other players anyway (i.e. player is casting a spell, therefore I''d have the server send this notification (PACKET_PLAYER_CASTING) out to all the clients as needed. Then I''d have the clients do the appropriate things based on that getting that packet (play avatar animation, play appropriate sound, generate particles, etc.)). I would think there would be no need to send these out as individual commands (PACKET_PLAY_ANIMATION, PACKET_PLAY_SOUND, PACKET_GENERATE_PARTICLES). You''re creating uneeded overhead, I would think

In fact, come to think of it, I already do something similar to this. My server tells players an avatar is moving, but not to perform the "runnning" animation on it, the clients do this on their own, based on the fact that they know the avatar is moving.

Share this post


Link to post
Share on other sites
You are probably correct there. at this point, I''m guessing that I would just send out a PLAYER_DID_X packet to all players within the vicinity and have each one of them react to it normally. Since the server determines if a spell is interrupted then I''ll just send out a PLAYER_SPELL_INTERRUPTED packet to all people as well. Then each client can determine what to do which would probably be something like blend from current casting animation into whatever occurred (got hit?) as well as fade out the spell to no sound and just let the sound finish playing silently until it is normally ended and removed. Tis as opposed to fading the sound out and then extra code to unload it prematurely. A simply volume adjustment seems the easier way to go.

Thanks for the input. I''m just looking for opinions.
Webby

Share this post


Link to post
Share on other sites
quote:
Original post by WebsiteWill
Since the server determines if a spell is interrupted then I''ll just send out a PLAYER_SPELL_INTERRUPTED packet to all people as well.

I actually have given this some thought for my game as well. I meant to mention it, but I forgot

I *think* (don''t quote me on this) that AC handles this by actually sending out 2 packets for each spell. One to initiate a spell and one to either a) complete the spell b) fail the spell, or c) stop the spell.

You send out your initiate packet, which allows the client to put the avatar into the proper spellcasting animation, play "build up" sounds, generate particles and so on. If the spell succeeds, you then send out that packet, allowing the clients to do the proper things to show the spell firing off. If it fails, you send out that packet, allowing the client to show the spell fizzling. If the spell is interrupted, you send out that packet, allowing the client to revert the to default animation.

That''s sort of what I was planning on doing, anyway. Haven''t quite gotten there yet. If you''re using UDP, you''d probably need to put these on your ordered AND reliable stack to make sure they get there properly.

quote:

Thanks for the input. I''m just looking for opinions.
Webby

Sure thing, hope your project is coming along well. I think you are slightly ahead of me in many respects, based on your posts, which is cool, I can ask you how you did things I''m still working on basic avatar animations and 3rd party avatar display, heh.

Share this post


Link to post
Share on other sites
I'm actually not far at all with code. What I have been doing is working out what I hope will be a solid, easy to manage design. I have written some small test apps for various things. I've got my networking core up and running quite nicely by itself. It hasn't been tested with any actual game code yet. It will get rewritten a time or two before it's usable

I'm working out a design that is as object pluggable friendly as possible. In the process I am learning a LOT about the various systems involved. As you can probably tell from my posts, I am currently gathering information that will be used later. So, as I am researching, if I find a good question that I can't solve using Google, my books or a trip to the bookstore then I post here. Usually I get definitive answers but sometimes (like this question) I am working with rather vague concepts which are generally hard to definitively answer.

I do appreciate all the help I get here and enjoy being a part of this community. Hope I don't become a bother by asking too many questions though I'm sure some moderator will hush me before that happens

I try to ask only questions I can't answer elsewhere though I have occassionally posted a question and find an answer to it almost immediately after posting. Then I reply to my own posts :D.

I also tend to get longwinded....Probably has something to do with the 10+ page papers I've had to write for school over the past 4.5 years. Graduation in December!!!!!! Then the real learning starts...

Webby

edited: can answer => can't answer

[edited by - websitewill on November 12, 2003 9:25:56 PM]

Share this post


Link to post
Share on other sites
quote:
Original post by WebsiteWill
I''m actually not far at all with code. What I have been doing is working out what I hope will be a solid, easy to manage design.

Ah, so you''re still in design phase. Wow, your questions are remarkably intellegent and to the point for not being in coding phase yet. My design work had very little to do with actual implementation details and was all about how things played. I would never have guessed you aren''t actually coding the game at the moment, heh.

quote:

I have occassionally posted a question and find an answer to it almost immediately after posting. Then I reply to my own posts :D.

Yeah, don''t you hate that? I''ve done that several times myself. I can spend three hours researching, find nothing, ask, then find the answer 30 seconds later

quote:

I also tend to get longwinded

Me too, you should see our forums

quote:

Graduation in December!!!!!!


Grats!

Share this post


Link to post
Share on other sites