How to access Chord Symbols at a cursor?
I'm trying to access Chord Symbols I've inserted in a staff, but the element.type can't show it, this is my code.
import QtQuick 2.2
import MuseScore 3.0
MuseScore {
version: "3.0"
description: qsTr("This plugin prints chord symbols in the selection")
menuPath: "Plugins.Notes.Print Chord Symbols"
function accessChordSymbols() {
var cursor = curScore.newCursor();
cursor.rewind(0);
while (cursor.segment) {
var element = cursor.element;
console.log(element.type);
cursor.next();
}
}
onRun: {
accessChordSymbols();
Qt.quit();
}
}
I got the message: Running…
Plugin Details:
Menu Path: Plugins.Notes.Print Chord Symbols
Version: 3.0
Description: This plugin prints chord symbols in the selection
Requires Score
Debug: 93
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
Debug: 25
As I know, 93 is chord object, 25 is rest object, there is no harmony object.
Attachment | Size |
---|---|
Screen Shot 2024-08-22 at 5.16.02 PM.png | 15.86 KB |
Comments
Chord symbols are annotations of the segment
miniHarmony.qml
In reply to Chord symbols are… by elsewhere
Revelation!
In reply to Revelation! by nanjingyaoge
With consequences:
https://musescore.org/en/node/307565
(Adding a chord symbol from a plugin at a position where there is no note.)
In reply to With consequences: https:/… by elsewhere
Do you know how to access voices(pitches) of current harmony?
In reply to Do you know how to access… by nanjingyaoge
What notes go with what chord symbol depends on a lot of things…
There is: “Realize chord symbols” with a literal and a jazz style, both very poor and arbitrary in my opinion. See:
https://musescore.org/en/handbook/3/playback-chord-symbols-nashville-nu…
If you want jazz style voicings see:
https://musescore.org/en/node/367174#comment-1253101
If already there chord notes can be read from a plugin:
if (cursor.element && cursor.element.type === Element.CHORD) {
var notes = cursor.element.notes;
ticks.push(cursor.tick);
for (var i = 0; i < notes.length; i++){
pitches.push(notes[i].pitch);
tpcs.push(notes[i].tpc);
}
}
In reply to What notes go with what… by elsewhere
What I'm thinking is that since this chord symbol can produce sound when clicked and played, it means that MuseScore can directly obtain the specific note values from the chord symbol without Realize chord symbols. I'm looking for an API in the plugin that can access these note values.