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

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    I'm trying to use this in my map, but it doesn't want to save.
    I get this error. And who knows there is another error after I fix this.
    Am I doing anything wrong? Or did I miss a requirement or someting?
     

    Attached Files:

  2. Luorax

    Luorax

    Joined:
    Aug 7, 2009
    Messages:
    1,301
    Resources:
    1
    Maps:
    1
    Resources:
    1
    You have to update your Table. What version are you using? It requires the latest one, made by Bribe, which isn't backwards compatible, nor is it with the old one, made by Vexorian.
     
  3. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    Hmm I had Table 3.0 in the map already. But that might be like 2 years old by now.

    Doesn't it fckup other things in the map if I update Table right now?
     
  4. Luorax

    Luorax

    Joined:
    Aug 7, 2009
    Messages:
    1,301
    Resources:
    1
    Maps:
    1
    Resources:
    1
    I presume that's Vexorian's Table - well, it won't screw up anything, though if you use it often like I do, it'll take you some time to update all of your resources. But at the end of the day it's worth it, as it's cleaner, and propably faster as well.

    If I recall correctly there's a backwards compatible module attached to its post though, so if you implement that as well you won't have to change anything.
     
  5. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    Alright, thanks alot. Gonna try that out.
     
  6. Sephalo

    Sephalo

    Joined:
    Oct 12, 2007
    Messages:
    1,791
    Resources:
    0
    Resources:
    0
    I'm using this system at the moment and learning how to work with it.
    I got a spell in my map that will let the hero do 5 melee swings within 1 second while he is paused with increased animation speed. So I want to put the sound inside the timer, and I would like it to play one out of three random combat sounds; medium axe chop flesh.
    I thought I had it already, but for some reason it doesn't play the sounds anymore if I use the skill a second time.

    This is what I've got in the init trigger of the spell: (Sound1, Sound2 and Sound3 are private global integers)
    Code (vJASS):

    set Sound1 = NewSound("Sound\\Units\\Combat\\MetalMediumChopFlesh1.wav", 522, false, true)
    set Sound2 = NewSound("Sound\\Units\\Combat\\MetalMediumChopFlesh2.wav", 720, false, true)
    set Sound3 = NewSound("Sound\\Units\\Combat\\MetalMediumChopFlesh3.wav", 723, false, true)


    This is what I've got inside the loop:
    Code (vJASS):

    if GetRandomInt(1,3) == 1 then
        call RunSoundOnUnit(Sound1, Dat.t)
    elseif GetRandomInt(1,2) == 1 then
        call RunSoundOnUnit(Sound2, Dat.t)
    else
        call RunSoundOnUnit(Sound3, Dat.t)
    endif
     
     
  7. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Okay, it seems that SoundTools fails to play the same sound instance twice.

    I don't know how this just came up.

    ._.

    edit
    Updated to v3.0.0.0:

    • Fixed sound playing bug.
    • Added extra debug message.
    • Changed system structure.
    • Removed functions that counted the number of currently playing sounds. (Completely useless)
     
    Last edited: Jul 29, 2012
  8. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,806
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Hmm... I don't know how you do it, but I had trouble with all the sound limitations when creating my TabReader aswell.

    Those were my observations and workarounds:

    Problem: WC3 doesn't allow to play the same sound filepath (regardless of handle) twice in less than 0,1 seconds (only different paths). This is hardcoded and can not be avoided.
    Fix: There is only one way to partially fix this: by taking the old sound and using SetSoundPosition to put it back to the beginning.

    Problem: WC3 doesn't allow simultanous running of the same sound handle.
    Fix: Simply create another soundhandle (up to 4 sound handles of the same filepath possible).

    Problem: WC3 doesn't allow simultanous running of the same filepath more than 4 times.
    Fix: Only possible solutions is importing the same sound again on a new filepath.

    Problem: WC3 doesn't allow simultanous running of more than 16 sounds altogether.
    Fix: None. I've tried everything.

    Problem: Pitch shifting is buggy as hell.
    Fix: Check out my pitch shifting function in the tab reader - it works 100% of the time, even if it looks weird.
     
  9. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Actually, that is a pretty good solution. This kind of behavior is present in a lot of applications.
    I'd be adding more overhead (an extra timer), so I guess I might make this optional :/

    Well, this problem is fixed here, as I'm using one sound handle recycler for each sound type. I didn't know there can only be 4 of them =O

    You know, these should be documented somewhere.
    At home, a few days ago, I started putting together some documents to contain all the Warcraft III knowledge that we have accumulated over the years.
    I guess I could add these =o
     
  10. Mr_Bean

    Mr_Bean

    Joined:
    Feb 11, 2011
    Messages:
    1,823
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    Hi. Just a question that should be obvious; when I use something like this:

    Code (vJASS):
    local Sound mySound = Sound.create(...)
    mySound.runPlayer(Player(0))


    Do I have to use
    mySound.release()
    or will it be cleaned up when it's finished playing?
     
  11. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    It will automatically recycle it after the sound duration if it is not a looping sound.
     
  12. Mr_Bean

    Mr_Bean

    Joined:
    Feb 11, 2011
    Messages:
    1,823
    Resources:
    6
    Maps:
    2
    Spells:
    4
    Resources:
    6
    Thanks, I suspected that may be the case.
     
  13. BPower

    BPower

    Joined:
    Mar 18, 2012
    Messages:
    1,709
    Resources:
    21
    Spells:
    15
    Tutorials:
    1
    JASS:
    5
    Resources:
    21
    Whne i'm trying to save Soundtools inside my map it says:"Undeclared function NewTimerEx"

    Its starts the recycle if not looping.

    I'm using Jnp 1.5e.
     
  14. Anachron

    Anachron

    Joined:
    Sep 9, 2007
    Messages:
    6,221
    Resources:
    66
    Icons:
    49
    Packs:
    2
    Tools:
    1
    Maps:
    3
    Spells:
    9
    Tutorials:
    1
    JASS:
    1
    Resources:
    66
    Well, you need TimerUtils for this to work:

    Code (vJASS):

    library SoundTools requires Table, TimerUtils
     
     
  15. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,806
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    You should replace all SetSoundPitch() natives in your system by this, as SetSoundPitch() is bugged when it is applied while the sound is running.
    Code (vJASS):

        function SetPitch takes sound s, real pitch, real lastPitch returns real
            //due to the bugged pitch native, we need this workaround snippet in order to make it work
            if GetSoundIsPlaying(s) or GetSoundIsLoading(s) then
                call SetSoundPitch(s, 1/lastPitch)
                call SetSoundPitch(s, pitch)
                return pitch
            else
                if pitch == 1 then
                    call SetSoundPitch(s, 1.0001)
                    return 1.0001
                else
                    call SetSoundPitch(s, pitch)
                    return pitch
                endif
            endif
        endfunction

    The real returned is the new pitch value of the sound. Store it to your specific sound instance to be able to pass it the next time this function runs.
     
  16. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Ah yes, thank you for reminding me about that bug.
    It was awesome that you were able to find all those bugs through your production of that Tab Reader ;D
     
  17. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,806
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Yeah it gave me a hell of a headache.

    And in the end, the poor sound engine of Warcraft III defeated the whole purpose of TabReader, as most of the mp3 compression is lost after importing a sound.
    (WC3 doesn't support all sampling rate+quality combinations. Only a few are supported. If you happen to import a sound that is inbetween one of the supported combinations, the quality is reduced to the lower one, usually resulting in unwanted audio fragments - which means all imported sounds need to be high quality)
     
  18. Magtheridon96

    Magtheridon96

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

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,806
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Hmm, I'm a little bit confused about your implementation, I gotta say.
    Why is the setSoundPitch method static? It should clearly be an instanced struct member as the method only makes sense for existing structs and when making it non-static, only the new pitch value needs to be passed.
     
  20. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    I see what you mean. Currently, it's static because I treated it like a utility function rather than something associated with any of the struct instances directly.

    edit
    How does this look? <: