wc3campaigns
WC3C Homepage - www.wc3c.netUser Control Panel (Requires Log-In)Engage in discussions with other users and join contests in the WC3C forums!Read one of our many tutorials, ranging in difficulty from beginner to advanced!Show off your artistic talents in the WC3C Gallery!Download quality models, textures, spells (vJASS/JASS), systems, and scripts!Download maps that have passed through our rigorous approval process!

Go Back   Wc3C.net > Resources > Code Resources > Scripts
User Name
Password
Register Rules Get Hosted! Chat Pastebin FAQ and Rules Members List Calendar



Reply
 
Thread Tools Search this Thread
Old 08-30-2009, 05:04 PM   #1
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default SoundUtils

SoundUtils Library

Background:
This library's development spawned out of my need in a map to handle sounds easily. Sounds suck, through and through, and anyone that has attempted to work with them in the past will agree with me there. Just go do a search for threads relating to "Why doesn't my sound run?" This library removes a lot of the guesswork associated with handling sounds and simplifies their usage and troubleshooting tremendously.

Requirements:Code:
Expand Library:

Function List:
This library provides the following functions to the user.
  • function DefineSound takes string fileName, integer duration, boolean looping, boolean is3D returns integer
  • function DefineSoundEx takes string fileName, integer duration, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate, string eaxSetting returns integer
  • function RunSound takes integer soundRef returns sound
  • function RunSoundOnUnit takes integer soundRef, unit whichUnit returns sound
  • function RunSoundAtPoint takes integer soundRef, real x, real y, real z returns sound
  • function RunSoundForPlayer takes integer soundRef, player p returns sound
  • function ReleaseSound takes sound s returns boolean
I remember first making this library, I had absolutely no idea how sounds work, and I wanted to make sure that no one else ever had this problem again. That was 8 hours of work that every mapmaker should be able to avoid with this library and (at most) a post in this topic.

I trust this will be useful to more than just myself!
Attached Files
File Type: w3x SoundUtilsTestMap.w3x (47.2 KB, 142 views)
__________________

Last edited by Rising_Dusk : 11-12-2009 at 08:27 AM. Reason: Updated
Rising_Dusk is offline   Reply With Quote
Sponsored Links - Login to hide this ad!
Old 08-30-2009, 05:08 PM   #2
darkwulfv
Alpha Male of Wc3c
 
darkwulfv's Avatar


Official Map Reviewer
 
Join Date: Mar 2006
Posts: 3,646

Submissions (6)

darkwulfv is just really nice (270)darkwulfv is just really nice (270)

Send a message via AIM to darkwulfv
Default

I've never found sounds all that hard to work with, honestly. You declare a sound variable in the Sound Editor and then use it later and destroy it when done. I don't see where the guesswork or problems come in. I've also never experienced the "first time doesn't play" bug either... Perhaps it's just me?
__________________
The Spell Request Thread
Quote:
Originally Posted by Joe-Black-5
a dota like map but with unique stuff
(There was no map attached, and that was all the thread said.)
Spells I've Made

Darkwulfv's Lightning Grapple || Tritanis' Lazy Bolt


Last edited by darkwulfv : 08-30-2009 at 05:09 PM.
darkwulfv is offline   Reply With Quote
Old 08-30-2009, 05:39 PM   #3
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by darkwulfv
You declare a sound variable in the Sound Editor and then use it later and destroy it when done.
Ever try playing that sound twice within its own duration? You'll find that it doesn't work. That is the biggest limitation of the Sound Editor sounds and the main reason people look for better ways in the first place. Of course, I did explain that in this library's documentation... :)
__________________
Rising_Dusk is offline   Reply With Quote
Old 08-30-2009, 05:44 PM   #4
uberfoop
User
 
uberfoop's Avatar
 
Join Date: Jul 2005
Posts: 207

Submissions (1)

uberfoop will become famous soon enough (29)

AI tournament - 2nd place

Default

