Skip to content

fix(alphatex): accept fractional harmonic values - #2941

Merged
Danielku15 merged 1 commit into
developfrom
fix/2896-alphatex-fractional-harmonic
Oct 8, 2026
Merged

Danielku15 merged 1 commit into
developfrom
fix/2896-alphatex-fractional-harmonic

Conversation

@Danielku15

Copy link
Copy Markdown
Member

Note

AI-authored disclosure (alphatab-ai-authored-v1)

Portions of this content were authored by an AI agent. The agent has read
AGENTS.md and the human submitter accepts responsibility for
compliance with the rules in that document.

Issues

Fixes #2896

Proposed changes

#2896: the alphaTex exporter writes fractional harmonic values as they are, e.g. {ah 2.4}, but the importer rejects that output with AT206/AT202. Guitar Pro uses such values (2.4, 2.7, 3.5, 8.5, …), so these scores cannot be loaded again after an export.

The alphaTex lexer reads 2.4 as 2, ., 4, because <fret>.<string> depends on that. An argument is only read as a float where its parameter is declared as one (RequiredAsFloat/OptionalAsFloat). The value parameter of ah, th, ph, sh and fh was declared as a plain Optional (integer). The importer therefore read 2, and the . that followed broke the property group.

The fix declares that parameter as OptionalAsFloat, as fermata length already does, and regenerates AlphaTex1LanguageDefinitions.ts. The lexer, parser, importer and exporter are unchanged.

Input Before After
3.3{ah 2.4} (same for th, ph, sh, fh) AT206 + AT202 harmonicValue = 2.4
3.3{ah 7} 7 7 (unchanged)
3.3{ah} unchanged unchanged
Export → import with harmonicValue = 2.4 fails round-trips

Tests

  • AlphaTexImporter.test.ts: new harmonic-values-fractional test. It imports one fractional value for each of the five harmonic types and checks type and value, then exports and re-imports. It fails before the fix with the errors from the issue.

The TypeScript, C# and Kotlin builds and test suites pass.

Checklist

  • I consent that this change becomes part of alphaTab under its current or any future open source license
  • This PR is linked to an accepted issue (see above)
  • Changes are implemented
  • New tests were added
  • I have read AGENTS.md if an AI helped draft any part of this PR

AI authorship disclosure

  • No AI agent authored any part of this PR (description, code, tests, or commit messages)
  • An AI agent contributed to this PR. The AI-authored disclosure block
    (alphatab-ai-authored-v1) is present at the top of this body, and I have
    personally reviewed every change and can explain each one

Further details

  • This is a breaking change
  • This change will require update of the documentation/website

The value of ah/th/ph/sh/fh was declared as an integer parameter, so a
fractional value like {ah 2.4} written by the exporter failed to parse
on re-import (AT206/AT202). Declare it as an optional float.

Fixes #2896
@Danielku15 Danielku15 self-assigned this Oct 8, 2026
@Danielku15
Danielku15 merged commit a6a38af into develop Oct 8, 2026
6 checks passed
@Danielku15
Danielku15 deleted the fix/2896-alphatex-fractional-harmonic branch October 8, 2026 12:39
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.

AlphaTex export → import round-trip fails when a note's harmonicValue is fractional (ah / fh)

1 participant