How to load and play multiple sounds at once?

Solid argument! Thanks! But I guess custom resource path from where I load buffer from would be included in build anyway right?

If you include a custom resource, then yes, it’s included in the archive.
You can always inspect the build report after a bundle step.

1 Like

Super, that clears that. Hmmm but again I’m trying to wrap my head around it. As in my current setup I have a folder “/assets/sounds” that is custom resource. And in this ambitious game I have 60 sounds for different footsteps, 15 for different music, and quite a few sound effects. That would mean if we discuss an approach of having a collection, all of them I would need to be referenced as separate .sound file with separate group that you need to double check its correct.

Therefore looking at approach in the original OP I thought is much cleaner IMO:

  • Have GO sound.go that you can attach to any collection
  • Have a script in it that listens to requests to play certain sounds
  • Have different “.sound” components that have a group specified. Like sfx.sound with group sfx, music1.sound and music2.sound with group music, …
  • And then any go can request to play any “file” from assets I desire. For example play a different random footstep based on surface or terrain or new environment we are in, or new collection has different theme and collection’s script just asks to play themed music file

Would you agree that it would be cleaner (I kinda think so at least)?

But then again, it would need to re-load buffer into resource and each .sound would need a separate resource. Even though its meant to be “dummy” placeholder

Maybe would it make sense that .sound component does not need to reference a resource and by default it creates an “empty” resource. Or maybe it can have a flag “dynamic”, that would have this behavior… At least to have some kind of option to do that if user chooses to?

just brainstorming at this point, I’m not an expert into all use-cases and I’m sure you guys have a way better overview of what people are building with an engine and how engine is intended to be used.

1 Like

I am coding my first tiny game in defold with sounds… and I am stuggling too, like you.
And I think I am aligned with your last idea.
I see sound component as kind of “sound emmiter”, which points to a particular .wav file at desing time. But then the .wav file will surely be replaced dynamically at runtime by code to play whatever sounds we need.

So yes a sound component/emitter for each specific sound-emiting thing (sfx, bg music, specific GO to implement paning/spacing based on game positioning, sound-effects emitter (reverberate sounds etc.)…

For example in my case I have many little animals each having many .wav files that I want to pick randomly (like “cat_hello_001.wav”, “cat_hello_002.wav” etc.) when the cursor hand-over it.
So I will create one sound component per animal, but choose in a table randomly the name of wav file and load it at runtime.

May I ask why you will load it at runtime instead of assigning it to a sound component in the editor so that it becomes part of the resource graph and loaded by the engine?