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

feat(alphaTex): allow specifying tempo as a float in a string #1356

Merged
merged 2 commits into from
Feb 25, 2024

Conversation

jonaro00
Copy link
Contributor

Proposed changes

Stumbled upon a piece that has a BPM of 112.3(!), so I propose this change where the tempo number can also be a float in a string. (using additional dots and number breaks the parser in edge cases)

Checklist

  • I consent that this change becomes part of alphaTab under it's current or any future open source license
  • Changes are implemented
  • Existing builds tests pass
  • New tests were added

Further details

  • This is a breaking change
  • This change will require update of the documentation/website (or leave it as an easter egg :) )

Copy link
Member

@Danielku15 Danielku15 left a comment

Choose a reason for hiding this comment

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

I think it would be more natural for writers to write simply decimals \tempo 144.22 instead of strings.

You can follow the pattern with allow flags to change the parsing logic:

this._allowTuning = false;
this._sy = this.newSy();
this._allowTuning = true;

Then in here you could use a new _allowFloats to read digits and points and then use parseFloat.

private readNumber(): number {
let str: string = '';
do {
str += String.fromCharCode(this._ch);
this._ch = this.nextChar();
} while (this.isDigit(this._ch));
return parseInt(str);
}

@jonaro00
Copy link
Contributor Author

jonaro00 commented Feb 1, 2024

Sounds good! I'll get it done.

@@ -548,7 +549,7 @@ export class AlphaTexImporter extends ScoreImporter {
} else if (this._ch === 0x2d /* - */) {
// negative number
// is number?
if (this._allowNegatives && this.isDigit(this._ch)) {
if (this._allowNegatives) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(we know that a dash is a digit if negatives are allowed)

@Danielku15 Danielku15 enabled auto-merge (squash) February 25, 2024 22:48
@Danielku15 Danielku15 merged commit 7a52218 into CoderLine:develop Feb 25, 2024
4 checks passed
@jonaro00 jonaro00 deleted the tempo-as-float branch February 26, 2024 10:23
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.

2 participants