1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. We have recently started the 16th edition of the Mini Mapping Contest. The theme is mini RPG. Do check it out and have fun.
    Dismiss Notice
  4. Choose your ride to damnation in the 5th Special Effect Contest Poll.
    Dismiss Notice
  5. The winners of the 13th Techtree Contest have been announced!
    Dismiss Notice
  6. Vote for the best entries in the 13th Music Contest Poll.
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[System] SoundTools

Discussion in 'JASS Resources' started by Magtheridon96, Nov 19, 2011.

  1. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,804
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Looks better. Not that the static method would have been useless, but assuming someone uses SoundUtils, I think there is no real reason why someone would still want to use wc3 sound handles.
     
  2. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Fixed a bug with setSoundPitch method :v
     
  3. ScorpioT1000

    ScorpioT1000

    Joined:
    Jun 26, 2013
    Messages:
    34
    Resources:
    0
    Resources:
    0
    Where is a wrapper for the most useful thing for sounds

    // the following method must be called immediately after calling "StartSound"
    native SetSoundPlayPosition takes sound soundHandle, integer millisecs returns nothing

    With this native and pitch you can synthesize sustained oscillations with custom frequencies! The audio lib in wc3 can do powerful things :)
     
  4. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Sounds awesome, maybe a library could be made for that using this resource to do all the dirty work (managing the handles and shit)
     
  5. ScorpioT1000

    ScorpioT1000

    Joined:
    Jun 26, 2013
    Messages:
    34
    Resources:
    0
    Resources:
    0
    I mean, split the wave into extra-small equal pieces and do the pitch, other words, make granulizer. The feature is to change tone without changing duration of any sound.

    To slow down we also should make interpolation, it's better to make besier and I have a code how to do that if somebody want ...

    Check this out http://www.youtube.com/watch?v=RIicn7ncQCw
     
  6. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
  7. ScorpioT1000

    ScorpioT1000

    Joined:
    Jun 26, 2013
    Messages:
    34
    Resources:
    0
    Resources:
    0
    Synthesizer by itself is not so useful.. but for the game (ex. generate tones depending on the car tachometer) would be really awesome. Because simple pitch changing sucks...
     
  8. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,709
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    call ReleaseSound(MySound) --> Syntax error: Cannot convert integer to sound.

    function ReleaseSound takes sound s returns boolean
     
  9. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    ^ You have to input the sound itself instead of the struct instance. The method create will return the sound instance (integer), but you can get the actual sound object through any of the following methods:
    Code (vJASS):
    /*
    *           method run takes nothing returns sound
    *               - Plays the sound.
    *           method runUnit takes unit whichUnit returns sound
    *               - Plays the sound on a unit.
    *           method runPoint takes real x, real y, real z returns sound
    *               - Plays the sound at a point.
    *           method runPlayer takes player whichPlayer returns sound
    *               - Plays the sound for a player.
    *
    *           method runEx takes integer volume, integer pitch returns sound
    *               - Plays the sound. This function allows you to pass in extra arguments.
    *           method runUnitEx takes unit whichUnit, integer volume, integer pitch returns sound
    *               - Plays the sound on a unit. This function allows you to pass in extra arguments.
    *           method runPointEx takes real x, real y, real z, integer volume, integer pitch returns sound
    *               - Plays the sound at a point. This function allows you to pass in extra arguments.
    *           method runPlayerEx takes player whichPlayer, integer volume, integer pitch returns sound
    *               - Plays the sound for a player. This function allows you to pass in extra arguments.
    */

    Or the wrapper function equivalents.
     
  10. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,709
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    Thank you. Problem solved :)
     
  11. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    842
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Soundtool bug?

    Hi guys,

    i have a problem in my map "Forsaken Bastion's Fall". I use your Soundtools and it works great BUT i spend a lot of time to check why "RunSoundForPlayer" in a loop does not work. I stopped it and created a small testmap.

    Take a look and tell me why the loop don't play the sound for each player.
    Start map in "debug mode".

    Please help!

    Reg.
     

    Attached Files:

  12. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    It would be nice if you posted the code. I lost access to an editor half a year ago.
     
  13. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    842
    Resources:
    1
    Maps:
    1
    Resources:
    1
    1. Trigger:

    Code (Text):
    scope GameSounds initializer Init

        globals
            integer GLOBAL_SOUND_1 = 0
        endglobals

        private function Init takes nothing returns nothing
            set GLOBAL_SOUND_1 = NewSound("Sound\\Interface\\Hint.wav", 2006, false, false)
        endfunction
       
    endscope
    2. Trigger:

    Code (Text):
    scope Test1 initializer Init

        private function Actions takes nothing returns nothing
            call RunSoundForPlayer(GLOBAL_SOUND_1, Player(0))
        endfunction

        //===========================================================================
        private function Init takes nothing returns nothing
            local trigger t = CreateTrigger()
            call TriggerRegisterPlayerChatEvent( t, Player(0), "sound 1", true )
            call TriggerAddAction( t, function Actions )
        endfunction

    endscope
     
    3. Trigger:

    Code (Text):

    scope Test2 initializer Init

        private function Actions takes nothing returns nothing
            local integer i = 0
            loop
                exitwhen i > 10
                call RunSoundForPlayer(GLOBAL_SOUND_1, Player(i))
                set i = i + 1
            endloop
        endfunction

        //===========================================================================
        private function Init takes nothing returns nothing
            local trigger t = CreateTrigger()
            call TriggerRegisterPlayerChatEvent( t, Player(0), "sound 2", true )
            call TriggerAddAction( t, function Actions )
        endfunction

    endscope
     
    auf typing "sound 2" you see that:

    [​IMG]
     

    Attached Files:

  14. Cokemonkey11

    Cokemonkey11

    Wurst Reviewer

    Joined:
    May 9, 2006
    Messages:
    3,237
    Resources:
    18
    Tools:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    2
    JASS:
    7
    Resources:
    18
    This is my snippet for sound that I used in the past -

    Code (vJASS):


    library Sound requires Table
        private struct slop
            string snd
        endstruct
       
        struct Sound
            private static HandleTable preloadDB
           
            private static method preloadAfter takes nothing returns nothing
                local timer time=GetExpiredTimer()
                local slop s=preloadDB[time]
                local sound sd=CreateSound(s.snd,false,false,false,12700,12700,"")
                call SetSoundVolume(sd,1)
                call StartSound(sd)
                call KillSoundWhenDone(sd)
                call s.destroy()
                set sd=null
                call DestroyTimer(time)
                set time=null
            endmethod
           
            public static method preload takes string str returns nothing
                local timer time=CreateTimer()
                local slop s=slop.create()
                set s.snd=str
                set preloadDB[time]=s
                call TimerStart(time,.01,false,function thistype.preloadAfter)
                set time=null
            endmethod
           
            public static method play3D takes string str, real pitch, real x, real y, real z returns nothing
                local sound s = CreateSound(str,false,true,true,12700,12700,"")
                call SetSoundPosition(s,x,y,z)
                call SetSoundVolume(s,127)
                call SetSoundPitch(s,pitch)
                call StartSound(s)
                call KillSoundWhenDone(s)
                set s = null
            endmethod
           
            public static method playForPlayer takes string str, real pitch, player who returns nothing
                local sound s = CreateSound(str,false,false,false,12700,12700,"")
                if GetLocalPlayer()==who then
                    call SetSoundVolume(s,127)
                else
                    call SetSoundVolume(s,0)
                endif
                call SetSoundPitch(s,pitch)
                call StartSound(s)
                call KillSoundWhenDone(s)
                set s = null
            endmethod
           
            public static method play takes string str, real pitch, integer vol returns nothing
                local sound s = CreateSound(str,false,false,false,12700,12700,"")
                call SetSoundVolume(s,vol)
                call SetSoundPitch(s,pitch)
                call StartSound(s)
                call KillSoundWhenDone(s)
                set s = null
            endmethod
           
            private static method onInit takes nothing returns nothing
                set preloadDB=HandleTable.create()
            endmethod
        endstruct
    endlibrary
     


    All you have to do is preload the sound once. Why should I use your massive library?
     
  15. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Massive? It's mostly comments and wrappers.

    Also, why are you looping and playing the sound once for each player when you can play it for everyone? :v
     
  16. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    842
    Resources:
    1
    Maps:
    1
    Resources:
    1
    In my map i start tutorials for each player when a player picks a hero. To pick a hero he needs to run with his peon in a circle and after he do this a cinematic starts for this player and in this cinematic i play a sound for this player.

    And as you can imagin not all player select its hero to the same time. So if the second player select the hero 10s later the sound needs to play later and only for him. Every player see its own Cinematic with this played sound.

    You understand me?
     
  17. Cokemonkey11

    Cokemonkey11

    Wurst Reviewer

    Joined:
    May 9, 2006
    Messages:
    3,237
    Resources:
    18
    Tools:
    1
    Maps:
    5
    Spells:
    3
    Tutorials:
    2
    JASS:
    7
    Resources:
    18
    If you remove all the comments and inlineable wrappers it's still 236 lines. My snippet is 70, without TimerUtils.

    I'm not.
     
  18. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Yes, but is this problem occurring in a real situation in your map? :|

    Not you, I mean pred1980.
     
  19. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    842
    Resources:
    1
    Maps:
    1
    Resources:
    1
    yes.

    edit: I have a flag called "MAP_HOSTED_BY_BOT" and if this is true, i start the tutorial (cinematic) for all players to the same time and i think exaclty this is the point where the sound does not play (for nobody). This is exactly the same thing like in the test map.
    But i use the same tutorial fore the case if MAP_HOSTED_BY_BOT == false, where the tutorials starts if the player do someting ( like the pick hero i mentioned ).
     
    Last edited: Apr 15, 2014
  20. pred1980

    pred1980

    Joined:
    Mar 19, 2010
    Messages:
    842
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Any Suggestions how to handle this problem?