paulrosen / abcjs

javascript for rendering abc music notation

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Changing accent position

jagrg opened this issue · comments

Hi, how can I add all accents above the notes with stem set to up?

X:1
M:4/4
L:1/8
V:1 stem=up
K:C perc
%%stretchlast
Lc2 c2 c2 z2 | Lc2 z2 c2 z2 |

That's not possible directly. You have two choices that I can think of: you can use a different accent or you can do some post-processing programming. So, if it is acceptable to use marcato instead of the accent, you could write !^! instead of L.

Or, if this is for your own website where you can run javascript, you could find those marks after the fact and move them. That could look weird if there isn't room for them already, but you could do something like:

abcjs.renderAbc("paper", abcString, { add_classes: true})`
const accents = document.querySelectorAll('[data-name="scripts.sforzato"]')
accents.forEach(accent => {
  const d = accent.getAttribute("d")
  // d will contain something like "M 71.25 57.792c 0.06 -0.03 0.15 etc..."
  // change the second number to change where the vertical placement is.
})

I don't want to use a different symbol and I wasn't able to get your second solution to work. The accent is always placed at the top left corner with a line connected to the note. Do you have any plans of adding this feature? AFAIK this common practice in the percussion literature. Thanks!

I looked around and I don't see any syntax already existing for specifying this. I can create a parameter, something like:

renderAbc("paper", abcString, { accentsAbove: true })

I'm going to be doing a small release soon and I'll see if I can add that.

In the meantime - are you using chord symbols? If not, you could specify it as " >". (Notice the extra space before the greater than sign.)

Looks reasonable. Were you able to push those changes?