Generating arpeggiated chords in plug-in - dox for
I have been tweaking the "Expand Chord Symbols" plug-in by Mark Shepherd. I am now trying to have the generated chords be arpeggiated. A look at a .mscx file shows that I need to have an tag added to the . has a integer that specifies the type of arpeggio.
Mark's code builds chords from an array of MIDI notes. This works fine.
cursor.addNote(midiNotes[0]);
if (!chord.bassOnly) {
for (var j = 1; j < midiNotes.length; j += 1) {
cursor.addNote(midiNotes[j], true);
}
}
I searched the dox for an arpeggio object, but found only Element.ARPEGGIO. I can use newElement(Element.ARPEGGIO) to create an object, but where can I find document on that properties and methods the object has? Element has a "subtype", so I tried adding this after the note loop:
// Arpeggiate the chord
var e = newElement(Element.ARPEGGIO);
e.subtype = 0;
cursor.add(e);
But it doesn't affect the score as viewed or saved.
Mark's code builds the chord using Cursor's addNote with a "true" second parameter. I PRESUME that Cursor wraps the notes in a Chord object. So perhaps my Arpeggio is ending up outside the Chord object.
I thought of newElementing a Chord, and populating it with Notes and my Arpeggio. But both Chord and Note have a number of parameters, which Cursor.addNote take care of and whose initialization isn't clear to me from the dox. Is there some other way of making "easy" Note and Chord objects as Cursor.addNote does?
Or is there a way to ask Cursor for the Chord that it presumably has created?
Comments
You might try managing the onTime's of the notes -- that's what the arpeggio constructs do.
In reply to You might try managing the… by [DELETED] 1831606
I prefer to have the arpeggio visible in the score, and I had trouble making Note objects by hand.
I found a partial solution in a comment elsewhere in Mark Shepherd's code: "cursor.addNote advances the cursor, but cursor.add does not." So I call
- cursor.addNote to specify the notes in the chord (addToChord true on all but the first)
- cursor.prev() to back up the cursor to point at what is presumably the CHORD
- cursor.add to add a newElement(Element.ARPEGGIO) to the chord
- cursor.next() to move the cursor past the chord and ready for what follows
The arpeggios now show up. HOWEVER, they are of <subtype> 0. The dox say that Element objects have a "subtype" property. But logging it says "undefined", even after I try to set it using e.subtype = 2.
The dox have nothing about an object created with newElement(Element.ARPEGGIO), and my new friend Object.keys(e) crashes MuseScore when applied to my ARPEGGIO object.
By grepping the source for some text from the Doxygen, I found the associated .h and .cpp files. I clearly have a some Q_PROPERTY learning in my future, but at least I have a path forward.
In reply to I prefer to have the… by OldBaldGeek
(deleted)
In reply to I prefer to have the… by OldBaldGeek
Hi, I'm delighted you are finding my code helpful. Let me know if you figure out how to add arpeggios, maybe we could add this feature to ExpandChordSymbols. BTW I just posted a new version of ExpandChordSymbols at https://musescore.org/en/project/expand-chord-symbols-notes; if you are working in the source code it might be better to have the newer version. But beware, I split the source code into 2 files, and unfortunately if you are using Plugin Creator, the Reload Current Plugin Source button only seems to reload the main .qml file, it does not reload any subsidiary files.
In reply to Hi, I'm delighted you are… by markshepherd
I'll take a look at your updates at some point, since a merged plug-in may make sense. My current version can either output the chord with a "squiggly line arpeggio", which sounds reasonably guitar-like, or one-note-at-a-time following a rhythm pattern (using your code), which I am hoping to turn into some sort of "picking pattern" based on the pitches of the rhythm pattern (as you do with bass note).
The "squiggly line arpeggio" is currently limited to upward, since I don't see a way to change the arpeggio-style from a plug-in. That limits the ability to simulate strumming, which needs downward as well as upward arpeggios.
My simple note-at-a-time isn't very convincing, since it doesn't let the notes ring. Notating this would be a pain, so I think I will see if sustain pedal can do anything.
The other remaining feature is capo. This is needed because the voicing of an F chord on a guitar is quite different from a D chord played with the capo on the third fret. Unfortunately, it doesn't seem that a plugin can read the capo setting (or much else) from the Style or Properties of a score, so capo position will probably need to be entered on the plug-in's dialog.
In reply to I'll take a look at your… by OldBaldGeek
Any chance such an arpeggiator could be released out? Even if it's in a beta state?
In reply to Any chance such an… by Shabab M.K.
To tell the truth, I never took this any further. As stated in the thread, I got stuck trying to generate notation for convincing strums, and went on to other things.
Attached are my script as I left it, and a sample output from a lead sheet. Have fun
In reply to To tell the truth, I never… by OldBaldGeek
Hi!
I found this plugin very useful and interesting, however, when I installed it, it only worked once.
I made a small simple musical snippet to test but without success!
After I closed Musescore and opened it again, it did nothing and presents the error as shown in the attached image. Could you guide me what I'm missing or doing wrong?
Thank you friend!
In reply to Hi! I found this plugin very… by mjbartemusica1
I don’t know anything about the arpeggio stuff, but you could look at my WriteHarmonyVoicings2.qml plugin at
https://musescore.org/en/project/plugin-embellishing-harmony-chord-symb…
This is specifically for 4 note voicings but you could (easily!?) adapt it to whatever many notes you want. And use ReadHarmonyVoicings.qml (in the same file) to build up your table.
In reply to Hi! I found this plugin very… by mjbartemusica1
The PNG isn't an error message: it is normally a warning that there are already notes in staff 2 (possibly generated the first time you ran the script). If you click "OK", it is supposed to delete those notes and run the script, putting new notes in staff 2, and then close the dialog. If staff 2 has notes you want to keep, then click "Cancel" and the script won't run, again closing the dialog.
BUT, with your Plugin.mscz, if I click OK, nothing happens and the dialog stays open.
There is something I don't understand about your chord symbols: if I select the first measure of the score, and press Ctrl-K to enter a chord symbol, it doesn't REPLACE your chord, it adds ANOTHER chord above yours.
My guess is that something about how your chord symbols are represented in the document confuses my script. I looked briefly at the mscx version of your file, but I don't know enough about the format to see what the problem it.
My (minimal) testing was on "lead sheet" style scores: a melody line with chord symbols attached to it. Then add an instrument to hold the notated chords - usually "acoustic guitar" which MuseScore notates as treble clef down an octave, which shows the chords without a lot of ledger lines, and then run the script. The attached My_Plugin.mcsz was generated that way, and I can re-run the script without problem on this file.
In reply to The PNG isn't an error… by OldBaldGeek
Hi OldBaldGeek!
Thanks for the guidance however, the chord symbols I entered are all correct using the shortcut Ctrl K. Also let me know that there is no note on staff 2. As I said, it only worked the first time then it didn't work anymore. I've uninstalled and reinstalled but to no avail! I am very interested in this plugin for teaching purposes.
My hope was that the plugin would transform the figures into arpeggios or guitar fingerings as per the proposal. See attached file that I took advantage of the file you sent me.
See also an example of this work I did in Sibelius 7.5
Friendly hug!
In reply to Hi OldBaldGeek! Thanks for… by mjbartemusica1
If you run the script in MuseScore's Plugin Creator, a lot of debug lines are generated which may help you diagnose issues like this. When I run the script on your Plugin.mcsz, I notice that the chord that shows as "F" in the score is seen by the script as an unparseable "f."
If I delete your f, and replace it with upper-case F, the script runs correctly multiple times. Screen-shots attached below show usage with an arpeggio pattern. (Using "Acoustic Guitar" rather than "Piano" for the second staff would use a more appropriate clef for the guitar notes, eliminating a lot of ledger lines.)
I am sure the script could be changed to deal with this, but I decline to do so at this time. In MuseScore's chord settings, you can disable automatic conversion to upper case, which would at least SHOW YOU the chords likely to choke the script.