Plotting accidentals using Abcnotation

32 views Asked by At

We're working on a line generator and using abcnotation with Open Sheet Music Display to render the music on a staff. Our line generation logic is working great, but we're running into an issue with handling accidentals.

If we set the key signature using the "K" setting with a particular key set, say "F", the staff renders the key signature correct, plotting the Bb on the left (see staff in screenshot).

We also have the INITIAL key defaults working, for example, if an Bb is part of our line, it is plotted as a straight B without any accidentals (honoring the key signature).

The problem we're running into relates to the rules of notation - per measure. That is, our line (in abc syntax) is calling for first, and F#, followed by an F natural. However, as you can see in the staff notation, the second F is plotted without the necessary ♮ symbol. So, this reads as F# F# instead of F# F♮.

We've search far and wide for the appropriate setting, but are stuck here.

We could in theory write a lookup table that tracks and checks all key signatures, and the "defaults" per note. But this will create a lot of overhead, requiring every note to be checked, and rechecked per measure.

Does anybody know if abcnotation should be able to handle this, or is this logic we need to maintain in our code?
sample staff notation and code

0

There are 0 answers