CreateJS / SoundJS

A Javascript library for working with Audio. It provides a consistent API for loading and playing audio on different browsers and devices. Currently supports WebAudio, HTML5 Audio, Cordova / PhoneGap, and a Flash fallback.
http://createjs.com/
MIT License
4.42k stars 838 forks source link

IE. Playing a short audio multiple times and overlapping interrupts #244

Open colmandesilva opened 8 years ago

colmandesilva commented 8 years ago

I am building a game and have an issue with IE (10, 11) when playing a short sound clip multiple times so they overlap. The audio seems to override/interrupt. The only workaround I have found is to have multiple mp3 files with the exact same sound and alternate playing them.

lannymcnie commented 8 years ago

You can specify the number of channels when you load the data. Have a look at the registerSound method - it accepts a data parameter that can be the number of channels for the sound. http://www.createjs.com/docs/soundjs/classes/Sound.html#method_registerSound

This limitation was introduced at first to get around limitations in the number of html audio channels, but was left in to artificially reduce the number of playing instances.

colmandesilva commented 8 years ago

@lannymcnie I have indeed looked into the channel parameter. Here is a little snippet:

for(var i=0;i<CONFIG.AUDIO.length;i++){ var id = CONFIG.AUDIO[i].id; var src = CONFIG.AUDIO[i].src; createjs.Sound.registerSound(src, id, 5); }

but it didn't seem to work. The only work around I have found so far is to create copies of the audio file and alternate playing them. It's an ok solution, but not too happy with it.