having fun with code

Particle Balls demo, now with sound!

Last week I read about the SoundManager2 javascript/flash library to manage sounds on websites (I found SoundManager2 while reading about MooSound, a sound management library based in Mootools that I haven’t tried yet.). The library looks very nice. It is pretty small but at the same time it gives you a lot of control on sound playing. You can change the position of the sound while playing, adjust the stereo pan from left to right and much more.

Today I wanted to test this library and I decided to add some sounds to my Particle-Balls demo. Every time a ball hits a wall, a sound plays. To make it more fun, I use the X coordinate of the ball to adjust the pan, so if the ball is closest to he left border the sound will play on the left speaker and same with the right border/speaker. The pan can be adjusted gradually from -100 to 100 (left to right).

Particle Balls
Check the demo here:
http://dev.enekoalonso.com/research/particle-balls.php

Related Posts:

3 Comments to Particle Balls demo, now with sound!

  1. December 29, 2008 at 03:31 | Permalink

    The problem with the javascript/flash library is that under some environments there is a delay between the action and the sound (for example, I’ve tried the demo on FF3/Ubuntu, and the balls hitted the wall but the sound came after a second or so).

    Check Demonstration of Different Ways to Play a Sound from a Web Page to see different ways to play sounds using javascript.

    I like the 4th method, although I remember only WAV files will work on all browsers using this method, which is unlikely. The great advantage of using flash is that it can play MP3, and you can create good controls for using javascript (SoundManager2 is great).

  2. January 2, 2009 at 11:33 | Permalink

    Some time ago I was researching and playing with all of this stuff, and at the end my conclussion was that SoundManager2 is the best solution out there for playing sounds in browsers. In fact I used it on my development version of Artypist (not yet released).

    I don’t know of any other library that works as great as SoundManager2. It gives you great control over sounds being played and it is quite clean.

    I just wanted to point out other methods on the previous comment ;)

Leave a Reply

You can use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Additional comments powered by BackType

About the blog

This is a blog about development, focused mainly on Javascript but also other languages like python, shell scripts and more.

About the author

Eneko Alonso is a software engineer and UI developer with more than eight years of experience in software and web development. He lives in San Luis Obispo, California and works at LEVEL Studios.

Contact Info

Contact Info