Accessing fingering info during play event

• Jul 22, 2021 - 10:46

Is there a way I can access fingering information (number and offset) defined on a note during play? I found some hints from Seq::playEvent, where the data structure elements are being accessed in the following manner. However, I could not find any specific instance in the entire codebase that access fingering numbers.

Staff* staff      = note->staff();
Instrument* instr = staff->part()->instrument(note->chord()->tick());
const Channel* a = instr->channel(note->subchannel());

From the XML structure, I can see that the Fingering element is defined within the Note datastructure.

<Chord>
<durationType>quarter</durationType>
<Note>
  <Fingering>
    <offset x="2.54236" y="0.508471"/>
    <text>1</text>
    </Fingering>
  <pitch>60</pitch>
  <tpc>14</tpc>
  </Note>
</Chord>

I tried to access the fingering info using note()->fingering()->text() - but obviously it did not work. I also see that fingering element has a public method note() to get the parent note, but not the other way around. That is, given a note, find the fingering element associated with it. Any pointers will be greatly appreciated.


Comments

In reply to by jeetee

@jeetee - Thanks a lot. I had to do a dynamic_cast to derived types due to class inhertance (Fingering->TextBase->Element) and essentially the list given by el() was an Element list. Now, I am able to use plainText() to get the finger number specified in the score.

The only issue that I am struggling with right now is to determine fingering visibility. When Visible checkbox for the Element in the Inspector panel is set, I am able to query fingering visibility for each note using Element->visible(). However, I came across the following line, which seems to globally disable fingering.


bool tabFingering = note->staff()->staffType(note->tick())->showTabFingering();

If this is not, then is there indeed a global option that can disable fingering on the whole score? Also, if you can guide on what function call can be used to check such global option, it would be really helpful. Although, at a feature level the functionality is working - I just want to guard against any global settings.

Thanks again for patiently guiding me.

In reply to by svanimisetti

> "I came across the following line, which seems to globally disable fingering"
It is not a global setting, it is a setting specific to Tablature staves. As those staves already show which fret on which string to display numerically, it is highly unusual to also show addition normal fingering elements on them (which might be confused for notes if not styled special).

In reply to by jeetee

Ok. Everything is working fine now. I am ignoring any global settings - and just checking if the note is visible for now. There are two remaining questions I have for which your suggestions are welcome.
1. How can I find if the note is the beginning or ending of score (first and last note)?
2. How can I determine if a note is on the bass or treble clef? I see note->staff(), but is there a property from Staff class that I can use to determine if its bass or treble?

In reply to by svanimisetti

1a.) score.firstSegment(), then check SegmentType for ChordRest, use segment.next until you find one. Then use elementAt to get the actual Chord/Rest there to see whether it was a rest or a note
1b.) score.lastSegment then as above but now using segment.prev

2.) Not really, as clefs might change throughout a score. But if you wish to differentiate between the top/bottom staff of the instrument, then indeed check the staff and/or track for a note (if you use a Cursor, then that only moves through its assigned track, so you're always within the assigned voice of the assigned staff then).
Although you can also track Clef segments probably..

Do you still have an unanswered question? Please log in first to post your question.