question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Wrong key signature(After setting drawFromMeasureNumber)

See original GitHub issue

The treble clef is displayed at the beginning of the score, and then there is a treble clef at the end of the 8th bar. Normally, the 9th bar should be the treble clef, but when I cut from the 9th bar, the treble and bass clef is still displayed.

correct performance:
osmd.setOptions({
  drawFromMeasureNumber: 5,
  drawUpToMeasureNumber: 0
})

You can see that in the 9th bar here, the left and right hands are all treble clefs. image

Note: There is a treble clef at the end of bar 8

wrong performance:
osmd.setOptions({
  drawFromMeasureNumber: 9,
  drawUpToMeasureNumber: 0
})

The left and right hand display in section 9 here is incorrect. image

I think it may be that after setting drawFromMeasureNumber , the calculation of the clef did not consider the information of the previous section.

file: quanwu.xml.zip

Issue Analytics

  • State:open
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
rianlucommented, Nov 2, 2021

when the clef is in the middle of the bar, I can’t get this information. Is there a related API to get it?

@rianlu In that case, the clef (ClefInstruction/AbstractNotationInstruction) is not in FirstInstructionsStaffEntries, but in another staffentry -> staffentry.Instructions. So, you have to loop over sourceMeasure.VerticalSourceStaffEntryContainers and then over verticalSourceStaffEntryContainer.StaffEntries, which have Instructions, and check if one of these is a KeyInstruction.

Thanks for the answer, now I have solved the problem! On the basis of the previous, I added a new method: checkMiddleClefByMeasureIndex(measureIndex)

forMeasure:
for (let measureIndex = start - 2; measureIndex >= 0; measureIndex--) {
    ... ...
    for (let j = 0; j < lastInstructions.length; j++) {
        ... ...
    }
    // 检查小节中间的谱号
    checkMiddleClefByMeasureIndex(measureIndex)
    if (updateClefObj !== undefined && updateClefObj.leftClef !== undefined && updateClefObj.rightClef !== undefined) {
        break forMeasure
    }
}
  
// new method
/**
 * 检查小节中谱号信息
*/
function checkMiddleClefByMeasureIndex(measureIndex) {
    console.log(measureIndex)
    const sourceMeasures = osmd.sheet.sourceMeasures
    if (sourceMeasures === undefined || measureIndex >= sourceMeasures.length) return
    const measure = sourceMeasures[measureIndex]
    const containers = measure.verticalSourceStaffEntryContainers
    if (containers === undefined || containers.length == 0) return
    forContainer:
    for (let i = containers.length - 1; i >= 0; i--) {
        const staffEntries = containers[i].staffEntries
        if (staffEntries === undefined) continue
        for (let j = 0; j < staffEntries.length; j++) {
            const staffEntry = staffEntries[j]
            if (staffEntry === undefined || staffEntry.instructions === undefined) continue
            const instructions = staffEntry.instructions
            if (instructions === undefined) continue
            for (let k = 0; k < instructions.length; k++) {
                if (instructions[k].clefPitch === undefined) continue
                const clefType = instructions[k].clefType
                const line = instructions[k].line
                if (clefType === undefined || line === undefined) continue
                if (updateClefObj === undefined) updateClefObj = Object()
                const tempClef = Object()
                tempClef.index = j
                tempClef.clefType = clefType
                tempClef.line = line
                if (j == 0 && updateClefObj.rightClef === undefined) {
                    // 右手谱号
                    updateClefObj.rightClef = tempClef
                }
                if (j == 1 && updateClefObj.leftClef === undefined) {
                    // 左手谱号
                    updateClefObj.leftClef = tempClef
                }
                if (updateClefObj.leftClef !== undefined && updateClefObj.rightClef !== undefined) {
                    break forContainer
                }
            }
        }
    }
}
0reactions
sschmidTUcommented, Nov 1, 2021

when the clef is in the middle of the bar, I can’t get this information. Is there a related API to get it?

@rianlu In that case, the clef (ClefInstruction/AbstractNotationInstruction) is not in FirstInstructionsStaffEntries, but in another staffentry -> staffentry.Instructions. So, you have to loop over sourceMeasure.VerticalSourceStaffEntryContainers and then over verticalSourceStaffEntryContainer.StaffEntries, which have Instructions, and check if one of these is a KeyInstruction.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Wrong key signature - MuseScore
I have a piece of music I imported using the abc plugin. It is fine, except it has a D key signature when...
Read more >
"Wrong" key signature for a score in F dorian? - Music
Upon listening to it, F minor is the tonic chord. It does have Dorian characteristics like you say, namely a major IV chord...
Read more >
Lead sheet has wrong key signature - PG Music Forums
Two options present in BIAB when you change key signature ... The "Key" setting is located as shown below (if you have BIAB...
Read more >
How to resolve the error: gpg: bad data signature from key ...
I'm seeing the same issue after upgrading to 2.2.9 on macOS. – nburr. Jul 25, 2018 at 4:18. 4. Also seeing this on...
Read more >
Key signature doesn't match the chords shown - iReal Pro
In case (for example) you have a song in C but the default key signature shows D, you need to set the default...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found