My favorites | Sign in
Project Home Downloads Wiki Issues Source
Main documentation on AS3WavSound
Featured, Phase-Requirements, Phase-Design
Updated Aug 24, 2012 by b.bottema

About this documentation

Documentation for AS3WavSound may seem minimal, but there's a good reason for this.

  • A WavSound object doesn't do anything particular a Sound object doesn't do as well

The WavSound class, AS3WavSound's pivot point, was designed to use the same API as the existing Sound classes and acts exactly the same. In fact, it adds no additional features except the ability to playback WAVE sound data. Therefor it makes sense that no more documentation is needed than Adobe already provides on the entire Sound framework!

Due to limitations of Adobe's Sound framework (specifically the SoundChannel class is made final), backwards compatibility has been dropped, but the WavSound as well as the WavSoundChannel are designed to work exactly like Sound and good old SoundChannel. The intent is to keep the API the same while simply adding Wave sound support. You just can't play mp3 files with this library anymore, because we're not extending the existing sound library anymore.

Transparent API

There is no additional API to the standard Flash Sound API. AS3WavSound simply completely mimicks the existing system.

The reason for aforementioned grade of backwards API compatibility is because AS3WavSound aims to be as simple to use as possible and simply fill the gap of WAVE playback support. Nothing more. Certainly not another library API for users to learn.


public class Demo {
	[Embed(source = "assets/drum_loop.wav", mimeType = "application/octet-stream")]
	public const DrumLoop:Class;
	public function foo():void {
		var drumLoop:WavSound = new WavSound(new DrumLoop() as ByteArray);
		var channel:WavSoundChannel =;

Current state / Roadmap

AS3WavSound is mostly finished except for the following features and remaining bugs:

  1. complete SoundTransform support, such as leftToleft en rightToLeft properties (currently only panning and volume are supported)
  2. streaming support (ie. Sound.load() or Sound.loadWav())
  3. better upsampling algorithm. The current one is a rudimentary one that provides low quality upsampling (quality degrades for lower source rates).

Quick note on the SoundChannel problem

About performance

A performance hit is to be expected the moment one generates sound on the fly using the Adobe sanctioned SAMPLE_DATA event approach.

However, AS3WavSound has completely minimized this hit by pooling all playing WavSounds into a single Sound. In effect, in this fashion always exactly one Sound is really playing samples generated and mixed from all WavSounds active, combined. It is still not as fast as native playback however, in which Flash directly delegates to the sound card.

Some factoids

Comment by, Feb 6, 2011

Hi, how do you stop a sound ?

Comment by project member b.bottema, Feb 6, 2011

The same way you would stop it using a conventional SoundChannel? object.

.play() returns a sound channel, wavSoundChannel.stop() stops the sound instance from playing.

Comment by, Sep 13, 2011

Hi, I need to create an audio Captcha and it appears reCaptcha ( uses Flash for it's audio Captcha's and I would like to mimic this functionality. Since I know nothing about Flash you'll have to excuse my questions. 1. Does your code allow the WAVE file to be loaded dynamically or does it have to be embedded in the SWF file? 2. If it can be dynamically loaded how would one go about doing this?



Comment by project member b.bottema, Sep 13, 2011

Al you need is the bytes that represents the wave data. In the example this is done by embedding the sounds using mimetype "application/octet-stream", but if you would load the sound from an external source, that will work too, as long as you're able to obtain the bytes.

Comment by, Sep 13, 2011

So, using some sort of Flash magic ;-) I would first load the wave file from the url, then pass the loaded file into your thingy which would then render the sound. I really must learn Flash. (I'm a Java guy)

Comment by, Nov 17, 2011

I needed to use your extract() function and get the same results I would get from the Sound.extract() function. It wasn't working out of the box, so I tweaked it a bit and got it operational. Thought you may want the changes I made to update the source, since the comments made it seem as if it was still in alpha.

Updated line 139: var end:Number = Math.min(start + length, samples.length);

Updated line 150: return i - start;

Comment by, May 3, 2012

Hey guys, any idea how do I change the speed of a WavSound? I tried the same approach used for the Sound class, but did not work. Help me please

Comment by, Aug 29, 2012

I needed to change the speed of wavSound too.How to work´╝č

Comment by, Dec 19, 2012

Why is so slow to play the sound and even to stop it ?

Comment by, Dec 20, 2012

Hello. In fact I changed the value of the MAX_BUFFERSIZE in WavSoundPlayer?.as to 2048. The sound start immediately.


Comment by, Dec 20, 2012


How to set the volume ? When I try to associate a soundTransform to the WavSoundChannel > It's not possible because the soundTransform is readOnly...

Comment by, Jan 6, 2013


when a sound is stop, I heard a "crack" in the speakers even if the volume of the wavSoundChannel is set to zero . Can you tell me how to avoid this? thank you

Comment by, May 7, 2014

There appears to be a delay when playing and stopping sounds. This isn't a major issue when playing especially if you're loading an external wav file but when using mouse events to stop a WavSoundChannel there is a significant delay (almost 1 second) between the mouse event and the sound stopping. Is there a way to prevent this?

Sign in to add a comment
Powered by Google Project Hosting