Does a webaudio module exist?

Monkey Targets Forums/HTML5/Does a webaudio module exist?

MikeHart(Posted 2013) [#1]
Hi folks,

I want to target mobile HTML5 as a platform and I wonder if someone has created a module that addds webaudio to Monkey with a fallback option for the regular Audio elements that Moneky uses by default. IOS6 supports webaudio now and so does the latest Chrome for Android.

Any info is welcome!

Michael


skid(Posted 2013) [#2]
It's kind of a work in progress:

webaudio.monkey



webaudio.js



MikeHart(Posted 2013) [#3]
Thanks man, i will try that.


MikeHart(Posted 2013) [#4]
Could not get it to play anything. But thanks for the suggestion.


skid(Posted 2013) [#5]
That's a shame.

nSYnth is the project I'm using the above with at moment. Click Play, then use keyboard to play notes, spacebar to toggle the arpeggiator, mouse position to alter the white noise.


MikeHart(Posted 2013) [#6]
I am glad that you got it working.


Shockblast(Posted 2013) [#7]
You can also try using howler.js for the webaudio+fallback to regular audio. I modified the mojo audio module to play sounds and music through howler instead of the regular audio elements.


David Casual Box(Posted 2013) [#8]
Hi there.

We're trying for days to play a sound with no success.
On Safari with an iPhone, the nsynth sample mentioned in this thread is no playing sounds, neither on Chrome.

We tried 4 differents HTML5 audio Javascript libs with no success. The main issue is that the mobile browser check if the sound is play "during a user event", which is not the case when you play a sound using a simple function call.

We tried to play the sound in a real HTML button (in the onClick), then simulate a click on the button with Monkey, just calling a js function (using Fireevent) with no success. It seems the call stack is not trustable for iOS, and this f... b... is not playing the sound...

Any help or advice will help us a lot.


Shockblast(Posted 2013) [#9]
@David

Like I said, I modified the mojo audio module to load and play sounds through howler.js

To unlock WebAudio on IOS6-7 you need to first play a sound through an user interaction. I added an extra function, enableWebAudio(), into howler.js to play a silent sound. Download the modded Howler here:

http://www.shockblastapps.com/files/howler.js

So in your Monkey folder, go to your HTML5 target folder and open html5game.js.
Then go to the 'canvas.ontouchstart' function and call Howler.enableWebAudio(); from there.

This should unlock WebAudio on IOS. Don't forget to import the howler.js file into the MonkeyGame.html. Also you now have to load and play your sounds through howler.js because only the AudioContext in there has been unlocked.

I hope this helps!

EDIT: Fixed the file so that it works with FF 25.
- "noteOn" method calls have been replaced with "start" method calls. This is because the "noteOn" method is deprecated.


David Casual Box(Posted 2013) [#10]
We managed to get sound working on iOS thanks to you Shockblast! Thank you so much, we're quite proud to show this working to our customer!


programmer(Posted 2013) [#11]
Firefox 25 adds Web Audio API support - http://betanews.com/2013/10/29/firefox-adds-web-audio-api-support-minor-tweaks/


Shockblast(Posted 2013) [#12]
Yeah I noticed that FF 25 now supports Web Audio. The howler.js file that I was using did not work with FF 25 but that has now been fixed. You can redownload the file in my previous post and it should all be alright.