Skip to content

Commit

Permalink
Improve BEAN_FOR_FRAME calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
stianjensen committed Jul 26, 2015
1 parent 70827fc commit cb3b1b6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion nin/dasBoot/BEATBEAN.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
};

FRAME_FOR_BEAN = function(bean) {
return ((bean - 1.5) * framesPerBeat + 0.5) | 0;
return (bean * framesPerBeat - 0.5) | 0;
};
};

Expand Down

5 comments on commit cb3b1b6

@sigvef
Copy link
Member

@sigvef sigvef commented on cb3b1b6 Jul 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commit message says BEAN_FOR_FRAME was improved, but the diff touches FRAME_FOR_BEAN.

@sigvef
Copy link
Member

@sigvef sigvef commented on cb3b1b6 Jul 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A description in the commit message of how this calculation is better than the previous one would be nice :) (even if it is just "the previous implementation was wrong -- this one is correct because it does x correctly" or something).

@stianjensen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops. Not the first time today I mixed those two function names.

@stianjensen
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As the next best thing to explaining further in the commit (which I acknowledge I should have done), I discovered that by simply reversing the formula from BEAN_FOR_FRAME, more accurate BEAN numbers were returned from FRAME_FOR_BEAN.

But looking at the results (in a spreadsheet \o/) showed that subtracting 0.5 instead of 1.5 yielded always-correct output, while subtracting 1.5 often missed by one frame.
screenshot 2015-07-27 01 17 58

@sigvef
Copy link
Member

@sigvef sigvef commented on cb3b1b6 Jul 26, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(y)

Please sign in to comment.