SoundManager2 has irregular latency

Posted by Stefan Monov on Stack Overflow See other posts from Stack Overflow or by Stefan Monov
Published on 2010-03-16T07:29:06Z Indexed on 2010/03/16 7:36 UTC
Read the original article Hit count: 540

I'm playing some notes at regular intervals. Each one is delayed by a random number of milliseconds, creating a jarring irregular effect. How do I fix it?

Note: I'm OK with some latency, just as long as it's consistent.

Answers of the type "implement your own small SoundManager2 replacement, optimized for timing-sensitive playback" are OK, if you know how to do that :) but I'm trying to avoid rewriting my whole app in flash for now.

For an example of app with zero audible latency see the flash-based ToneMatrix.

Testcase (see it here live or get it in an zip):

<head>
<title></title>
<script type="text/javascript" 
src="http://www.schillmania.com/projects/soundmanager2/script/soundmanager2.js">
</script>
<script type="text/javascript">
soundManager.url = '.'
soundManager.flashVersion = 9
soundManager.useHighPerformance = true
soundManager.useFastPolling = true
soundManager.autoLoad = true

function recur(func, delay) {
    window.setTimeout(function() { recur(func, delay); func(); }, delay)
}

soundManager.onload = function() {
    var sound = soundManager.createSound("test", "test.mp3")
    recur(function() { sound.play() }, 300)
}
</script>
</head>
<body>
</body>
</html>

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about soundmanager2