• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Music inducing lag

Status
Not open for further replies.
Level 4
Joined
Sep 28, 2016
Messages
47
Hi all,

It seemed that once the song was played once, it would be stored in memory and wouldn't create lag the next time it was played. However, when I played track a, then track b, then back to track a, it lags for a second to load it again. Anyone know why this could be? Any guaranteed way to store it in memory for the entirety of the game?
 
Level 11
Joined
May 16, 2016
Messages
730
Hi all,

It seemed that once the song was played once, it would be stored in memory and wouldn't create lag the next time it was played. However, when I played track a, then track b, then back to track a, it lags for a second to load it again. Anyone know why this could be? Any guaranteed way to store it in memory for the entirety of the game?
Stop music immediatly
Clear music list
Play music track b.
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
I am guessing the lag has nothing to do with file IO and the track not being cached. Otherwise it would only lag once as after that the track would then reside in the file cache so no IO would occur and the track would be loaded almost instantly (sub frame).

What I guess is happening is incorrect use of the miles sound system API used by WC3. Tracks are probably being played in a way that changing the current track blocks until the track is done. Hence the game "lags" as the main thread is blocked waiting for the track to finish fading out so a new track can be loaded in. After the fade out is finished the function returns and the main thread resumes operation.
 
Level 4
Joined
Sep 28, 2016
Messages
47
Yes. Music isn't a game state change, so no desync chance.

Thanks man. Sorry for being annoying, but could I just clarify again: If I use these triggers -

  • Main Town Music
    • Events
      • Unit - A unit enters CCTownRegion <gen>
      • Time - Every 3.00 seconds of game time
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
    • Actions
      • Set GENERIC_SoundForPlayer = (Owner of (Triggering unit))
      • Custom script: if GetLocalPlayer() == udg_GENERIC_SoundForPlayer then
      • Custom script: call StopMusicBJ( true )
      • Custom script: call TriggerSleepAction( 2.00 )
      • Custom script: call PlayMusic(gg_snd_MAINISLAND_TOWN__The_Scumm_Bar)
      • Custom script: endif
And multiple players are triggered these simulataneously, it'll still work properly? No issue of instancing?
 
Level 4
Joined
Sep 28, 2016
Messages
47
I am guessing the lag has nothing to do with file IO and the track not being cached. Otherwise it would only lag once as after that the track would then reside in the file cache so no IO would occur and the track would be loaded almost instantly (sub frame).

What I guess is happening is incorrect use of the miles sound system API used by WC3. Tracks are probably being played in a way that changing the current track blocks until the track is done. Hence the game "lags" as the main thread is blocked waiting for the track to finish fading out so a new track can be loaded in. After the fade out is finished the function returns and the main thread resumes operation.

Thanks for your insight on this Doc. It's a good reminder that I shouldn't assume I know what's going on ;P
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,199
And multiple players are triggered these simulataneously, it'll still work properly? No issue of instancing?
Use TriggerSleepAction outside the local block? Start another local block after the wait?

I am not sure it is safe to use TriggerSleepAction in a local block. I am guessing it generates net traffic which will not sync well unless all clients run it.
 
Status
Not open for further replies.
Top