• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

Sounds Leak?

Status
Not open for further replies.
Level 13
Joined
Nov 22, 2006
Messages
1,260
I agree with TriggerHappy, I don't think you're supposed to destroy sounds in GUI. It won't leak because GUI uses a global sound which is reused. So that same sound is played over and over again each time you do "Play Sound". Get it?

That Destroy Sound action is a bit weird and I don't think you should use it.
 
Level 5
Joined
Jul 14, 2008
Messages
121
Using sound in GUI leak, you have to destroy it. And you can use it again after.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Well, the good thing about the "Destroy sound" action is that the sound is destroyed when it finishes playing. Maybe they do leak, I don't know much about sounds, but from a jasser persperctive it doesn't make any sense. Try searching the forum for threads about sounds.
 
Level 12
Joined
Aug 22, 2008
Messages
911
You have to destroy the sound using
  • Sound - Destroy Sound
otherwise it leaks, it states so clearly in the leaks tutorial. And btw Vulcano is wrong because you can use sounds after destroying them and it doesn't matter if it's jass or GUI, I know that because I use sounds when one of my units attack, and it works each time it attacks.
 
Level 13
Joined
Nov 22, 2006
Messages
1,260
Maybe they're created again once they're destroyed, I don't know, but it doesn't leak if you don't destroy them.

This post is too long because everybody is expressing their opinions, but we aren't really getting somewhere. Ask a moderator or something (or search the forum, I'm sure there's a thread like this one).
 
Can someone test this script, I don't have sound on my computer so I would imagine the sound natives don't work either.

JASS:
scope sounds initializer onInit
    
    globals
        private sound gg_snd_Doom = CreateSound( "Sound\\Music\\mp3Music\\Doom.mp3", false, false, false, 10, 10, "" )
    endglobals
    
    private function again takes nothing returns nothing
        if gg_snd_Doom != null then
            call BJDebugMsg("Sound still exists")
        else
            call BJDebugMsg("Sound was destroyed")
        endif
    endfunction
    
    private function onInit takes nothing returns nothing
        call SetSoundChannel( gg_snd_Doom, 0 )
        call SetSoundVolume( gg_snd_Doom, 127 )
        call SetSoundPitch( gg_snd_Doom, 1.0 )
        if gg_snd_Doom != null then
            call PlaySoundBJ( gg_snd_Doom )
            call KillSoundWhenDoneBJ( gg_snd_Doom )
        else
            call BJDebugMsg("The sound was never initiliazed")
        endif
        call TimerStart(CreateTimer(), 5, false, function again)
    endfunction
    
endscope
 
Level 5
Joined
Jul 14, 2008
Messages
121
GUI sound does leak, you have to destroy it, it's a fact. When you destroy a sound, it only destroy the currently playing sound. You can use it again without any problems.
 
Status
Not open for further replies.
Top