Retrieve Chord Names

• Sep 23, 2011 - 18:50

How can I RETRIEVE the text objects that denote Chord Names? There is Cursor.putStaffText(text), but what is the reverse method?


Comments

There is currently no way to get the chordnames via the plugin framework. The only possible thing is to add a chordname via chord.addHarmony(). The harmony object exists though. PutStaffName is different and used only for "meaningless" text.
If I understand your project well, you want to write the notes from a chorname in the staff right? What's your plan exactly once you'll have the chordname, especially if it was only text.

In reply to by [DELETED] 5

You understand me well: I want to upload a lead sheet onto MuseScore, and then turn the 'meaningless' chord names into real piano chords. It would be easier for me to play notes, rather than something like 'C9b5'.

So the question is now: How can I attach manually a textual chord name to a lead note, in order to change it into a Harmony object? And what's a Harmony object anyway? Does MuseScore play it, or is it kept silent for later use?

Thanks.

In reply to by [DELETED] 5

There are any number of things for which I could also use access to info about chordnames, and simple text format would be fine . Two immediate applications that come to mind are export to ABC and to iReal b. For iReal b, that would almost be enough; I think repeats and voltas would also be needed to be useful, and other text elements would be nice too of course. For ABC, I'd eventually want everything, but for basic lead sheets and for things like the teaching materials I typically put together, again, I think I could go a long ways with just chordnames and repeat info, and other text elements if possible.

The trick with chordnames, I imagine, is that it probably isn't represented as a text string, but as an ID number that is output according to rules in the chordname style XML file. But if there is already code to "flatten" the chordname output for MusixXML export, I'd take that. Another complication would be the fact that we can now attach chordnames to beats instead of just to notes, and I have no idea if you guys have worked out a way to carry that forward into 2.0, and how that might play with the plugin framework if so.

The only way I have found to get this to work from within a plugin is to

1) export the score to an XML file
2) read the xml file, parsing the harmony and associated tags such as root-step, root-alter, kind and kind-text
3) keep track of which notes/rests have chords associated with them
4) iterate through the score, adding the new info back to the score

I'm using this approach for a plugin I am developing for displaying autoharp appropriate chords for lead sheets.

It's not very elegant but this is the basic structure I use -

var textStream = new QTextStream(file1);

while (!textStream.atEnd()) {
readMe = textStream.readLine();

if (readMe.indexOf(' -1) {
//code here as needed
}

In reply to by rmcallaghan

I've developed a similar plugin - it reads the xml-File, extracts chords and melody and generates a new text file for use with another program (impro-visor) for playalong. The text-parsing could be taken from this plugin. Than you have only put back the info into the score instead writing a text-file.

In reply to by JazzClub

After I failed using QT XML objects, I tried rmcallaghan 's way (thanks), and yes, it works, though it's a little tedious.

I turned the XML file into an array of objects, each contains a representation of one XML Note/Rest, with zero or more XML Harmony objects. I assume that a lead sheet has only one vocal voice, but long notes can be accompanied with more than one chord.

Now the real work starts, and I really don't know where I'm going to. I already discovered that MuseScore is not bug proof, and that I can find many obstacles on my way.

For now, I try to write the notes from the lead staff back to the piano treble staff. If it succeeds, then the next step would be chords construction. Meanwhile, I attach the script as it is now.

Can you upload your plugin?

Attachment Size
ExpandChords.zip 1.7 KB

In reply to by [DELETED] 5

There are pros and cons for using a plugin. I chose the pros, because I can see the resulting chords actually written while debugging, in real time.

I don't write a new score, but I add a piano part to the original lead score, and that makes a difference.

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