Sound Limitations

BlackRose

Forum User
Reaction score
239
Are there like sound limitations? I've tried playing the FaerieDragonSound every 0.075 second but it will not work. Only 3 instances are played at once.

It's blargh. Other sounds such as: [ljass]"Sound\\Units\\Combat\\MetalLightSliceMetal2.wav"[/ljass] will play without limits...

Here's the method I am using:
JASS:
            method createBladeSound takes nothing returns nothing
                local integer r = GetRandomInt( 0, 2 )
                local sound   s = null

                //if r == 0 then
                    set s = CreateSound( SOUND_ONE, false, true, true, 10, 10, "" )
                    //call SetSoundParamsFromLabel( s, "FaerieDragonLaunch")

                /*elseif r == 1 then
                    set s = CreateSound( SOUND_TWO, false, true, true, 10, 10, "" )
                    call SetSoundParamsFromLabel( s, "FaerieDragonLaunch" )
                    call SetSoundDuration( s, SOUND_DUR_2 )
                elseif r == 2 then
                    set s = CreateSound( SOUND_THREE, false, true, true, 10, 10, "" )
                    call SetSoundParamsFromLabel( s, "FaerieDragonLaunch")
                    call SetSoundDuration( s, SOUND_DUR_3 )
                endif*/

                call    SetSoundVolume( s, PercentToInt( 100, 127 ) )
                call  SetSoundPosition( s, GetUnitX( this.caster ), GetUnitY( this.caster ), 100.00 )
                call        StartSound( s )
                call KillSoundWhenDone( s )
                set this.ticks = 0
                set s = null
            endmethod
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
Yes, there is a limittation.
At the sound editor, you can see the sound's 'Duration'

I've tried playing a sound file (Duration:2.001second) once every 2seconds, failed.
So, I tried 2.1 seconds.. Success

It seems that you can only spawn a sound only when that sound handle is done playing =/
Or sth like that.

I haven't tried sth like this, though:

Sound[0] = SameSound
Sound[1] = SameSound
Sound[3] = SameSound

Then, loop and play the sounds, lol
Might work, might not, I duno
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
I know.
It's the same.

I also used that exact same line of code you did.
I'm talking about the duration of the sound, that you can only see in the sound editor (Or if you know it because it's a custom sound file and you imported it =x)
There isn't a GetSoundDuration.. Is there?
 

BlackRose

Forum User
Reaction score
239
I've tried with setting sound duration and without. Actually, you just gave me an idea of reimporting the sound and seeing if it work. I might test that later.

Hmm.. same sound handle? I'm creating new ones to play, not using same.
 

Tyrulan

Ultra Cool Member
Reaction score
37
You are using the same handle...

A new handle would be by creating a struct specifically for the sound and moving your method into there.
 

BlackRose

Forum User
Reaction score
239
You are using the same handle...

A new handle would be by creating a struct specifically for the sound and moving your method into there.

What is meant by handle?

Isn't the decleration of a 'local sound' a new handle? By the way, if I am doing it wrong, why does it work on other sounds but not some .__.
 

SineCosine

I'm still looking for my Tangent
Reaction score
77
*Ahem* Duration *Ahem* Of *Ahem* Sound *Cough*

Maybe =/
I think he meant that actually creating a new handle everytime would actually work.
(Even though I have not tested it)

Something like that SameSound Array thingy, but local and not global.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Try without KillSoundWhenDone, and if it works then use a timer or a wait, to destroy the sound / recycle it after playing done.

Also be sure this.caster is a valid unit, and more the one expected (debug message).
And ofc display also X/Y.
 

Tyrulan

