• 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.

[JASS] Another Sound Thread

Status
Not open for further replies.
Level 7
Joined
Mar 6, 2006
Messages
282
Before anyone just tells me to use SoundTools, let me explain something real quick.

People say you can't play a sound right after you create it. Like this:

JASS:
local sound s = CreateSound( "Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveCaster1.wav", false, true, true, 10, 10, "" )
call SetSoundDuration( s, GetSoundFileDuration("Abilities\\Spells\\Other\\CrushingWave\\CrushingWaveCaster1.wav") )
call SetSoundChannel( s, 0 )
call SetSoundVolume( s, 127 )
call SetSoundPitch( s, 1.0 )
call SetSoundPosition(s, GetUnitX(me), GetUnitY(me), 0)
call StartSound(s)
call KillSoundWhenDone(s)
set s = null

What I've found is, if you preload the sound just by playing it, then you CAN play sounds right after creating them, like the above code.

Notes on preloading:

- Set the sound volume to zero, so they can't hear it.
- Only works if the player's game-sound is enabled at the time of preloading
- If it's a 3D sound, then you need to FORCE the player to hear it by
playing it in an area that you KNOW that player is already looking at.
(that would be easy at the start of the game, where most preloading is done)


So here's the question:

What's the problem with this? I mean, I can't be the only person to do this, and there must be a reason that SoundTools was created, because whenever I search for sound threads, it's just people saying to use SoundTools.
 
I don't think there is anything wrong with preloading it like that. I noticed a similar solution when I was trying to make my system to simulate 3d sounds (I was doing some tests on the sound durations, and I would never hear it on the first, but all other plays worked).

But that is some neat info on it, thanks. :) SoundTools does it with a short timer iirc. But it also has other useful functions (e.g. the pitch, playing sounds for players, OOP-like syntax), which makes it nice to use.
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
The sound will not be destroyed if it is never played (KillSoundWhenDone), for example if the sound is off on wc3 settings.

Now instead of this manual preloading i suppose it's just faster/easier to use SoundTools or whatever else.
 
Level 7
Joined
Mar 6, 2006
Messages
282
I don't think there is anything wrong with preloading it like that. I noticed a similar solution when I was trying to make my system to simulate 3d sounds (I was doing some tests on the sound durations, and I would never hear it on the first, but all other plays worked).

But that is some neat info on it, thanks. :) SoundTools does it with a short timer iirc. But it also has other useful functions (e.g. the pitch, playing sounds for players, OOP-like syntax), which makes it nice to use.

Yeah, I had the same problem, which made me think of doing that first play, when no one could hear it, so the rest of them would work.

The sound will not be destroyed if it is never played (KillSoundWhenDone), for example if the sound is off on wc3 settings.

Wtf, so if you play with your WC3 sound off, sounds will always leak on maps that don't use SoundTools?!

Are you sure about this? The wording of the native does suggest it ( "when done", so if it never plays, it never gets destroyed), but damn, how could Blizz not give us DestroySound()..
 
Level 17
Joined
Apr 27, 2008
Messages
2,455
Quite sure yes, if i remember correctly, but you can test it.
Same for TriggerWaitForSound (no wait), for this one i even suspect that could cause a desync on a multiplayer game, since it's like a TriggerSleepAction after all.

And about jass destructors, we don't have ones for trigger events, trackables, ...
 
Are you sure about this? The wording of the native does suggest it ( "when done", so if it never plays, it never gets destroyed), but damn, how could Blizz not give us DestroySound()..

Well, it doesn't make a whole lot of sense to use sounds dynamically anyway. You should just create them once and use them throughout the game. That's why Blizzard makes the sound editor generate globals for sounds... you can just use those throughout the game.
 
Level 7
Joined
Mar 6, 2006
Messages
282
It makes sense because you can't replay an already playing sound. That's why the sound editor suck.

So create/destroy a sound should be fine if only we could destroy them properly.

That was the issue I had. I'm big on spell aesthetics and sounds are important to get that "aw yeah" feeling when you cast something cool. And these spells are of course, MUI, so someone might be devoid of said awesomeness.

Edit: Haha, I just saw that thing in your sig

- Never believe some warcraft "fact" without a proof, even from an "experienced" user, that's how myths & legends born.
 
The sound will not be destroyed if it is never played (KillSoundWhenDone), for example if the sound is off on wc3 settings.

Now instead of this manual preloading i suppose it's just faster/easier to use SoundTools or whatever else.

"You must spread reputation before giving it to Troll-Brain again"

Really? To who? No thanks.
 
Status
Not open for further replies.
Top