TypeError: Property 'goToSelectionStart' of object Ms::Cursor(0x55d0db053b20) is not a function
I am creating a plugin for Musescore (currently I am using version 2.3.2).
The plugin has to reverse the order of notes in triplets or other nplets of a selection.
I have not tested the algorithm because a blocking error is issued.
You can find the plugin source code in the attached file.
Some parameters are hard-coded in this preliminar version as you can see.
The error is:
TypeError: Property 'goToSelectionStart' of object Ms::Cursor(0x55d0db053b20) is not a function
I think the cursor variable is not good reference.
What is wrong?
(If other errors will be issued after the solution to this I will not open another thread but I will stick with this because I am new to MS plugin development).
Thank you
Attachment | Size |
---|---|
example.qml | 1.04 KB |
Comments
What gave you the idea that such a property or method exists? The plugin edit help for cursor doesn't show it.
Check what other plugins do instead, e.g. ColorVoices:
In reply to What gave you the idea that… by Jojo-Schmitz
Excuse me, but I think there is some misunderstanding. Please check this out:
https://musescore.org/en/plugin-development/cursor-object
As you can see there are such function members for the cursor object. Am I wrong?
In reply to Excuse me, but I think… by P5music
That is for 1.x plugins, as the parent page points out
In reply to That is for 1.x plugins, as… by Jojo-Schmitz
Sorry but that's not the parent page.
As you can see inspecting the url of the link I have posted, it is a general development page about the cursor object.
If I am wrong, I need to know where the MS 2.x plugin development documentation is.
In reply to Sorry but that's not the… by P5music
It is, go to your link, scroll down and click on "up" to see.
But whatever, this is 1.x plugin documentation, and 2.x documentation is entirely inside the plugin edit's help, the 1.x documentation may help at times though, like to understand tonal pitch class
In reply to It is, go to your link,… by Jojo-Schmitz
Ok thank you.
I changed my code for 2.x standard, you can see it as an attached file.
But It does nothing. I select the right notes (no check is performed about the element types because it is a tool for myself, I know that the selection is always right) but they are left unchanged.
What is not right? Is it the because of the algorithm, or other things?
In reply to Ok thank you. I changed my… by P5music
It's better to open a new thread.
In reply to It's better to open a new… by P5music
https://musescore.org/en/node/291358
In reply to Ok thank you. I changed my… by P5music
In your code...
The 'while' is literally comparing the object to itself so it will never be not-equal.
I think you should be looking at the cursor.segment values as the cursor.next() function will step you through the objects.
-Dale
In reply to In your code... : var… by DLLarson
I have changed the code (please see the attachment). Now tick is taken into account,
but now it says that notes is null.
And I do not understand the segment thing.
In reply to I have changed the code: … by P5music
I tried your qml in the latest MuseScore 3 and of course it trips up on the import "MuseScore 1.0".
Have you considered the latest MuseScore version for your work?
I chimed in because I'm new to MuseScore and needed to fix a desired plug-in for my use. In the course of that I learned a few tricks. But it's all 3.0+.
The problem you encountered was due to the assumption that a cursor.element is a chord. There are many kinds of elements (a rest for example).
Rather then using a text narrative to explain, I've attached your example.qml that I reworked some.
I now have it calling "hisPlugin" (that would be mine) instead of "myPlugin" (that's yours.)
This framework works in the latest MuseScore.
As for all the stuff about nplets etc... you're on your own but this should get you started.
-Dale
In reply to I tried your qml in the… by DLLarson
Thank you.
[I am testing it on MS 2.x because a few months ago I tried the new version but it was laggish and unusable.
Furthermore, I am using Ubuntu Studio, and I found MS 2.x installed by default.]
I still do not understand the segment, however I updated the while cycle with the type check as in your example. (Please see the attachment)
But very strange things happen.
I tested it on 4 triplets and after the plugin run the notes sounds as expected, that is in reverse order within each triplet.
-A 5th triplet is involved too, in the next measure, but it is unwanted effect, the processing exceeds the selection.
-The first 2 triplets are unchanged as it comes to appearance, while the 3rd and 4th triplets are completely altered (notes are spread too much, although they sound as they should).
If I save the score, the next time I open it I see that the appearance has not changed (so the first 2 triplets are in the original form, the 3rd and 4th have the spread notes), but this time the first 2 triplets play the original notes (not reversed) and the 3rd and 4th plays the spread notes (and the 5th too).
It seems that both my algorithm and the plugin mechanism have some problems.
In reply to Thank you. [I am testing it… by P5music
I'm going to suggest you start a new thread restating the issues and attaching updated readable code.
IMO, you would've been better off migrating your code into my version of your code.
I suggest migrating your work in small testable steps to help you understand the problem you trying to solve with MuseScore. In the programming biz this is called step-wise refinement.
-Dale
In reply to I'm going to suggest you… by DLLarson
That new thread is at https://musescore.org/en/node/291358 ;-)
In reply to I'm going to suggest you… by DLLarson
Thank you for your suggestion.
I am going to continue this discussion in the other thread if you are so kind to follow me.
I will recapitulate the problem with my script and attach the qml.
Please note that the strangeness I have pointed out goes beyond my simple algorithm and you just have to put myPlugin in your Musescore to see that.
I will try also to insert my algorithm in your code. I hope that your version is such that the problems do not occurr.
But it is also worthy to inspect and test my code, I think, by your side.
In reply to Thank you for your… by P5music
So you now want to continue this in https://musescore.org/en/node/291412 I guess
In reply to So you now want to continue… by Jojo-Schmitz
Yes, as the threads I opened deal with single issues now solved, but the linked thread is going to encompass all that will come out from now.