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. Dismiss Notice
  5. The Highway to Hell has been laid open. Come along and participate in the 5th Special Effect Contest.
    Dismiss Notice
  6. 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. Adiktuz

    Adiktuz

    Joined:
    Oct 16, 2008
    Messages:
    9,674
    Resources:
    23
    Models:
    2
    Packs:
    1
    Maps:
    1
    Spells:
    16
    Tutorials:
    1
    JASS:
    2
    Resources:
    23
    cool... this would be useful when I get back time to mod...
     
  2. o2bryan

    o2bryan

    Joined:
    Mar 9, 2009
    Messages:
    173
    Resources:
    0
    Resources:
    0
    why the Custom script: set udg_MySound = NewSound(udg_SoundPath, udg_SoundDuration, udg_SoundLooping, udg_Sound3D) looks like have undeclared function ??
     
  3. Magtheridon96

    Magtheridon96

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

    o2bryan

    Joined:
    Mar 9, 2009
    Messages:
    173
    Resources:
    0
    Resources:
    0

    The name of my sound variable is from Sound Editor or Import Manager (war3mapImported\skill_explo_128.wav) ??

    Hey sorry i really not good in doing this >.<

    Can you give me a complete triggers >.< I not very understand whether how to do this .


    Edited * the NewSound is a variables?
     
    Last edited: Feb 12, 2012
  5. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    NewSound is a function, not a variable :X

    Listen, if you're using the Sound Editor, there's no point in using this resource :/

    This was made for handling sounds for people who use Jass because only these people are going to run into problems and inconveniences while managing sounds :/

    In GUI, it's really simple.

    You just have to import the sound, use it as a sound in the Sound Editor, and play it in the world editor.

    Simple as that.

    In Jass, you have to create a trigger in GUI and use the sound just for the World Editor to generate something like gg_snd_xxxxxxx

    Also, this provides a recycler for sounds so that you wont run into problems when wanting to play a sound twice at very close times (about 0.3 or 0.7 seconds apart for example)

    BUT, if you really wanna use this and be what I like to call a Linux-user, you would have to do this:

    Do this on map initialization:
    • Custom script: set udg_MY_INTEGER_VARIABLE = NewSound("war3mapImported\\skill_explo_128.wav", DURATION_OF_THE_SOUND_IN_MILLISECONDS, false, false)

    So for example, if your sound is 3.872 seconds, you would have to replace DURATION_OF_THE_SOUND_IN_MILLISECONDS with 3872.

    Do this to play the sound:
    • Custom script: call RunSound(udg_MY_INTEGER_VARIABLE)
     
  6. mysteriis

    mysteriis

    Joined:
    May 2, 2011
    Messages:
    39
    Resources:
    1
    Maps:
    1
    Resources:
    1
    thx for this
     
  7. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    No problem bro, coding is fun.
     
  8. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    I want to use this lib to create a music library:
    http://www.hiveworkshop.com/forums/triggers-scripts-269/


    However, in order to do so, can you please make volume, pitch settings and sound channel parameters of the sound struct?
    I need them to be configurable for each sound, not just all sounds together. Them being constants is weird, if you ask me.

    Also, can I use this lib to run the same sound twice at the same time? Let's say I want both sounds to overlap each other, will it work? if so, will the first sound stop or will it continue until the end of its duration when the second playing is fired?
     
  9. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    If you play 2 sounds of the same type at the same time, this system will smartly ignore the second play-order.
    If you play 2 sounds of the same type with a very tiny time difference, this system will play both of them, so they will overlap.

    I guess I could make some things changeable.
     
  10. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    That would be awesome. :)
     
  11. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Actually, I realized that my run function returns the sound played O-o
    You can do this:

    Code (vJASS):
    local sound s = MySoundObject.run()
    call SetSoundPitch(s, 0.8)
    call SetSoundVolume(s, 0.2)


    Those values in the struct aren't constants, just default values :p

    edit
    I have an idea, I can write a function called runEx() and give you the ability to pass in custom sound data so you don't have to waste performance with the sound function calls :D
     
  12. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Neat. :)

    Wow, haven't noticed that Run returns the sound played. That makes stuff a lot easier.
     
  13. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Updated. \o/
    You can now write an awesome Music System :D

    I also removed some unnecessary function calls.
    When a system is going to be used as the basis of another complex system, speed is crucial.
     
  14. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Thanks. Now I can just hope I won't get trouble with WC3 limitations in sound channels. :/
    I will look into it on weekend.
     
  15. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Updated again.
    Members are now readonly.
    Now it's possible to write a SoundPlayPosition tracker :p
     
  16. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Due to my findings of limitations in:
    https://www.hiveworkshop.com/posts/2141105/
    you might want to consider some changes to your system (for example the max instance limits of 16 and 4 and removing the sound channel parameter of your RunSoundEx().
     
  17. Magtheridon96

    Magtheridon96

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

    edit
    I updated this hours ago, but I forgot to say so, so:

    Updated.

    :p
     
    Last edited: Apr 28, 2012
  18. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Due to the limitation of 4-of-the-same and 16-all-together sound instances, can you possbly write a tracker that returns how many instances of the same sound are currently playing and how much are currently played all together?

    something like .getInstanceCount() or such.
     
  19. Magtheridon96

    Magtheridon96

    Joined:
    Dec 12, 2008
    Messages:
    6,006
    Resources:
    26
    Maps:
    1
    Spells:
    8
    Tutorials:
    7
    JASS:
    10
    Resources:
    26
    Of course, anything to get that Music system up and running :D

    edit
    Updated.
     
  20. Zwiebelchen

    Zwiebelchen

    Joined:
    Sep 17, 2009
    Messages:
    6,793
    Resources:
    12
    Models:
    5
    Maps:
    1
    Spells:
    1
    Tutorials:
    1
    JASS:
    4
    Resources:
    12
    Awesome stuff. Almost done btw. :)

    EDIT: Okay, one problem: I want to know how many instances of that sound are playing before I use NewSound (makes sense, doesn't it? ;D ). So it would be better if input parameter is the filepath string, not the actual Sound.