Modifying Note Names to identify notes in different octaves

• Jan 25, 2021 - 06:10

Hi all

I've been trying to modify the Notes Names plugin so that I can assign numbers to notes, however for this instrument in question, I'd like to identify notes that are an octave apart. So for example, a low C might have the number 1 assigned to it, but a higher C might have a 1* assigned to it. I've modified the plugin so that it's numbered but the A is assigned the same number regardless of where it is on the staff. Does each note have an id by any chance, that would help me achieve this?

Thanks

D


Comments

This is how I do (I skipped some part of that function related to getting note head, accidentals, ...).
I put that in a note sub object (that I call extname, up-to-you to exploit that as you want)

function enrichNote(note) {
    // accidental
    //  ... skipped...

    // note name and octave
    var tpc={'tpc' : 0, 'name' : '?', 'raw' : '?'};
    var pitch=note.pitch;
    var pitchnote=pitchnotes[pitch % 12];
    var noteOctave=Math.floor(pitch/12)-1;

    for (var i = 0; i < tpcs.length; i++) {
        var t = tpcs[i];
        if (note.tpc==t.tpc) {
            tpc=t;
            break;
        }
    }           

    if (pitchnote == "B" && tpc.raw == "C") {
        noteOctave++;
    } else if (pitchnote == "C" && tpc.raw == "B") {
        noteOctave--;
    }

    note.extname={"fullname": tpc.name+noteOctave, "name": tpc.raw+noteOctave, "raw": tpc.raw, "octave": noteOctave};

    // head
    //  ... skipped...

    return note;

}

readonly property var pitchnotes : [ 'C', 'C', 'D', 'D', 'E', 'F', 'F', 'G', 'G', 'A', 'A', 'B']

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