Play sound consecutively

Status
Not open for further replies.
Level 3
Joined
Aug 24, 2014
Messages
22
I have a trigger that plays a sound whenever an ability is used. But if 2 units use the ability at the same time the sound will only play once. How can I fix this? Thanks
 
Level 14
Joined
Aug 30, 2004
Messages
909
This is an annoying limit to the world editor. I came across it when making Battle for Tatooine. I know it's daunting, but I recommend this tutorial:

http://www.hiveworkshop.com/forums/3d-modeling-tutorials-282/adding-sounds-attachments-30738/

Just attach the sound to the special effect of the ability being used and it will play every time. Modeling is extremely difficult, but adding attachment points and sounds is pretty easy. I resisted it for a long time, but once I decided to spend 45 minutes learning how to do it I found it really useful. This skill will come up a lot if you're making custom abilities.

Be sure to +rep the tutorial maker if you use it!
 
Level 14
Joined
Aug 30, 2004
Messages
909
Why would you dick around with the model file when you can just fix your trigger?

It's not just a problem with the trigger, it's a limit on the editor. You cannot play the same sound at the same time. So if you have a custom sound on a laser for example, and play the sound with a trigger every time someone shoots a laser, you can only have 1 laser on your map at a time. Whereas, if you attach the laser to the .mdx file, it will play appropriately every time anyone shoots it as many times as necessary.
 
I did extensive testing on sounds back when I wrote my tab interpreter system.

Basicly, here are all the hardcoded limits to the WC3 engine when it comes to sounds:

- you can only play up to 16 sounds at the same time
- you can only play up to 4 sounds of the same filepath (but at different sound handles) at the same time
- you can only play 1 sound per sound handle at the same time (obviously)
- even if a sound filepath is on different sound handles, they must have a delay of at least 0.1 seconds inbetween them to play

So basicly this boils down to:
- create 4 sound handles for each filepath as a small array
- loop through the array when you want to play the sound, until you find one that returns true for the following condition:
if GetSoundIsPlaying(snd) == false and GetSoundIsLoading(snd) == false then
- then play this sound

Having more than 4 sound handles of the same filepath is pointless.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
In SC2 you could configure all this in the data editor sound catalog. Oh well...

In WC3 With triggers using 3D sounds you can make the sound behaviour better by only playing it if the point is visible for the appropriate player. This means that any sound effects not visible will not eat up limited sound slots or be heard through fog of war. You could further clip based on current screen target point but that would need extra synchronization so is not recommended unless you already use those values.
 
In SC2 you could configure all this in the data editor sound catalog. Oh well...

In WC3 With triggers using 3D sounds you can make the sound behaviour better by only playing it if the point is visible for the appropriate player. This means that any sound effects not visible will not eat up limited sound slots or be heard through fog of war. You could further clip based on current screen target point but that would need extra synchronization so is not recommended unless you already use those values.

This thread is about playing simultaneous sound instances, not about optimizing sound handle usage.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,285
This thread isn't about that.
Yes it is?
But if 2 units use the ability at the same time the sound will only play once. How can I fix this?
Sound playback parallelization is clearly what he was asking about. Optimizing sound playback occurrence can allow the sound to appear more parallel capable.
Basically the fewer pointless instances of a sound playing the more meaningful instances of the sound playing you can get.
People only care about meaningful sound playback (I see it so I should hear it) and ultimately not what the technical limitations of the game are. Optimizing within those technical limitations can give the appearance that the game can do more than it actually can.
 
Status
Not open for further replies.
Top