What is the purpose of the SoundTrack's mainTrack constructor option?

In ISoundTrackOptions | Babylon.js Documentation it simply states: “Define if the sound track is the main sound track of the scene”. This isn’t very helpful, because it doesn’t answer any of the questions that immediately come to mind:

  • What is the “main” sound track of a scene?
  • How is it different from other sound tracks?
  • When should I be using this flag?

Looking at the source, it seems to do only one thing, but the purpose is unclear:

  • Here it gets added to a list of sound tracks for the given scene, but only if it’s not the main track
  • Here a new sound track is created whenever the current scene doesn’t have one

What am I supposed to do with it? In my application I have a sound track for background music, one for sound effects, and one for ambient sounds. None of these seem like they should be the “main” sound track. Do I even need to care about setting one in this case?

The audio engine was written a few years ago, and does need a revisit :slight_smile:

This configuration is just there to allow the scene object to have a “main sound track” that is user (or developer)-defined. It is a container for every sound created

No, you don’t. The main sound track will be created for you, and any new sound that is created in the scene will be added to it. There is no need on your part to define a new soundtrack.

3 Likes