Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fade(start, stop, dur) is sluggish with small values for dur #621

Closed
jaschanarveson opened this issue Sep 18, 2016 · 1 comment
Closed

Comments

@jaschanarveson
Copy link

jaschanarveson commented Sep 18, 2016

In a simple test, i'm fading out my sound 'tester' with a call to

tester.fade(1.0, 0.0, 10)

which should fade it out over 10 milliseconds (ie: really fast!). The fade is audibly MUCH longer than that, though.

Try the attached example with a soundfile of your choice.

<!DOCTYPE html>

<html>

<head>
    <script type="text/javascript" src="howler.js"></script>

    <script type="text/javascript">
        var tester = new Howl({
            src: ['testsound.wav'],
            onload: console.log("loaded tester")
        });

        tester.on('fade', function () {
            tester.stop();
        });
    </script>
</head>

<body>
    <button type="button" onclick="tester.play()">Start Tester</button>
    <button type="button" onclick="tester.fade(1.0, 0.0, 10)">Stop Tester</button>
</body>


</html>

Is there something i'm missing?

@jaschanarveson
Copy link
Author

jaschanarveson commented Sep 18, 2016

Looking at the howler.js source code, it seems like howler's taking the difference between start and stop, dividing that range by 0.01 (ie: multiplying it by 100), and then moving through all those steps with a stepLen length of duration/steps. So, calling fade(1.0, 0.0, 10) gives me the following:

difference: 1.0
steps = difference / 0.01 = 100
stepLen = duration / steps = 10 / 100 = 0.1 ms

...and it looks like JavaScript's setInterval timing method just can't handle sub-millisecond values. Drag.

Are there plans to incorporate High Resolution Time into Howl once it gets further along?

https://w3c.github.io/hr-time/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant