Max Number of sounds? (DEF-2979) (SOLVED)

Does defold have a max number of sounds files?

I’m building a game which reads various words. Right now, I have a 630 wav files and my game sometimes playing the wrong sounds file. It only happens for certain words. For instance, “map” is always playing the “cheese” file. It’s most like “map” and “cheese” are sharing a hash key.

I’ve already increased the “Max Sound Data”, “Max Sound Buffers”, “Max Sound Sources” and “Max Sound Instances” to 1024.

Does anyone have any ideas why or how to debug this?

Would separating the sound files into different game objects help?

1 Like

Not sure about this issue. Can you figure out at what number of sounds it begins to behave incorrectly?

You might try switching to using https://www.defold.com/community/projects/59862/ for audio.

This sounds a bit strange to be honest. Can you please double check those two sound components and ensure that they reference two different wav/ogg files and that these two wav/ogg files actually aren’t the same?

No. It makes sense to have all sound components on one game object since it simplifies sound gating and other sound control operations.

I’m temping to convert to use OpenAL but I didn’t want to waste my time if it was an known platform limitation.

Yes, I’m sure my object files is correct…

components {
  id: "map_file"
  component: "/main/wavs/wav/map.wav"
  position {
    x: 0.0
    y: 0.0
    z: 0.0
  }
  rotation {
    x: 0.0
    y: 0.0
    z: 0.0
    w: 1.0
  }
}

Is there some way you could share the project (bjorn.ritzl@king.com) or a small project that reproduces the problem?

I did some debugging and it definitely seems like there is a max of 256.

I created an array of all my words and started playing each of them. As expected, I’m seeing that when I it hits 257 is starts over again. So word[257] = word[1], word[258] = word[2]…

Does anyone know of a workaround? Right now, I’m considering trying…

  1. splitting the sounds into multiple game objects. The idea is that the limit is actually per game object and not per project.
  2. try OpenAL
  3. See if there is a way to play only part of an audio file. for instance, merge all sounds into one long wav and instead, play seek to a position then play for X seconds. (e.g. similar to sprites but for audio).

Anyone have any thoughts on these?

As a mentioned before, I bumped all the project settings to 1024.
02 AM

That seems strange. You can double check the values in the game:

print(sys.get_config("sound.max_sound_data.", "not set"))
print(sys.get_config("sound.max_sound_buffers.", "not set"))
print(sys.get_config("sound.max_sound_sources.", "not set"))
print(sys.get_config("sound.max_sound_instances.", "not set"))

Matches my config… … (once I removed the trailing period )

DEBUG:SCRIPT: Max Sound Data = 1024
DEBUG:SCRIPT: Max Sound Buffers = 1024
DEBUG:SCRIPT: Max Sound Sources = 1024
DEBUG:SCRIPT: Max Sound Inst = 1024

Ok. How do you generate your table?

Also, does it behave correctly if you bundle the game first, and then run it?

I wonder if somewhere there’s an iterator index of type UInt8 in a for so it overflows.

1 Like

It indeed seems we had a place where the component id’s (numbers) got clamped to [0:255]. It seems like an easy fix (we’ll discuss it tomorrow), and if so, it should land in the next release scheduled for monday. I added ticket DEF-2979 for this.

6 Likes

Thanks.

Creating separate game objects also fixes the problem. I wrote a bash script to generate sound_{a … z}.go files. For my game, the IDs match the word so it was easy route the message to the correct game object based upon the word I want to say.

5 Likes

Fixed in Defold 1.2.117

3 Likes