Play Multiple Sounds Really Fast

Frosthowl

TH.net Regular
Reaction score
15
Hi, I need it so that it plays the ancient protector attack sound multiple times really quickly as a 3d sound. The problem is, it is playing the sound every time the sound ends instead of "stacking" the sound effect. Can anyone help?
 

Zaraf

New Member
Reaction score
22
You can't stack the same sound. You need different sounds to be able to stack. So if you want the same sound effect to be stacked, then you need copies of that sound effect for however many would be playing at the same time.

For example:

If the length of the sound effect is 1 second, and you want it to play every 0.2 seconds, that means you need 5 sounds to be stacking at the same time

So you would need to import 4 copies of that sound and then play them each one after another, and then you can repeat with the original (after it would stop playing).

Although in this case, you might only need 4 total since by the time the 5th one would start, the first one would be ending....but that is something you could test.

One thing I need to check myself is if you can just create extra variables of the same sound, or if you actually need to have copies IMPORTED in...

EDIT: I just tested it out, and it turns out you DO NOT need to import additional copies, but only make copies of the sound as extra variables. That's good since it won't increase file size then :)
 

Lazy Knight

New Member
Reaction score
0
common.j provided some function to achieve this goal, then I write a custom function.
Now you can use the function at the bottom to achieve your goal (though this is 2D audio):

function JustAnotherPlaySound takes string soundName, real volumePercent, real pitch returns nothing
local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
call SetSoundVolumeBJ(soundHandle, volumePercent)
call SetSoundPitch(soundHandle, pitch)
// Set Volume or Pitch after StartSound is invalid for current playing sound.
call StartSound(soundHandle)
call KillSoundWhenDone(soundHandle)
set bj_lastPlayedSound = soundHandle
endfunction

Usage Eg:

call JustAnotherPlaySound( "Sound\\Ambient\\DoodadEffects\\RollingThunder1.wav", 100, 1 )
 
Last edited:
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top