Quote:
Originally Posted by darkwulfv
I've never found sounds all that hard to work with, honestly. You declare a sound variable in the Sound Editor and then use it later and destroy it when done. I don't see where the guesswork or problems come in.
The main point of this is avoiding the doesn't-play-when-two-instances-are-attempted issue.



I think it's pretty neat.
__________________
Quote:
Originally Posted by darkwulfv
.03 is one 300th of a second.
uberfoop is offline   Reply With Quote
Old 08-30-2009, 05:46 PM   #5
darkwulfv
Alpha Male of Wc3c
 
darkwulfv's Avatar


Official Map Reviewer
 
Join Date: Mar 2006
Posts: 3,646

Submissions (6)

darkwulfv is just really nice (270)darkwulfv is just really nice (270)

Send a message via AIM to darkwulfv
Default

Whenever I used sounds it was always a one-time deal (or the sound was repeated, but not at the same time).

After reading said documentation, I see this limitation now. I've just never experienced it.
__________________
The Spell Request Thread
Quote:
Originally Posted by Joe-Black-5
a dota like map but with unique stuff
(There was no map attached, and that was all the thread said.)
Spells I've Made

Darkwulfv's Lightning Grapple || Tritanis' Lazy Bolt

darkwulfv is offline   Reply With Quote
Old 08-30-2009, 08:26 PM   #6
Na_Dann_Ma_GoGo
User
 
Join Date: Feb 2008
Posts: 125

Na_Dann_Ma_GoGo has little to show at this moment (8)

Default

I found myself in really heavy trouble regarding sounds, I may check this out.

Last edited by Na_Dann_Ma_GoGo : 08-30-2009 at 08:27 PM.
Na_Dann_Ma_GoGo is offline   Reply With Quote
Old 08-30-2009, 09:29 PM   #7
Karawasa
Element Tower Defense
 
Karawasa's Avatar
 
Join Date: Feb 2006
Posts: 1,094

Submissions (2)

Karawasa has a spectacular aura about (78)Karawasa has a spectacular aura about (78)Karawasa has a spectacular aura about (78)

Approved Map: Tropical TagApproved Map: Element TD

Send a message via AIM to Karawasa Send a message via MSN to Karawasa
Default

I don't use sounds anymore but I remember back in Tropical Tag they were a huge pain in the ass. Thus, this seems like a useful library.
__________________

Element Tower Defense - Premier WC3 Custom Game
Karawasa is offline   Reply With Quote
Old 08-31-2009, 12:11 AM   #8
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Are there any reasons to use ExecuteFunc in lieu of .execute?

Also, is there any advantage to recycling sounds other than the small performance boost of not creating and destroying handles?
__________________
Anitarf is offline   Reply With Quote
Old 08-31-2009, 12:39 AM   #9
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Anitarf
Are there any reasons to use ExecuteFunc in lieu of .execute?
Force of habit. If it's a problem, I can change it. They're the same, though, as far as I am aware.
Quote:
Originally Posted by Anitarf
Also, is there any advantage to recycling sounds other than the small performance boost of not creating and destroying handles?
You need multiple sounds to play multiple at a time and they're easy to recycle (and saves you from having to change their settings many times, since they remember their settings), so I figured might as well. You could consistently create new sounds if you wanted, but I figure that if you can recycle them easily, why not?
__________________

Last edited by Rising_Dusk : 08-31-2009 at 12:40 AM.
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 12:59 AM   #10
Anitarf
Procrastination Incarnate


Development Director
 
Join Date: Feb 2004
Posts: 8,190

Submissions (19)

Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)Anitarf has a brilliant future (903)

2008 Spell olympics - Fire - SilverApproved Map: Old School Alliance TacticsHero Contest #2 - 3rd PlaceSpell making session 2 winner

Default

Quote:
Originally Posted by Rising_Dusk
Force of habit. If it's a problem, I can change it. They're the same, though, as far as I am aware.
.execute is supposedly faster.

Quote:
You need multiple sounds to play multiple at a time and they're easy to recycle (and saves you from having to change their settings many times, since they remember their settings), so I figured might as well. You could consistently create new sounds if you wanted, but I figure that if you can recycle them easily, why not?
If you don't know which sound particular is getting recycled, remembering their settings can be a problem. If you always play sounds at their default volume except in rare cases when you modify the volume, then once one of those rare cases gets recycled for a normal case, it's volume would no longer be at the expected default value.

