Developer for Logic World. — Github Itch.io Twitter Contact

This is an unfortunate limitation of how we currently do audio listening; there’s no smooth way to transition from the main menu audio listener to the player audio listener. I am planning to work around this for 0.91.x

Good grief, this was a hard bug to track down. Especially since you can never prove the absence of occasional random audio stutters in a build, only their direct presence. It took me FOREVER.

Here’s what’s happening:

  • Logic World uses Unity’s OnAudioFilterRead to synthesize the music notes for the music components (Singers and Drums).
  • AS IT TURNS OUT, using OnAudioFilterRead causes the audio thread to become subject to the managed garbage collector, even if you’re not making any allocations with it. This means that when garbage is collected, the audio thread is paused – this is the cause of the stuttering sounds you were hearing. Of course, this critical information is ABSOLUTELY NOWHERE IN THE DOCUMENTATION, and I only learned about it because I stumbled on this forum thread where a Unity dev explains this behavior.
  • So, this issue is actually present in 0.90 as well, but it only shows up after you place down a music component. I assume nobody reported this bug before now because if you’re messing with music components, you probably aren’t listening to the in-game music much (in fact, by default, playing a music component stops any in-game music that is playing)
  • In 0.91 there were many changes to how Logic World renders thumbnails, the little images that show a preview of the components in the Hotbar and Selection Menu. As part of these changes, the component scripts get initialized a bit more than they did in 0.90. This was causing OnAudioFilterRead to be run every time when the game starts up, as part of the process of rendering the thumbnails, so the audio glitches were always present instead of only when you were using music components like in 0.90.

I’ve tweaked the music component code to make sure OnAudioFilterReadonly gets called when it actually needs to be called, so the thumbnail rendering doesn’t trigger that method (thus dooming the audio thread) anymore. This reverts the status of this issue to the much better 0.90 behavior (actually slightly better – in 0.90, the audio thread gets doomed if a music component is placed in the world; in 0.91, you actually need to play a sound with a music component).

Unfortunately I don’t think a full solution is possible for now. I don’t think there’s a way to synthesize sounds with the built-in Unity audio system besides OnAudioFilterRead, and even the shortest pauses due to GC are liable to cause distortion in the playing music. I’m not 100% sure about that, it’s possible that expanding the audio buffer size and eliminating the most egregious allocations in the code would totally eliminate these issues, but I’ve already spent 30 goddamn hours on this and I’m moving on for now.

Later in Early Access, I was already planning to replace the built-in Unity audio system with a third-party solution to enable some epic upcoming features. This third-party system does not have the terrible awful no-good very bad audio thread pausing problems that Unity’s system does, so when we eventually make that upgrade, this issue will be fixed for good.

I cannot for the life of me reproduce this. Are you doing anything besides starting the game and loading a save? How long does it take for music to start erroneously playing? Do you have any mods installed? Are there any errors in the console?

Fixed for the next preview!

Fixed for the next preview!

1) Stop Logic World from ever changing the resolution, if the window is in windowed mode. PLEASE.

Done in a previous preview release (0.91 Preview 510)

2) Further, whenever the resolution does change, ensure that Unity updates its content. It does not seem to always do that.

I can’t reproduce this issue in my Linux Mint install. I did improve the way the game handles windowed mode for the next preview release, so hopefully that fixes it. If not, we’ll be doing a major Unity version upgrade for 0.92, so hopefully that fixes it. If not, I’ll try reproducing your environment to replicate it.

Fixed in next preview

Fixed in next preview :D