Repository navigation
feat: keep the sharp or flat spelling of tunings - #3020
Merged
Merged
Conversation
Introduces the public SpelledPitch (step, alter, octave) as the single representation of a written pitch and uses it for parsing and spelling resolution: - ResolvedSpelling is replaced by SpelledPitch, resolveSpelling returns it. - TuningParseResult/TuningParseResultTone are replaced by PitchParseResult returned by ModelUtils.parsePitch with unchanged acceptance rules. The Note.tone/Note.octave values derived from it are unchanged. - Duplicated step and accidental tables are folded into SpelledPitch. - resolveSpelling no longer allocates closures for candidate lookups. - Tuning.noteNames, getTextForTuning and getTextPartsForTuning are deprecated with unchanged behaviour. Refs #2802
Tuning.spellings holds the written pitch of every string next to the tuning values, null when the spelling is unknown. Tuning.getSpelling returns the stored pitch while it matches the tuning value and the flat spelling otherwise, so code changing the tuning values keeps working. The serializer generator now emits a non-null assertion when reading a nullable array of own types without add method. Refs #2802
\tuning stores the written pitch of every string, the exporter writes the tunings with their spelling. Tunings without known spelling are exported with flats as before. Refs #2802
staff-tuning keeps tuning-step and tuning-alter as the written pitch of the string. Fractional alters keep their tuning value without spelling. Refs #2802
The score tuning and the inline tuning show the written spelling of every string with the accidental drawn from the music font next to the step letter. EngravingSettings.tuningGlyphAccidentalScale controls the size of the accidentals. Refs #2802
- Kotlin: indexed DoubleList.map and List.slice(start, end). - C# and Kotlin: Number.isInteger. - The MusicXML tuning parsing avoids optional chaining across several members which Kotlin does not short-circuit. Refs #2802
…itar Pro Guitar Pro 7 and 8 store one sharp or flat choice per tuning: the Flat element of the tuning and the TuningFlat property are written for flats and omitted for sharps. The importer spells the strings accordingly, the exporter writes sharps if every string with an accidental is spelled with a sharp. Guitar Pro 6 files have no such choice and keep the flat display. Refs #2802
Arrays of @json_immutable types are read with fromJson and written with toJson per item. Refs #2802
- Tuning.pitches is the stored tuning. Tuning.tunings is derived from it and spells the strings with flats when set. JSON stores the pitches as text like "D#4" and still reads the tunings of earlier versions. - SpelledPitch is an immutable value. - Guitar Pro tunings are spelled with sharps unless the tuning has the Flat element, without distinguishing the format version. - The tuning display writes the accidentals as text characters instead of placing music font symbols, the tuningGlyphAccidentalScale setting is removed. - C# tests can expect exceptions with a message. Refs #2802
color-performance compares the colored and the uncolored reference on every render and fails after all renders, so a mismatch of the colored reference no longer hides the uncolored one.
The visual tests register Noto Sans Math and Noto Sans SC and add them to the font families, so the CJK texts and symbols like arrows no longer fall back to fonts installed on the machine.
7 of 9 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 #2802
Proposed changes
Tunings keep the sharp or flat spelling of every string (
F#3vsGb3) from import to rendering and export. The tuning display shows the accidentals as♯and♭.One representation of a written pitch
SpelledPitchis an immutable value: step, alter and octave, plus the derived MIDIvalue.TuningParseResultandResolvedSpellingtypes and their duplicated lookup tables.ModelUtils.resolveSpellingand the newModelUtils.parsePitch(same acceptance rules as before) return it.resolveSpellingno longer allocates closures for its candidate lookups.Tuning model
Tuning.pitchesis the stored tuning.Tuning.tuningsis derived from it; setting it spells the strings with flats, as before.pitchesas text ("D#4") and still reads thetuningsvalues of earlier versions (@json_read_only).@json_immutablevalues.Formats
\tuningkeeps the spelling as written and exports it back.Flatelement is spelled with flats, all others with sharps. This was checked against Guitar Pro 8 files saved with sharp and with flat display.tuning-stepandtuning-altergive the spelling.Rendering
♯ ♭ 𝄪 𝄫.Other
DoubleList.mapandList.slice(start, end).Number.isIntegerin the C# and Kotlin runtimes.Expect(Action, string).Tuning.noteNames,getTextForTuningandgetTextPartsForTuningare deprecated and unchanged.Behaviour notes (also in the release notes)
Tuning.tuningsin place no longer changes the tuning; assign a new array instead.pitchesinstead oftunings.Reference images
Tests
SpelledPitch, the tuning pitches and their JSON form, alphaTex, Guitar Pro 6/8 and MusicXML import and export, and the round trips.Checklist
AI authorship disclosure
(
alphatab-ai-authored-v1) is present at the top of this body, and I havepersonally reviewed every change and can explain each one
Further details
website/