Recycling can be a bigger performance hit than creating/destroying, in your case you need to maintain a stack for each sound type, plus the extra timerutils operations for the RecycleSoundWhenDone feature. Also to consider is the fact that other recycling systems like Timer/GroupUtils exist primarily because of bugs associated with destroying those handles, performance is a secondary concern.
__________________
Anitarf is offline   Reply With Quote
Old 08-31-2009, 01:46 AM   #11
Bobo_The_Kodo
oO
 
Bobo_The_Kodo's Avatar
 
Join Date: Jul 2008
Posts: 580

Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)

Default

.execute uses TriggerExecute rather than ExecuteFunc, and TriggerExecute is faster
Bobo_The_Kodo is offline   Reply With Quote
Old 08-31-2009, 02:05 AM   #12
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Quote:
Originally Posted by Anitarf
If you don't know which sound particular is getting recycled, remembering their settings can be a problem. If you always play sounds at their default volume except in rare cases when you modify the volume, then once one of those rare cases gets recycled for a normal case, it's volume would no longer be at the expected default value.
You could always just do call SetSoundVolume(MySound, 127) if you're doing something weird like that.
Quote:
Originally Posted by Anitarf
Recycling can be a bigger performance hit than creating/destroying, in your case you need to maintain a stack for each sound type, plus the extra timerutils operations for the RecycleSoundWhenDone feature. Also to consider is the fact that other recycling systems like Timer/GroupUtils exist primarily because of bugs associated with destroying those handles, performance is a secondary concern.
I can't really argue with this. I guess it's just a matter of preference. I prefer to keep my handle count low, and since I will never use more than 5 or so sounds at once, performance is a non-issue. The contrast here is that you'd need to run 9 additional natives for each sound you create as opposed to those you recycle. Does that rival the array handling of the stack? Heck if I know, but what I do know is that either way the difference is going to be negligible in all applicable cases.
__________________
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 06:17 AM   #13
Bobo_The_Kodo
oO
 
Bobo_The_Kodo's Avatar
 
Join Date: Jul 2008
Posts: 580

Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)Bobo_The_Kodo has a spectacular aura about (109)

Default

RecycleSoundWhenDone_Child doesn't recycle the timer >.<
Bobo_The_Kodo is offline   Reply With Quote
Old 08-31-2009, 06:56 AM   #14
Rising_Dusk
Obscurity, the Art


Projects Director
Project Leader: OD
 
Join Date: Feb 2006
Posts: 9,729

Submissions (27)

Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)Rising_Dusk has a reputation beyond repute (1192)

Hero Contest #3 - 1st PlaceApproved Map: Desert of ExileApproved Map: Advent of the ZenithHero Contest #2 - 1st PlaceHero Contest - Third place>

Send a message via AIM to Rising_Dusk Send a message via MSN to Rising_Dusk
Default

Lol, I win.
__________________
Rising_Dusk is offline   Reply With Quote
Old 08-31-2009, 12:30 PM   #15
Anachron
User
 
Anachron's Avatar
 
Join Date: Mar 2009
Posts: 1,079

Anachron will become famous soon enough (51)Anachron will become famous soon enough (51)

Default

You should add an option what player to play the sound to, else this is pretty damn a waste of space in most maps.
__________________
CustomInventory [Discussion - Download] - Got Directors Cut!
CustomMissle [Discussion - [Download (not yet)] - In development!
Other systems [Spawn System] [Move System] [CustomBar] [SpellBar]
Anachron is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off


All times are GMT. The time now is 04:27 AM.


Affiliates
The Hubb The JASS Vault Clan WEnW Campaign Creations Clan CBS GamesModding Flixreel Videos

Powered by vBulletin (Copyright ©2000 - 2019, Jelsoft Enterprises Ltd).
Hosted by www.OICcam.com
IT Support and Services provided by Executive IT Services