Play Multiple Sounds Really Fast

Discussion in 'World Editor Help' started by Frosthowl, Jun 3, 2008.

  1. Frosthowl

    Frosthowl Member

    Ratings:
    +15 / 0 / -0
    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?
     
  2. Zaraf

    Zaraf New Member

    Ratings:
    +21 / 0 / -0
    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 :)
     
  3. Frosthowl

    Frosthowl Member

    Ratings:
    +15 / 0 / -0
    aight, thanks
     
  4. Lazy Knight

    Lazy Knight New Member

    Ratings:
    +0 / 0 / -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: Sep 23, 2017

Share This Page