gryff Posted January 2, 2016 Share Posted January 2, 2016 Anyone who has looked at the code I use for playing sound, music or dialog will notice that I use howler.js for playing sound. Now this New Year, I made a resolution to investigate more the the sound capabilities of BJS - and I have been looking at this tutorial . Now there is one feature that I can't see in the BJS that howler.js has - sound sprites. See here - scroll down to "Define and play a sound sprite" to see an example. All the sounds are contained in one file - but it is possible to play just parts of the file (and if you click the "Play Winner" button and then click the other two buttons you can play all three sounds at the same time - sounds get mixed). So why might this be useful? Well for playing what I call scene environment sounds - like doors opening and closing, footsteps fading away, a scream, a bell sounding, a dog howl etc. Now I have a little collection of these types of sound (between 15 and 20 sounds) the longest of which is about 9 secs and the shortest is 1.2 secs. so rather than load 15 separate files it would be nice to load just one file that I could play small parts of - saves clutter, and download requests. So am I missing/overlooking this type of functionality in BJS with sound? Or is it a feature that could be added? And as a side question, what compressed sound format is playable on all OSs, devices and browsers - or is that a fantasy? cheers, gryff Quote Link to comment Share on other sites More sharing options...
davrous Posted January 3, 2016 Share Posted January 3, 2016 Hi gryff, Yes I know howler got that, it wasn't in my priority list. I can put this feature in my backlog if you really think it's important. For codecs, MP3 seems to be the universal format. One drawback: it doesn't loop perfectly most of the time. For Babylon, you can find an up to date article on our sound support on my blog: https://blogs.msdn.microsoft.com/davrousCheers,David Quote Link to comment Share on other sites More sharing options...
gryff Posted January 4, 2016 Author Share Posted January 4, 2016 Thank you for the reply David And thanks for posting the link to your blog. I have actually been keeping an eye on it - that was how I found out about the Web Audio tab in Firefox. I was also very very impressed with another blog about your efforts at creating a "Breakout" game for the visually impaired using WebGL audio - I would not have known where to start I can put this feature in my backlog if you really think it's important. Well I think it could be useful for me - but I don't know what the priorities are for the BJS team. I do believe that, as I said above, it could be useful for environmental and atmospheric sounds - so a variety of gun/weapon sounds, or wind, or doors opening and closing etc. - which can be important in some types of games. I also think it might be useful in short dialog/conversation events. Here is a simple example that I created with howler.js. Imagine the back streets of Victorian London : 5 Sounds It uses one sound file containing 5 different sounds - a church bell, a foghorn, a woman's scream, man's heavy footsteps and finally a woman's footsteps. Click on the red box 5 times and you can play the 5 sounds individually. On the sixth click sounds 4 and 5 are played together - followed by sound 3. By using the "sound sprite" mechanism, you end up with an atmospheric effect for those backstreets. Now I suppose you can do this with separate audio files - but the scream is only 1.2 secs long. This all stems from watching conference videos about narrative and atmosphere in video games. Anyway, you and DK will decide one way or another. So thanks again for listening. Bonne année!! cheers, gryff Quote Link to comment Share on other sites More sharing options...
davrous Posted January 4, 2016 Share Posted January 4, 2016 Yes, you can do the same thing with separate files but I understand audio sprites could be useful and optimized to reduce the number of http requests.Will have a look to see if it's easy to implement or not. Anyway, it looks fun to code this feature, so I'll probably do it. David gryff 1 Quote Link to comment Share on other sites More sharing options...
gryff Posted January 4, 2016 Author Share Posted January 4, 2016 Thank you David. And as they say, "You are a gentleman and a scholar". Having read you blog about the "Breakout" game and the challenges it presented, I'm sure you will find a way to implement this sprite feature without too much difficulty. cheers, gryff Quote Link to comment Share on other sites More sharing options...
JCPalmer Posted January 4, 2016 Share Posted January 4, 2016 Remember that SSSynthesiser, by Surikov? I do not know why a non-file based use of Web Audio would need to only loop part, but he did it.https://github.com/surikov/SSSynthesiser.js/blob/master/SSSynthesiser.js I had partially converted it to typescript/BJS when I noticed the loopStart / loopEnd properties on audioBufferSourceNode. That looks like it might be the way to implement. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.