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. The 13th Music Contest Poll is up! Vote for the best tracks in this symphony of frost and flame.
    Dismiss Notice
  7. Race against the odds and Reforge, Don't Refund. The 14th Techtree Contest has begun!
    Dismiss Notice
  8. 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. Magtheridon96

    Magtheridon96

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

    edit
    Updated.
     
  2. Luorax

    Luorax

    Joined:
    Aug 7, 2009
    Messages:
    1,301
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Ah, "NewSound"... I had to change like 50 function calls in 50-100 triggers... meh.

    EDIT: did you even test it? Because there're no sounds at all. No spells do work with this that worked perfectly before, and it likes causing super lags on my tri-core 3200 Ghz, 4 Gbyte DDR3 RAM PC (not that good, I know, I'm not trying to brag with it; I'm trying to tell that it's not supposed to freeze down because of a couple of sounds)

    Also, Table should be on the requirement list.

    EDIT2: okay, switching Advent 3.0 back to 2.0 removed all the lags (both was implemented together). But my spells still DO lack sounds (most likely because SoundTools has nothing to do with Advent)
     
    Last edited: Nov 25, 2011
  3. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    It worked flawlessly while I was testing it with my Streak System :eek:
    I'll re-test this thing and see what's the problem.
     
  4. Luorax

    Luorax

    Joined:
    Aug 7, 2009
    Messages:
    1,301
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Oh well, I figured out what's wrong, you'll find it strange, just like me.

    The in-game sounds did appear, I was just trying a "bad" hero, its sound effects are not that loud and got overlayed by other sounds. But the hero selection sound is a different story.

    SoundUtils had an interesting bug: after initializing the click sound I had to play it, like I had to preload it, or it was randomly not played. It looked like this:

    Code (vJASS):
    private function init takes nothing returns nothing
        set ClickSound=NewSound("Sound\\Interface\\MouseClick1.wav",239,false,false)
        call RunSoundForPlayer(ClickSound,Player(12))


    If I don't play it immediately after initializing it, it works perfectly. Interesting.

    Whatever, it's working, don't waste any more of your time on it. I'll stick to this from now, and gj ;)
     
  5. Magtheridon96

    Magtheridon96

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

    I thought it was some sort of error with my stack :p
    Good to know there's nothing wrong ^_^
     
  6. Luorax

    Luorax

    Joined:
    Aug 7, 2009
    Messages:
    1,301
    Resources:
    1
    Maps:
    1
    Resources:
    1
    For first I thought the same, but then that little glitch with SoundUtils came to my mind. And I was right about that (however I have to rewrite my hero selection system, because it's an ancient, function orientated slow bs)

    (EDIT: Firefox 9.0 lolwut?)
     
  7. Bribe

    Bribe

    Joined:
    Sep 26, 2009
    Messages:
    8,125
    Resources:
    25
    Maps:
    3
    Spells:
    10
    Tutorials:
    3
    JASS:
    9
    Resources:
    25
    Fun code which I look forward to using some time soon. Thanks for making this. Approved.
     
  8. kStiyl

    kStiyl

    Joined:
    Oct 23, 2011
    Messages:
    180
    Resources:
    1
    JASS:
    1
    Resources:
    1
    does the sound have to be initialized for runPlayer? this keeps bugging for some reason

    *EDIT

    improved API with demo map would be nice as well.
    How am I supposed to use release? I thought i was supposed to use it like .snd.release().. what am I supposed to recycle?

    Sound.release(this.snd.runPoint(0, 0, 0))...?
     
    Last edited: Jan 21, 2012
  9. Mr_Bean

    Mr_Bean

    Joined:
    Feb 11, 2011
    Messages:
    1,823
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    When I try saving the map after installing the system, it gives the following error:

    "sound is not a member of Table__GTable"

    The line that has this error is:

    "
    return stack[this].sound[count[this]]
    "

    I do have the TimerUtils and Table libraries. What's wrong?
     
  10. watermelon_1234

    watermelon_1234

    Joined:
    Nov 18, 2007
    Messages:
    1,066
    Resources:
    10
    Spells:
    9
    JASS:
    1
    Resources:
    10
  11. Mr_Bean

    Mr_Bean

    Joined:
    Feb 11, 2011
    Messages:
    1,823
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    Oh, my bad. I was using ... Old Table ... I guess. Thanks!
     
  12. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Now that I think about it, there's absolutely nothing you're going to want to do with the sounds you run :eek:
    I'm going to remove the function release sound and just make it run automatically.
     
  13. Luorax

    Luorax

    Joined:
    Aug 7, 2009
    Messages:
    1,301
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Hmm, maybe you do want to stop looping sounds? For example, ReleaseSound DOES have use for me.
     
  14. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Well, I guess you have a point ;p
    I'm going to have to update one of my systems to call ReleaseSound now :p
     
  15. o2bryan

    o2bryan

    Joined:
    Mar 9, 2009
    Messages:
    173
    Resources:
    0
    Resources:
    0
    how to use this ?
     
  16. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Usually, I'd expect the user to know how to use it given the API :/
    But, just for you, here:
    Trigger
    • Init
      • Events
        • Map Initialization
      • Conditions
      • Actions
        • ---------- The file path of your sound. If it's imported, use the one given in the Import Editor ("war3imported/...") ----------
        • Set SoundPath = ""
        • ---------- The duration of the sound in MILLISECONDS. Meaning, you should take the duration of the sound in seconds and multiply it by 1000. ----------
        • Set SoundDuration = 0
        • ---------- Is the sound a looping sound? Note: Looping sounds have to stopped manually ----------
        • Set SoundLooping = False
        • ---------- Is the sound going to be played in 3D? ----------
        • Set Sound3D = False
        • ---------- Now, we get down to business and create our sound ----------
        • Custom script: set udg_MySound = NewSound(udg_SoundPath, udg_SoundDuration, udg_SoundLooping, udg_Sound3D)

    SoundPath is a string variable
    SoundDuration is an integer variable
    SoundLooping is a boolean variable
    Sound3D is a boolean variable
    MySound is an integer variable

    NO sound variables are needed ever ;)
    EXCEPT when you have a looping sound.

    If the sound is looping, you need to store the sound variable whenever you run it and release the sound variable when you want it to stop looping.

    To Play the sound:
    Trigger
    • Play
      • Events
      • Conditions
      • Actions
        • Custom script: call RunSound(udg_MySound)


    It's that simple :)

    To run the sound for a player:
    Trigger
    • Play for Player
      • Events
      • Conditions
      • Actions
        • Set udg_MyPlayer = (Player 1)
        • Custom script: call RunSoundForPlayer(udg_MySound, udg_MyPlayer)


    To play it on a unit:
    Trigger
    • Play on unit
      • Events
      • Conditions
      • Actions
        • Set udg_MyUnit = (Triggering unit)
        • Custom script: call RunSoundOnUnit(udg_MySound, udg_MyUnit)


    To play the sound at a point or location:
    Trigger
    • Play at location
      • Events
      • Conditions
      • Actions
        • Set MyLoc = (Position of (Triggering unit))
        • Custom script: call RunSoundAtPoint(udg_MySound, GetLocationX(udg_MyLoc), GetLocationY(udg_MyLoc), GetLocationZ(udg_MyLoc))
        • Custom script: call RemoveLocation(udg_MyLoc)


    If the sound is a looping sound, just replace the "call" before the RunSoundxxxx functions, with a "set udg_THE_NAME_OF_YOUR_SOUND_VARIABLE_HERE = " (Excluding the quotation marks of course)

    And when you want to stop the looping sound:
    Trigger
    • Custom script: call ReleaseSound(udg_THE_NAME_OF_YOUR_SOUND_VARIABLE_HERE)


    It's that easy ;)
    I hope this helps.

    edit
    Hey, if you're a GUIer, you shouldn't be using this, you could simply use the Sound Editor and GUI actions to play sounds >:O
     
  17. o2bryan

    o2bryan

    Joined:
    Mar 9, 2009
    Messages:
    173
    Resources:
    0
    Resources:
    0
    hey , can I put - A unit is attacked then play the multiple of sound effect on the attacking unit ??


    Edited*

    The first trigger "Init" is require right ?
     
  18. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Yes you can:

    Trigger
    • Trigger
      • Events
        • Unit - A unit is attacked
      • Conditions
      • Actions
        • Set Unit = (Attacking unit)
        • Custom script: call RunSoundOnUnit(udg_MySound1, udg_Unit)
        • Custom script: call RunSoundOnUnit(udg_MySound2, udg_Unit)


    And the init trigger is required because it actually creates the sound.
    Without it, the sounds wouldn't play :c
     
  19. o2bryan

    o2bryan

    Joined:
    Mar 9, 2009
    Messages:
    173
    Resources:
    0
    Resources:
    0
    Mysound is it my sound effect file name ??
     
  20. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    MySound is an integer.
    Using this system, all you need to do is delcare integers and set them to NewSound( etc.. ) to create them, then call RunSound(udg_MySound) to play them