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

FIX #2645 Better Faux Pickup Support #4068

Merged
merged 5 commits into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion js/blocks/MeterBlocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@ function setupMeterBlocks(activity) {
*/
flow(args, logo, turtle, blk) {
const arg0 = args[0];
if (args.length !== 1 || typeof args[0] !== "number") {
if (args.length !== 1 || typeof args[0] !== "number" || arg0 < 0) {
activity.errorMsg(NOINPUTERRORMSG, blk);
return;
}
Expand Down
3 changes: 2 additions & 1 deletion js/js-export/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,8 @@ class MusicBlocks {

set PICKUP(value) {
const args = JSInterface.validateArgs("PICKUP", [value]);
Singer.MeterActions.setPickup(args[0], this.turIndex);
const validatedValue = Math.max(0, args[0]);
Singer.MeterActions.setPickup(validatedValue, this.turIndex);
}

get WHOLENOTESPLAYED() {
Expand Down
1 change: 1 addition & 0 deletions js/notation.js
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,7 @@ class Notation {
} else {
if (this.activity.logo.runningLilypond) {
obj = rationalToFraction(factor);
if (!obj) return; // Prevent undefined obj error
Copy link
Member

Choose a reason for hiding this comment

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

Maybe print factor to console so we can diagnose why this is happening? Or maybe fix rationalToFraction?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hello, even though i print factor in console, there seems to be some issue in the initial function as while doing so it throws errors, also i did find some potential problems in error handling in rationalToFraction function which are as follows-

  1. Infinite loop risks are there in the while loop in edge cases
  2. there are floating point inaccuracies which might cause very large denominators due to very small values of d
  3. also there could be more improvements in error handling of edge cases such as limiting the maximum number of cases or the number possible

but if i do these changes in rationalToFraction function in js\utils\utils.js file can it cause issues in the software at other places as it is used in a lot of places, please guide me for the same @walterbender

Copy link
Member

Choose a reason for hiding this comment

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

I think all of the changes you recommend for rationalToFraction make sense regardless of where it is used. Best to address the problem at its source.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have updated the rationalToFraction function kindly review it and please let me know if this is good or require some additional changes as after testing this it seems to work for me with no error in edge cases in the software.

this.activity.errorMsg(
_("Lilypond cannot process pickup of ") + obj[0] + "/" + obj[1]
);
Expand Down