• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Is there a way to play more than 3 same sounds at once?

Status
Not open for further replies.

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
I wonder, is there a way to play a same sound at more than 3 different location and the sound played correctly?

as example I have a sound variable named S and 10 locations named loc1,...,loc10. I want to play that sound at those locations at the same time, but seems like only one sounds played.. or another case, I played a same sound with 3 seconds duration at one location every 0.05 seconds. The sounds can't be played rapidly. :(

so the question is, is there a way to solve this?

answer
JASS:
function PlaySoundAtPoint takes string f, real x, real y returns nothing
    local sound s = CreateSound( f, false, true, true, 10, 10, "" )
    call SetSoundDuration( s, GetSoundFileDuration(f) )
    call SetSoundChannel( s, 0 )
    call SetSoundVolume( s, 127 )
    call SetSoundPitch( s, 1.0 )
    call SetSoundPosition(s, x, y, 0)
    call StartSound(s)
    call KillSoundWhenDone(s)
    set s = null
endfunction
 
Last edited:
Level 3
Joined
Feb 9, 2014
Messages
45
I wonder, is there a way to play a same sound at more than 3 different location and the sound played correctly?

as example I have a sound variable named S and 10 locations named loc1,...,loc10. I want to play that sound at those locations at the same time, but seems like only one sounds played.. or another case, I played a same sound with 3 seconds duration at one location every 0.05 seconds. The sounds can't be played rapidly. :(

so the question is, is there a way to solve this?

you want a sound plays when unit enter that location?
try this..:
  • Location
    • Events
      • Unit - A unit enters Location 1 <gen>
      • Unit - A unit enters Location 2 <gen>
      • Unit - A unit enters Location 3 <gen>
    • Conditions
    • Actions
      • Sound - Play H02DwarfHunter17 <gen>
 

Kazeon

Hosted Project: EC
Level 33
Joined
Oct 12, 2011
Messages
3,449
it's not really imposible, but to do that we need to replace one original sound with our imported sound, then we create a no taget spell with that replaced sound on cast.. to increase the volume we can increase the dummy unit fly height, we can play about 4 sounds rapidly using this way.. but what I'm looking for is the way without replacing original sound, which maybe you are right, it's imposible :(
 
Level 20
Joined
Jul 6, 2009
Messages
1,885
Just create a sound array and assign it as many sounds as you want (use the same soundfile).
Have a counter that tracks which sound in the array to play and increase it every time you play a sound. When you reach last sound, reset counter to 0.
It's impossible without a little mr hacky game. /Half Sarcasm
Sounds in Warcraft is restricted to 1 sound at a time, you can play up to 12 different sound for 12 different player (using Local Player), but it's impossible to play more than 1 sound for a player. It's because of WC III machine limits.
Yeah...no.
 
Level 7
Joined
Mar 6, 2006
Messages
282
No, you just need to create a different instance of the sound for each time you play it. I believe the limit is 4 simultaneous plays per 1 instance of a sound, and you can only play another if 1 instance ends.

You can use this function to play as many sounds as you want at the same time, because you're creating them on the fly:

JASS:
function PlaySoundAtPoint takes string f, real x, real y returns nothing
    local sound s = CreateSound( f, false, true, true, 10, 10, "" )
    call SetSoundDuration( s, GetSoundFileDuration(f) )
    call SetSoundChannel( s, 0 )
    call SetSoundVolume( s, 127 )
    call SetSoundPitch( s, 1.0 )
    call SetSoundPosition(s, x, y, 0)
    call StartSound(s)
    call KillSoundWhenDone(s)
    set s = null
endfunction

Call it with this:

call PlaySoundAtPoint("Units\\Human\\Peasant\\PeasantReady1.wav", targetx, targety )

Remember to use double backslashes in the filename.
 
Level 7
Joined
Mar 6, 2006
Messages
282
Um, I'm almost positive, because that's what I've been told but I've never actually tested it. I'm finding it hard to test, but I swear I'm NOT counting more than 4 simultaneous sounds. I'm playing a long "pissed" wav with a small wait in between each play, so I can hear when each one starts, but it doesn't sound like there's more than 4 at once. Someone else may post on the matter in a bit.

Also, I'm not sure what SoundTools or SoundUtils does but they're usually suggested for what you're trying to do. I just wanted to show you how it was done, but I may be doing something wrong.
 
Level 19
Joined
Mar 18, 2012
Messages
1,716
Also, I'm not sure what SoundTools or SoundUtils does but they're usually suggested for what you're trying to do
Like for instance TimerUtils for timers or Dummy for dummy units, SoundTools (awesome) and SoundUtils (nearly as awesome) recycle sounds to minimze the need of the CreateSound native.

Basically the sound is taken from a stack and pushed back into it, once it is finished.
 
There are certain limitations to sounds in WC3:

1) You can only play the same sound handle once (I needs to be stopped or finish in order to play it again)
2) You can only play the same sound file path (when using the same file path with multiple sound handles) once within a certain interval (around 0.1 seconds)
3) You can play only up to 4 different sound handles with the same sound filepath at the same time - note that 2) still applies so you need to delay them by 0.1 seconds each.
4) You can only play up to 16 sounds, no matter the handle or filepath in general
 
Status
Not open for further replies.
Top