• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Sound problems

Status
Not open for further replies.
Level 14
Joined
Apr 21, 2007
Messages
1,465
I'm not sure if this should go in the trigger section or here, but since it doesn't require complex triggering I suppose here is a better fit.

I have problems with sounds. I have a script that calls various sounds at a point. Note that these sounds aren't activated at the same time but almost always after the previous one has finished and then some.

Basically what I have is a set of triggers that go like this:
Play sound A (lasts 3 seconds)
wait and do other stuff for about 5 seconds
Play sound B (lasts 2 seconds)
wait and do other stuff for about 3 seconds
Play sound C (lasts 2 seconds)
wait and do other stuff for about 5 seconds
Play sound D

Problem is the sounds randomly don't play. Sometimes the first two play, sometimes only A and C but never do all the sounds play. I know for a fact that all of the sounds are played if there are only a few of them in the script and there's a large pause in between.

I also have a question about sound leaks. Should I destroy sounds and what would be the best method if I'm doing a cinematic?
 
If they are used as Sound - Play sound, you don't need to do anything else regarding their destruction.

I generally like to use this script in the map's header:
JASS:
function PreloadSoundPath takes string path returns nothing
    local sound snd = CreateSound(path, false, false, false, 10, 10, "")
    call SetSoundVolume(snd, 0)
    call StartSound(snd)
    call KillSoundWhenDone(snd)
    set snd = null
endfunction

How does it work: use an event of Time - Elapsed game-time is 0.00 seconds.
Then, let's say that your imported sound's path is war3mapImported\HelloThere.wav.
Use this:
  • Custom script: call PreloadSoundPath ("war3mapImported\\HelloThere.wav")
(watch out for the double slash)

When you want to play a sound, use
  • Custom script: local sound s = CreateSound ("war3mapImported\\HelloThere.wav", false, false, false, 10, 10, "")
  • Custom script: call StartSound (s)
  • Custom script: call KillSoundWhenDone (s)
  • Custom script: set s = null
This is recommended for cinematics, since you shouldn't care much about repetitive creation of sound variables (playable maps should really have a recycling system).

The good thing is that you can play (from my tests) 4 sounds of the same path at the same time, without colliding with each other (and ultimately play only once). Really useful if you want to go for example for a heartbeat sound effect, which has a low rate of playing, especially when from slow rate goes up to a higher one (tip: which shows anxiety, fear or someone getting tired).

Warning: The sound will be global (one reason why I recommend it for cinematics); you need to use SetSoundPosition to play them at a certain location, just like a 3d sound.

Finally, you can have a map script additionally generated in the map's header, which will be creating the sounds just like in that script, so that you don't have to use those actions over and over again; all you'll need is to use something like
  • Custom script: call PlayMySound ("war3mapImported\\SoundPath.wav")
and it will do the job for you. If you want to go for something like this, let me know, it's only a simple edit.
 
Status
Not open for further replies.
Top