Wednesday, 25 August 2010

GWT and sound synthesis

I have been a little quite of late. August is meant usually a time when I spend lots of time with the children so is usually a slow month for anything. Weather has not been great this year which has making the usual outside activities a little bit less fun.

I have written a few post which I doubt I will publish. They were really for figuring stuff out in my head. The end result is I am probably going to attempt to make a  little web app in the area of sound synthesis. Although I am not 100% sure on the direction it will take.

So with this in mind I fired up eclipse and have spend a few days attempting to work out how to use gwt to generate and play a sound. Using HTML5 playing a sound is quite simple.

If you want to synthesise a sound first you have to base64 encode the wave file and then attach it as an inlined file. Terminology may not quite correct there as I am still learning all this.

The fun part is you have to actually work out all the headers to wav files for yourself  as Java in GWT does not provide any sound api's to help you. I really just want to say to some api, here is my array of normalised double and this is the sample rate, go play the sound.

I got the code working and the results were a little noisy. I got the occasional spitting like noise on the play back. Not exactly what I wanted. As most of the code had been tested with real Java I was fairly confident in my code and decided to publish it to app-spot (google app engine) on the hunch it was a browser thing.

Turn out I was correct. FireFox on ubuntu plays back the sample with a spitting noise. Chrome make no noise at all, I guess it does not yet support wav files or the HTML5 tag. Opera on the other hand played it back perfectly. On windows FireFox played it back perfectly and I did not test other browsers. No access to a mac to check on those systems.

I am not surprised support is patchy as the Audio tag is fairly new and it maybe I am doing something in an incorrect way.

Here is the link if you wish to hear what I have been up to.

Amazon delivered Essential GWT today so I am going to spend some time studying that book over the next week or so. Will do a mini review once I have read it.

No comments:

Post a Comment