Skip to content

How to align notes with accidentals to equal x position in both clefs? #1610

Closed Answered by TeemuKoivisto
TeemuKoivisto asked this question in Q&A
Discussion options

You must be logged in to vote

Okay I found a solution from the FAQ https://github.com/0xfe/vexflow/wiki/FAQ#how-do-i-align-multiple-voices-across-staves. It seems you have to manually calculate the offset where the notes start.

    const el = document.querySelector('#score')
    const renderer = new Renderer(el, Renderer.Backends.SVG)
    renderer.resize(732, 360)
    const ctx = renderer.getContext()
    ctx.scale(2.0, 2.0)
    const tclef = new Stave(0, 0, 200).addClef('treble').addKeySignature('B')
    const bclef = new Stave(0, 60, 200).addClef('bass').addKeySignature('B')
    const trebleNotes = [
      new StaveNote({ keys: ['g#/4'], duration: 'q' }),
      new StaveNote({ keys: ['b/4'], duration: 'qr' }),
      n…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TeemuKoivisto
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant