• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Sound mui

Level 30
Joined
Aug 29, 2012
Messages
1,382
If it can be in jazz

1740090448671.png


There's often problems related to playing sounds, imo the easiest way is to add the sound directly in the model so that it plays during a specific animation, and play said anim when your ball hits something
 
Level 45
Joined
Feb 27, 2007
Messages
5,578
The first time a custom sound object is played in a map it will not be audible. For this reason it’s beneficial to preload your sounds by playing them once at low/no volume.

Sounds as available to GUI are global variables that point to sound objects, and as such a single sound object cannot be played simultaneously in multiple locations (different sound objects can be simultaneous). The way around this is to create a new instance of the sound object each time you want it to play. The GUI functions for sounds do not really make this possible, though it is with JASS/Lua.

Chaosium’s suggestion of integrating the sound into the object model avoids these issues. You can also assign the sound to be used by some ability (Roar for example) and then use a dummy to cast that ability wherever you want the sound heard.
 
Last edited:
Level 24
Joined
Feb 27, 2019
Messages
833
Here are two examples of how I have used sounds. I learned these from this forum from guides that I am unable to find now.

This works and is very simple. It creates a sound with some default values. Theres just a custom script and the addition of destroy sound. The native CreateSound has some parameters.
  • Custom script: set udg_GunGlaiveSound = CreateSound("Abilities/Weapons/huntermissile/HeadHunterMissileHit1", false, true, true, 1, 1, "CombatSoundsEAX")
  • Sound - Play GunGlaiveSound at 100.00% volume, attached to AllPigsArray[Int]
  • Sound - Destroy GunGlaiveSound
JASS:
native CreateSound takes string fileName, boolean looping, boolean is3D, boolean stopwhenoutofrange, integer fadeInRate, integer fadeOutRate, string eaxSetting returns sound

Later I did something like this for a dynamic index. I added some dots to display time has passed before the next actions.
  • Custom script: set udg_MechanismSound[udg_MechanismMax] = CreateSound("Abilities/Spells/Other/Monsoon/MonsoonRainLoop", true, true, false, 1, 1, "SpellsEAX")
  • Custom script: call SetSoundVolume(udg_MechanismSound[udg_MechanismMax], 30)
  • Custom script: call SetSoundDistances(udg_MechanismSound[udg_MechanismMax], 600, 3500)
  • Custom script: call SetSoundDistanceCutoff(udg_MechanismSound[udg_MechanismMax], 3000)
  • Custom script: call AttachSoundToUnit(udg_MechanismSound[udg_MechanismMax], udg_MechanismDummy[udg_MechanismMax])
  • Custom script: call StartSound(udg_MechanismSound[udg_MechanismMax])
  • ...
  • Sound - Destroy MechanismSound[MechanismIndex]
  • Custom script: set udg_MechanismSound[udg_MechanismIndex] = null
So in essence: create sound, set some values for the sound or keep default values, play sound and destroy sound. Very simple.
 
Top