| 04-17-2006, 09:49 PM | #1 |
Apologies in advance - I wouldn't ask so much at once, but couldn't find a tutorial on this subject. I'm trying to assign a sound to an event by ability ID as I'd like to be able to change the sound without touching the script. (questions are the code comments) JASS:function SoundEffect takes unit target returns nothing local real x = GetUnitX(target) local real Y = GetUnitY(target) local sound hit set hit = CreateSound(GetAbilitySoundById ('A001', SOUND_TYPE_EFFECT,false,true, false, (integer fadeInRate), (integer fadeOutRate),(string eaxSetting)) //I don't know what to put for fade-in and out. I get what fad-in and fade-out //are, just don't know if percentage or what. And what is eaxSetting? call SetSoundVolume(100) call SetSoundPosition(hit,x,y,60) call StartSound(hit) call KillSoundWhenDone(hit) //Have I done everything I need to play the sound? set hit = null endfunction |
| 04-17-2006, 09:59 PM | #2 |
Fade-in and Fade-out are real values that correspond to seconds, I believe. EAX refers to the Creative EAX Soundcard audio processing... not sure what the value should be, maybe just try "" (null string?) Also... you're missing a ')' after the second parameter of GetAbilitySoundById |
| 04-17-2006, 10:57 PM | #3 |
Dude, I have to tell you this. Using sounds with jass has a bug; It wont always play the sound the first or few first times you try to play it, however when it does play, it will play on the rest of the attempts to play it. |
| 04-17-2006, 11:37 PM | #4 | |
Quote:
Since the function called by the GUI essentially has the same effect as calling StartSound(), that really doesn't seem to make much sense unless assigning bj_lastPlayedSound to the sound you're trying to play has some unseen effect. If that were true it would seem like the PlaySoundBJ() or whatever it is would do the same thing. My guess is that it's actually something else you overlooked. Unless I'm mistaken, shouldn't you call KillSoundWhenDone() after calling StartSound()? Also, since they are named fadeInRate and fadeOutRate, my guess would be that they are actually the amount (maybe percent) that the volume increases per second (or whatever unit of time used: miliseconds maybe?). |
| 04-17-2006, 11:47 PM | #5 | |
Quote:
JASS:function PlaySoundBJ takes sound soundHandle returns nothing set bj_lastPlayedSound = soundHandle if (soundHandle != null) then call StartSound(soundHandle) endif endfunction The problem may have something to do with the way WC3 loads content. Abilitys, models, ext. are not loaded untill they are first needed. Im guessing it would be the same for sounds. (Thus, they wouldnt play untill fully loaded) |
| 04-18-2006, 12:23 AM | #6 | ||
Quote:
Thanks for the tip on KillSound. The reason I'm not using the GUI version is because I want to be able to change the sound in the object editor without using sound manager to create a variable first. Makes it easier to configure, but harder to set up. Post 2: Quote:
Do you think addin this to the init_trg function might help?: JASS:call Preload(GetAbilitySoundById ('A001', SOUND_TYPE_EFFECT)) Edited by Blade.dk. Reason: Double post.. |
| 04-18-2006, 07:32 AM | #7 |
I already did killsoundwhendone and everything that gui does. The difference is that the sound is preplaced when pressing F5 and putting it on a sound variable. I think it preloads on initialization to prevent this from happening. I am talking about playing a sound without pre defining it with F5. I'm not talking out of the air here, i've already experienced this. I havent tried on preloading it knutz, try and see if you dont get any bugs. The sound sometimes WILL play on the first time, but most times it bugs out. |
| 04-18-2006, 07:59 AM | #8 | |
Quote:
Doasnt the preload function take a filename? |
| 04-18-2006, 08:24 AM | #9 |
No, it takes it from fields from the abilitydata BTW knutz you havent used call SetSoundDuration(sound, real) the sound duration is used like this: lets say a sound is 00:05:52 long you can see it when assigning it with F5 the duration here will be 552 just take the last numbers, not including 0's Offtopic: Heh earth-fury, you should have just put bj_PI :P |
| 04-18-2006, 09:49 PM | #10 |
Example of what the sound editor does: JASS:set gg_snd_clipin=CreateSound("war3mapImported\\clipin1.wav",false,true,false,10,10,"SpellsEAX") call SetSoundDuration(gg_snd_clipin,299) call SetSoundChannel(gg_snd_clipin,11) call SetSoundVolume(gg_snd_clipin,127) call SetSoundPitch(gg_snd_clipin,1.) call SetSoundDistances(gg_snd_clipin,600.,10000.) call SetSoundDistanceCutoff(gg_snd_clipin,3000.) call SetSoundConeAngles(gg_snd_clipin,.0,.0,127) call SetSoundConeOrientation(gg_snd_clipin,.0,.0,.0 There's no magic. |
| 04-19-2006, 10:01 PM | #11 | |
Yep, PipeDream is right, sounds are no different to any other varible You can have locals and globals, they are both exactly the same. Using sound editor is no different from using trigger editor. Sound editor is just easier for fast maps, and creates a global sound if you want them done well, create them yourself in JASS. As Pipe said, the sound editor just does what most people do when creating a sound in JASS, the basic functions it needs to run. Quote:
Yes, i have experienced this myself when creating sounds in JASS, its just that the sound editor will have some unknown way to completly destroy a sound handle, where as KillSoundWhenDone() wont have the same effect, try stopping it, then using KillSoundWhenDone, then setting the sound to null. |
| 04-19-2006, 10:23 PM | #12 |
I'll try that. |
| 04-20-2006, 12:59 AM | #13 | |
Quote:
I'll try this out soon as I'm home! |
