HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

Sounds in JASS

07-01-2007, 09:21 AM#1
Silvenon
Hi,

I've seen that GUI Sound - Play Sound is PlaySoundBJ right? Which creates a sound and play it (and has to be destroyed afterwards). But what about StartSound()? Could I use StartSound(<some sound variable>), do I need to destroy it then? Does JASS have some better ways of playing a sound?
07-01-2007, 09:42 AM#2
Toadcop
sounds are never recycled or destroyed <_<
(it's a fact)
07-01-2007, 09:59 AM#3
Pyrogasm
gg_snd_MySound.wav is a global variable, if I remember correctly.
07-01-2007, 10:35 AM#4
Silvenon
Well could you give me more details?? I know gg_snd_MySound.wav is a global variable, PlaySoundBJ somehow creates a sound......whoops, it was PlaySound, then it's practically StartSound, just stores the sound in last created sound. But what's the DestroySound for then? (in GUI also)
07-01-2007, 11:06 AM#5
Toink
call KillSoundWhenDone(<arguments>) did you use that yet?
07-01-2007, 12:34 PM#6
The)TideHunter(
Well ok, lets look at the PlaySoundBJ function.

Collapse JASS:
function PlaySoundBJ takes sound soundHandle returns nothing
    set bj_lastPlayedSound = soundHandle
    if (soundHandle != null) then
        call StartSound(soundHandle)
    endif
endfunction

It obviously sets the last played sound to the soundHandle, if soundHandle isnt nothing then play it.
As Toadcop said, it is never destroyed. You play a sound which is already made (when you define custom sounds in the sound editor), and thats about it, it checks if its not empty and plays it.
07-06-2007, 09:01 PM#7
Silvenon
Ok, but if nothing is destroyed, what's KillSoundWhenDone for?
07-07-2007, 07:43 AM#8
Toadcop
Quote:
KillSoundWhenDone
just for fun ? ^^ well in trueth it's not simple don't doing anything =) it's also some kind obfuscate sounds possibilitys ! for example you can get the sound duration after etc.

// you can check if they are recycled by playing a sound avery 2 seconds. and the sound duration is ~1 second. and if they were recycable then the handle id would be the same. i have tested alot and avery time i get new handles =\
07-07-2007, 12:01 PM#9
Anitarf
Quote:
Originally Posted by Silvenon
Ok, but if nothing is destroyed, what's KillSoundWhenDone for?
It's for disposing of dynamicaly created sounds; not something you would do in GUI, though, you can only create sound objects on the fly with Jass, while GUI only uses sounds precreated in the sound manager.
07-08-2007, 02:49 PM#10
Silvenon
Tnx, so Destroy Sound in GUI is useless.