Ultra Cool Member
Reaction score
37
The construction of a struct creates an "instance" of handles. In this case you need your handles to be separate so they will play at the same time. Local variables are overwritten each time the code is run regardless of local vs. global. Hence the need for structs in MUI. (Multi-Unit Instanceability). I am however, curious whether the sounds may be played at the same time over the same output stream.. (Wc3's sound stream).
 

BlackRose

Forum User
Reaction score
239
Try without [ljass]KillSoundWhenDone[/ljass], and if it works then use a timer or a wait, to destroy the sound / recycle it after playing done.

Also be sure this.caster is a valid unit, and more the one expected (debug message).
And ofc display also X/Y.

Everything is valid...

I'll just attach the map.
This is my 'spell in working :D', so please don't ninja me in submission :O

Notice, when you cast Blade Barrier, there will be a 'metal ticking' with a few Faerie Dragon projectile launch sounds, if you set the sounds to the metal sounds, they'll play correctly and without limits. But change all to Faerie, and you will only hear like 3 per second....

[I've tried that new handle / struct thingy, but dunno if I did it right, see map]
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Are you sure it doesn't work ?
I suppose some sounds "erase" other ones by their nature, and since your function get a random sound, that's not a proper test.

Also forgot this ugly stack of sound, just do like you did before, with the local.
 

BlackRose

Forum User
Reaction score
239
Are you sure it doesn't work ?
I suppose some sounds "erase" other ones by their nature, and since your function get a random sound, that's not a proper test.

Also forgot this ugly stack of sound, just do like you did before, with the local.

Ok. Here it is.
JASS:
        private struct SoundData
            static method create takes unit u returns thistype
                local thistype this = thistype.allocate()
                local integer r = GetRandomInt( 0, 2 )
                local sound   s = null

                //if r == 0 then
                    set s = CreateSound("abilities\\Weapons\\FaerieDragonMissile\\FaerieDragonAttack.wav", false, true, true, 10, 10, "" )
                    call SetSoundDuration( s, 1200 )
                //elseif r == 1 then
                    //set s = CreateSound( SOUND_TWO, false, true, true, 10, 10, "" )
                    //call SetSoundDuration( s, SOUND_DUR_2 )
                //elseif r == 2 then
                    //set s = CreateSound( SOUND_THREE, false, true, true, 10, 10, "" )
                    //call SetSoundDuration( s, SOUND_DUR_3 )
                //endif

                call    SetSoundVolume( s, PercentToInt( SOUND_VOLUME, 127 ) )
                call  SetSoundPosition( s, GetUnitX( u ), GetUnitY( u ), 100.00 )
                call        StartSound( s )
                call KillSoundWhenDone( s )
                set s = null
                call this.destroy()
                return 0
            endmethod
            
        endstruct


--

SineCosine:
I think I just did what you did before and still failed :( Setting array's to sound and crap.

--

If ultimately, it's the sounds fault. I'll add that as a warning to the spell header :D
 

Tyrulan

Ultra Cool Member
Reaction score
37
That's what I had in mind BlackRose. I'm not sure it will work but I think it's worth a try. Results?
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
Actually i think that each sound is played correctly but you have the impression that it doesn't played, or in other words that's the same sound.
You could try to give a different position for each sound.
But anyway it's obvious that only a sound with a short duration is adapted to be played such frequently.

There is also a rumour where sometimes a sound isn't played the first time you try to play it.
To be sure you can create X sounds in an array, play all of them at map initialization, and then use them in your spell.
 
Reaction score
456
> There is also a rumour where sometimes a sound isn't played the first time you try to play it.
Not a rumor. It is true. But not for the sounds you have 'created' in the sound editor. Also, it doesn't work at map initialization sometimes. The reason for that in my map is probably that I have cinematic filter on. Dunno.
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
> There is also a rumour where sometimes a sound isn't played the first time you try to play it.
Not a rumor. It is true. But not for the sounds you have 'created' in the sound editor. Also, it doesn't work at map initialization sometimes. The reason for that in my map is probably that I have cinematic filter on. Dunno.
The sound you have created in the sound editor is created on map init.
I have never "heard"/"seen", a such problem of not playing sound, but in an other hand i haven't used that much sounds.

All i can say, is that a sound is not played if wc3 is minimized, or if the player has turn off the sound in his wc3 settings, or if the sound is already playing (hence the reason of the creation of a sound each time you want to play it).
So it's locally dependant, and maybe this bug of not playing sound the first time is fixed in some patch, dunno.

EDIT


Or try that :
http://www.wc3c.net/showthread.php?t=107433
Basically he says that you can't play a sound in the same time (probably same thread) when it was created, but at least it works sometimes.
So it can't be the absolute truth, but it's worth a try.
Basically he recycles sounds, and play 0.001 second after the sound creation, so don't use KillSoundWhenDone if you use it.
 

tooltiperror

Super Moderator
Reaction score
231
Just a side note.

JASS:
//this.
                local sound   s = null

                    set s = CreateSound( SOUND_ONE, false, true, true, 10, 10, "" )


---->

JASS:
//to this.

                local sound   s = CreateSound( SOUND_ONE, false, true, true, 10, 10, "" )
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
No.
Because normally the sound is randomly created, but if you want to whine about that we can do that :

JASS:
local sound s // yeah we save a set to null !!!
 

tooltiperror

Super Moderator
Reaction score
231
So Sounds have to be nulled first?

That's annoying.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top