abcjs icon indicating copy to clipboard operation
abcjs copied to clipboard

Extra key signature incorrectly inserted

Open chrisspen opened this issue 4 years ago • 3 comments

If your abc has a key change at the beginning of a line, the renderer incorrectly shows the updated key signature at the end of the previous line.

For example, for the abc:

X:1
L:1/4
M:C
K:A
e f g a | !4!b a g f | e f g a | !4!b a g f | e f g a | !4!b a !4!b a | !4!b a !4!b a | !4!b a g f | e4 |]
[K:G] D E F G | !4!A G F E | D E F G | !4!A G F E | D E F G | A G !4!A G | A G A G | !4!A G F E | D4 |]

it's rendered like:

Screenshot from 2021-07-16 21-29-32

Is there any way to stop the duplicate key signature from being rendered?

chrisspen avatar Jul 17 '21 01:07 chrisspen

This is by design.

In "Behind Bars" on page 93: "When a key change coincides with a system break, then cancelling naturals and the new key signature go at the end of the first system".

paulrosen avatar Jul 17 '21 14:07 paulrosen

I've never seen this behavior in any real sheet music, nor even in any other abc renderers. The "|]" terminator implies an end of the bar, so the next bar is a completely separate piece of music. That means there's no key change happening that needs to be incrementally denoted.

If I had used a "||" or some other separator, I'd agree with you. But these two lines are logically completely separate, so duplicating the key signature is necessary.

chrisspen avatar Jul 17 '21 14:07 chrisspen

For jquery a hack,


 var keySignatureLast = false
    $('#cheatsheet_music svg g').map(function(k,v) {
      if ($(v).hasClass('abcjs-key-signature')) {
        if (keySignatureLast) {
          $(v).remove()
          keySignatureLast = false
        } else {
          keySignatureLast = true
        }
      } else {
        keySignatureLast = false
      }
      return true
    })

syntithenai avatar Apr 05 '22 03:04 syntithenai