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

FOO the denominator to prevent negative delays #32

Merged
merged 1 commit into from
Jan 4, 2015
Merged

FOO the denominator to prevent negative delays #32

merged 1 commit into from
Jan 4, 2015

Conversation

ssorallen
Copy link
Contributor

For the first chord it is possible for noteDelay to equal -1 because the
“- 1” is not wrapped in the denominator:

0 + (0 / 6 - 1) = -1

But the intended order is:

0 + (0 / (6 - 1)) = 0

If the AudioContext is created quickly enough its currentTime is 0
during the first calculation, which results in a negative start time and
throws an exception in MIDI.js.

Fixes #31.

For the first chord it is possible for noteDelay to equal -1 because the
“- 1” is not wrapped in the denominator:

    0 + (0 / 6 - 1) = -1

But the intended order is:

    0 + (0 / (6 - 1)) = 0

If the AudioContext is created quickly enough its `currentTime` is 0
during the first calculation, which results in a negative start time and
throws an exception in MIDI.js.

Fixes #31.
@ajacksified
Copy link
Owner

I knew falling asleep during 8th grade Algebra would come back to get me.

ajacksified added a commit that referenced this pull request Jan 4, 2015
FOO the denominator to prevent negative delays
@ajacksified ajacksified merged commit e853c2c into ajacksified:master Jan 4, 2015
@ssorallen ssorallen deleted the fix-31 branch January 4, 2015 10:48
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

Successfully merging this pull request may close these issues.

Some user's songs result in Uncaught InvalidStateError and will not play.
2 participants