More flexible AudioEngine

I started working on an interactive soundtrack for my game and WebAudio is of cours perfect. Babylon already has a lot in place, so I will ask for some additions to make it more flexible. In the mean time I will just access private members.

I am going to start with a very small request :slight_smile:

Proposal: add a public property ‘duration’ to BABYLON.Sound that accesses BABYLON.Sound._audioBuffer.duration

let me know if you would like me to start working on the Babylon source code!


p.s.: gives a very smooth transition; If I use soundtrackPart1.onended(() => it is not smooth at all.

Hey! would you be ok to do the PR?

1 Like

You probably do not want to have to go back & do more here, so just making the entire audioBuffer public would cover more bases.

You would also get length, numberOfChannels, sampleRate, copyFromChannel(), copyToChannel(), & getChannelData(). Not that important to most, but I am doing a lot of work in this area right now. I use them against my own AudioBufferSourceNode's & the AudioEngine’s context sometimes.

I only use a BABYLON.Sound object once I have already assembled an entire sound track using an OfflineAudioContext. This makes my little video making process work with both sound files & generated audio without change.

Yes, I agree with exposing the audioBuffer.

I just started working with Web Audio, sounds like you have a better perspective. Do you think anything else is needed to make the AudioEngine fully extendable without making the interface too complicated?

Thanks for asking. I have only used the Sound object not the SoundTrack, WeightedSound, or Analyser. I have moved from using the stuff here, which does look pretty game related except for strong integation to animation, to another code base. It has its own AudioBufferSourceNode 's. No need to have more than one context, so I just use the one here.

PR’s are not a precious resource. Making that public is a quickie. As you use it, maybe you’ll think of something else, then do another.

1 Like

Can’t agree more