How correct usage sound component?

Hi all.

My first question. I have tons small sounds files(dialogs). I can change sound file in sound component by script or I need create tons sound component for each file?

My second question. I can detect finished sound or not? I have active dialog system with voice and need detect start/stop sound

Thank you for answer.

You must create a sound component for each sound. You can load/unload sets of sounds with collection proxies.

To detect timing of audio (and thus when audio files should be done playing) currently you have to do it manually with timing meta data manually created and loaded and a timer increased with dt value. More features for audio have been requested before Some audio features - pause, resume, play after, detect playback

I understand what I can load/unload collection proxies but in my one dialog 102 sounds :slight_smile: And create 102 sound component it really strange :slight_smile:

Thank you for link and info. I right understand about meta data - create Lua table with sound timings and in update function count elapsed time?

You should make a batch script to generate all of the sound components based on the list of files to make your life easier. Someone else may have already done this in the past.

Loading so many audio files into memory at once can be bad (all active audio components are not streamed they are loaded into memory) so you may want to segment those over several collections.

Yes, counting elapsed time with dt on update should be good enough. You may want to add a little extra time as spacing between playing each clip. Test and see what works. Hopefully more sound features come in the future such as being able to detect end of audio clips and dynamically load audio files via scripting!

I will think about small collection proxies for each dialog phrase. May be not proxies, may be game object factory. Thank you again.

Factories will still be loaded into memory. You need collection proxies to load/unload into memory.

Use

msg.post("@system:", "toggle_profile")

Along with task manager to watch resource / memory use with your setup.

My guess is that we will open up the Defold SDK so that it’s possible to dynamically load/manipulate/generate sounds using the existing buffer system and do resource.set() or resource.set_sound() or something similar.

2 Likes

Yes, I understand about memory usage. I say about factory, because my dialog system very dynamical(simulate real dialog) and may be often load/unload collection will slow process. Tomorrow try you recommendation.

I would also like to remind you that all files in Defold are simple text files, so there’s nothing stopping you from generating them based on other files. You could e.g. have a python script that generates a collection with all those sounds in it and then you could put that into your regular collection. There are a lot of benefits of keeping the resource-dependency-tree static.

Example:

dialog_sounds_gen.py, generates:

dialog_sounds.collection, containing:

  • Collection
    • dialog_sounds (game object)
      • manager (script)
      • my_dialog_sound1 (sound)
      • my_dialog_sound2 (sound)

Based on the files:

  • my_dialog_sound1.wav
  • my_dialog_sound2.wav

Etc.

2 Likes

I will plan create similar script :slight_smile:

I was make first question, because, for example, in Sprite/Gui I can change texture for any file/anim in Atlas/Tilesource and I will think for Sound component present similar schema.

Thank you for answer and good luck.

Yes, it is possible in GUI because you have the atlas file with images already added to the GUI scene in the editor. For sound files the only link to the file is in the sound component.

It requires a bit more initial work to statically link all files like this but there are great benefits. For instance, when you build only files that are actually used are included in the game bundle. It also allows the editor to automatically fix links when you rename or move stuff around.

1 Like

I now make script(in php with ogg tools) for recieve sound files names, sounds length and generate all need Defold files. And make small Lua script for start/stop sounds and check end sounds with recieved sounds lengths data. If somebody need this small tools I share after complete and tests.

3 Likes

Hi again!

I receieve strange bug with make sound play structure(application crush when I try unload collection).

I make mainSound collection, mainSound collectionproxy and gameobject controller for control mainSound collection. In mainSound collection present GameObject with collections, collectionproxies, gameobjects for every sound file and gameobject controller for load/unload sound collection. I start game, load mainSound collection and load/unload inside collections, but if i try unload mainSound collection then game crush with AccessViolation error.

I tried delete all inside collections and justload/unload mainSound and game crush again, but if i load/unload any inside collection all good.

What happened?

PS: Script for generate sound,go,collection, proxycollection files and collect sound length based on OGG files work in alpha version :slight_smile:
PPS: Second schema for manipulate sounds its make one gameobject with all sound files and start/stop they, but i think it has very high memory utilization

Make second schema. Schema with many proxies have very problem :frowning:

It sounds like you have hit a bug. I’ll try to reproduce it after the weekend (we have a short holiday here in Sweden).

1 Like

Good weekend.

I think I create very high count proxies and recieve bug. But I can create sample project with it bug.

1 Like

Thank you! Have a good weekend you too!

That would be awesome. Thanks!

Tried make sample project with bug and not reproduce :frowning: Sorry for annoying.

I have very big request - please make callback message for sound completion it very important. I did system with check sound length, but start sound play have some delay and sometime my system not right work. If make length more then my dialog system wait check completion and it not good. If you make callback message it complete resolve my problem.

Thank you!!!