Music track stuttering

Hello !

I currently have this music track playing in background, with alternative loops playing depending on certain parameters. As it’s a long loop, its loading mode is in ‘Streaming’.

We’re playing in a multiplayer game, thus, sometimes, there’s a lot of stuff happening at the same time (6 players generating SFXes + ambient sound loops + snapshots triggering and stopping) .

The problem is : The music stutters from time to time.
This didn’t happen before, even with already many events triggering.

Do you people have advices on what could be causing the stuttering (maybe something about CPU) and some known solutions to ease that ? hould the default Loading mode should be something other than Compressed (even if the music audio is in Streaming because of its size) ?

Here are my current settings :

Thanks !

Given that the music is set to streaming, the most likely explanation is that your game is trying to play too many streaming assets at once. Try going through your project’s assets looking for other assets set to stream (especially looping ambiances and dialogue), and setting them to not stream.

Each simultaneously playing streaming asset requires constant disk I/O to function. Unfortunately, most disk drives only support a limited amount of disk I/O per unit time. If that limit is exceeded, your game won’t always be able to load the next section of each streaming asset into the stream buffer in by the time that section needs to be played - resulting in stuttering.

The exact number of simultaneous streams a platform can support depends on its hardware and the assets’ encoding and compression, but it’s usually a single-digit number. For this reason, we strongly recommend that you only set an asset to stream if it’s unlikely to play at the same time as other streaming assets. Music and non-background dialogue are often good candidates; ambient loops can also be set to stream as long as there is only one such loop playing at a time.

Oh, and because of the way streams work, each playing instance of a streaming asset requires a separate stream. This means that, unlike non-streaming assets, simultaneously playing multiple instances of a streaming asset consumes more memory than playing just one instance of that asset.

Ok ! All right ! I’m gonna try to keep only the music to Streaming, and switch to compressed for ambiances. I’ll bump the topic if it worked !

Thanks a lot joseph !

Hello joseph !

So, I manually set every Streaming asset (except the music) to compressed, 100% quality, 48 Hz Vorbis.
And it’s still stuttering ! Do you have an idea of what could be interfering ? Is it possible that the disk I/O could be consumed Unity-Side, by some scripts or assets, and do you have an idea of what is generally in cause there (type of method, etc) ?
And also, what would be the dangers of settng the music and other streaming assets to Uncompressed ? Longer loading times ?

Sorry if I’m asking stupid questions ! Thanks a lot for your availability and your answers ! Cheers !

What kind of assets are your streaming assets (other than the music)? How many of them are playing at the same time?

Hmm. If music really is the only streaming asset you’ve got left, it’s possible that streaming might not be the issue. If you set the music to not stream, does it continue to stutter?

Just to confirm something, how many instruments are in the affected music event, and how many of them play simultaneously?

Here’s a breakdown of how the three different loading modes work:

  • Streaming: The asset is continually read from disk into a small buffer, such that only the small part of the asset that is currently playing or about to play is loaded into memory at any given time. This requires much less memory and shorter load times than either of the other options, but requires constant disk I/O.
  • Compressed: The whole asset is loaded into memory in its compressed form, and decompressed as needed only when it is played. This method requires less memory than decompressed mode, and more memory than streaming mode, but increases the CPU time required to play the asset.
  • Decompressed: The whole asset is decompressed into memory when loaded. This method requires the absolute minimum amount of CPU time to play the asset, but also means the asset takes up more memory while loaded, and that it will take longer to load than either of the other two methods.

As you can see, each method has its own advantages and disadvantages, and these advantages and disadvantages can interact in a complex way. Every game has a unique set of assets and requirements, so you’ll have to experiment to discover what works best for you.

Hmm, I added 2 things :

  • Switching the music to .ogg, to make it less heavy
  • Switching basic assets to Compressed, and music to decompressed (37%, Vorbis, Optimized for Size)

However, the music still stutters, generally when your power sfx are triggered : Those sfx are generally around 5-12 seconds long, with tracks that fade in/fade out that has some effects on them (getting affected by a snapshot + 3-EQ for example ).

Is it possible that the 3-EQ/Flanger effect, or FMOD fading is making these sounds heavy to load ? (they’re also in .ogg).

Also, every sfx are in Vorbis 37% quality Compressed now.

If I were you, I would try those options (or a combination):

  • SFX decompressed (the opposite as what you did), and perhaps even PCM decompressed instead of Vorbis, to have the absolute minimal CPU footprint
  • Music event priority set to highest, SFX to something lower
  • Bank::loadSampleData() on SFX bank to preload them entirely in memory

Hello Alcibiade !

So yeah, I already set SFX to decompressed, and this seems to help a bit, however the stutters are still there when some powers SFX are heard the couple first times (I think) ?

So I went through the profiler, but the CPU usage never gets past 10% ! And my power & ambient sounds, which were the ‘longer’ loops apparently does not consume more than 0.8-1.5 %.

However I didn’t know about the music priority ! I thought it was just about volume sorting order ? So if I’m setting the Music event priority to High, it’ll allow more power to it ?

Also, i’m already loading like all the project’s Banks using the FMOD Studio Bank Loader (on Object Start, Preload sample data ON) - IS that a problem, like does that contradict compression parameters ? Should I only let some specific banks be loaded ?

Thanks a lot for your insight, I hope it’s gonna be useful to others than me !

If you didn’t know about the priority, you should try that at first.
Also, did you correctly set the virtualization/max instances of your SFXs and spatialized ambient loops, in case there could be lots of them at the same time?

I don’t know, I never used that option myself. But I know the FMOD staff told that it’s only necessary for assets that needs to be triggered in a time-critical manner, which is usually the case only for rhythm games, for instance. Maybe could you try the opposite and deactivate it?

That setting doesn’t change how assets are loaded, just when. It has no effects on streaming assets, which must always be loaded as and when the assets plays.

Oh damn I forgot to answer ! So, I :

  • Stopped loading the project’s Banks with the Studio Bank Loader

  • Put the music in ‘Compressed’ , Vorbis 37%, Optimized for Size. The music itself in an ogg.

  • Put the music’s priority on Highest

Aaaaand no stutter anymore ! I enhanced the other asset’s quality, and still no stutter.
Thanks for your help guys !

I’m glad to hear you were able t resolve the problems you were having.

[quote=“laut, post:12, topic:17273”]The music itself in an ogg.[/quote] The format of the source audio files has no effect on their behavior once they’re built into a bank, as their compression and encoding format is replaced as part of the bank-building process.