How to write a plugin for Musescore 4?
First of all I'm aware that writeScore() is not working on Musescore4.0 for the time being.
However
I created a directory called "export_midi"
so "....blablabla... Documents\MuseScore4\Plugins\export_midi"
Inside it I put a png called "midi_export.png" and a "qml" file called "export_midi.qml"
This qml file contains these lines (I used the existent plugins to try to follow them and to get sume hint)
import QtQuick 2.2
import MuseScore 3.0
MuseScore {
version: "2.0"
title: "MIDI Exporter"
description: "Export MIDI for REAPER"
categoryCode: "composing-arranging-tools"
thumbnailName: "midi_export.png"
MessageDialog {
id: versionError
visible: false
title: "Unsupported MuseScore Version"
text: "This plugin needs MuseScore v3.0.5 or higher"
onAccepted: { quit() }
}
onRun{
var s = curScore;
var p = curScore.path;
p = p.slice(0, -5);
p = p.replace(/\//gi,"\\");
writeScore(s, p, 'mid');
curScore.endCmd();
quit();
}
}
When I run Musescore 4 it doesn't detect this plugin.
So I thought it was for the function writeScore() then I commented that line, and restarted Musescore.
But the plugin doesn't pop-up. It's not listed, is not anywhere
I tried to move the whole directory "export_midi" into the main plugin folder of Musescore 4 having the same result: no detection.
What am I missing please?
EDIT
I corrected it implementing the first 3 suggestions I received in the comments. But the plugin doesn't show up. Even commenting or deleting the line writeScore(s, p, 'mid');
Comments
Drop the "Qt." In front of the "quit();"
And add a "curScore.startCmd()"
In reply to And add a "curScore.startCmd… by Jojo-Schmitz
tried both the suggestion but the plugin doesn't show up
run Musescore from command line and You will get some messages.
"var p = curScore path;" is problem. missing dot? "var p = curScore.path;"
In reply to run Musescore from command… by sammik
I put the dot. But it doesn't show-up
In reply to I corrected it. However the… by tormyvancool
see https://musescore.org/en/node/340594 (your own post)
In reply to see https://musescore.org/en… by graffesmusic
Yes I know that post ... but do you mean that even writing plugins (cofrom code) they are not seen at all?
In reply to I corrected it. However the… by tormyvancool
seems to show for me
In reply to seems to show for me by sammik
Stupid newbie question here -- how do I get administrator access to put this in the plugin folder?
In reply to Stupid newbie question here … by duresport
Just don't. Use your own plugin folder.
In reply to Stupid newbie question here … by duresport
don't use it. The plugin folder you have to use is the one on Edit > Preferences > General > Folders
I did use the native folder just to be sure about my code. NOthing else.
Not that's working (I mean: now that MU4.0 is showing up my plugin into the list and I'm able to activate it) I transferred that code into the above directory and it works.
In reply to I corrected it. However the… by tormyvancool
probably needed "id: " too
In reply to probably needed "id: " too by sammik
onRun: {
In reply to onRun: { curScore… by graffesmusic
move curScore.startCmd(); just after onRun{
In reply to move curScore.startCmd(); … by graffesmusic
Did it
But I don't see the plugin, nor clicking on the left menu "plugins" nor from the top -down menu
In reply to probably needed "id: " too by sammik
I added that line but without being successful.
Just to be sure:
I tried with the folder "export_midi" where teh qml and png files are located, on the folder indicated by Preferences > Folders as well as on the root folder C:\Program Files\MuseScore 4\plugins
In both cases: Musescore doesn't show the plugin up
I would suggest you to follow the guidelines for writing plugins for MU4.0.
Second remark: IMO a
endCmd()
is not required for writing awriteScore
, and certainly not without astartCmd()
earlier.That your plugin doesn't popup is normal, it is not a "dialog" type plugin (which is not incorrect if you aim to call it from Reaper).
Maybe could you adapt
In reply to I would suggest you to… by parkingb
I will certainly read the link you shared. thank you for that.
With "it doesn't show up" it means that not only I don't see it into the list of the plugins, but also from the menu, I don't see its name. So how can I"call" it? I'm supposed to start iit manually via a click or even a button from within Musescore
In reply to I will certainly read the… by tormyvancool
I'd suggest you to test it in MS3.6. If it works there, then consider testing it under MU4.0
In reply to I'd suggest you to test it… by parkingb
Well this was working on MS3.6 and very well.
But now, trying to import it, it's not visible nor in menus nor in plugins
In reply to Well this was working on MS3… by tormyvancool
I uploaded working (well, I didnt test, how plugin work itself, but it apears in plugin list) version above https://musescore.org/en/node/340725#comment-1161213
Did You miss it, or it is not shoving too?
In reply to I uploaded working (well, I… by sammik
It was not showing up.
What I did now, in order to spot any error from my side, is to copy and paste (a duplicate ) of a simple working plugin.
I changed the names of the pasted folder and the files inside.
I edited it and line by line copied and pasted it from my plugin to the working one,
I wanted to see what was blocking mine.
but all the pasted lines are working. And the "new" plugin is visible.
I still don't know what's causing the real mine one do not be visible.
I even counted the spaces for the ident of each line to be sure is not depending about such thing (like in Fortran :-D )
In reply to I uploaded working (well, I… by sammik
Hi Sammik, so far, is there a list of APIs of MS4.x?
In reply to Hi Sammik, so far, is there… by tormyvancool
Not in my knowlege.
In reply to Well this was working on MS3… by tormyvancool
> It was working on MS3.6
:-/ It must be "It is working on MS3.6".
This is your sole chance of having it working under MU4.0 : A MU3.6-compatible plugin on which you applied the guidelines. If it doesn't work like that, there are little chances that it works on MU4.0.
As for your request about a Plugin API documentation for MU4.x, you must understand that most of the plugin stuff has been out-of-scope of MU4.0. So the best Plugin API documentation around is the one of 3.5 (*) - but nothing prevents you from generating it from the source code.
What puzzles me is why you stick so hard to MU4.0 ? Is your script for your own usage ?
I'm asking because
writeScore
DOES NOT WORK in MU4.0. So how hard you are trying, your plugin will not work in MU4.0(*) you'll notice the doc hasn't been even generated for 3.6
In reply to "It was working on MS3.6" :-… by parkingb
Could you possibly share your script on some collaboration platform (CodeBerg, Github, ...) ?
In reply to "It was working on MS3.6" :-… by parkingb
When the script will work as it should I will share it.
Yes as I said in the beginning, I know that writeScore is not any-longer in use.
I want that script ready for when there will be the writeScore back or a similar function.
The goal of the script, is to export the MIDI file of the score.
Now, today i was able to make it visible from MU4.0 and it works (with the exception the writeScore line.
I will wait for the 4.1, mean while I will use the version 3.6 to work.
In reply to When the script will work as… by tormyvancool
> When the script will work as it should I will share it.
The advantage of sharing it now (even in some limited-audience way) is that we could have a look at it and help you improving it.
But anyway, this is a really trivial plugin. So here you are:
https://gist.github.com/lgvr123/da646ab7bbaafbabf7d6e4379305dadf
Your plugin working in MU3.6, appearing in MU4.0 plugins list and plugins menu once enabled:
In reply to Here you are: https://gist… by parkingb
Please here the link
https://github.com/tormyvancool/MuseScore_for_Reaper
The commented line in to the onRun,(), are blocking the script execution Any of them.
The script is visible since yesterday, as I stated on a previous comment ...
In reply to Please here the link https:/… by tormyvancool
First observation:
might cause an error, because this image file does not exist( at least in your github repo)
In reply to First observation:… by parkingb
Sorry I uploaded it
In reply to Sorry I uploaded it by tormyvancool
I've made a pull request on your repo with a working version.
I've commented out everything that was not necessary (e.g.
import FileIO
,startCmd()
, ...) and what was not supported by MU3.6 (e.g. thequit()
)That version appears in the plugins panel:
And is working (at least opening the DONE dialog box)
However one can observe that the plugin is not able to retrieve the score path, which is similar to what one can observe in other plugins ported to MU4.0: the lack/poor support of the
score
objects.And interesting test to do is to uncomment the
import FileIO
. I guess this line might cause your plugin not to appear in the plugin manager. If this would be the case it worths being added as a new issue.In reply to I've made a pull request on… by parkingb
Hi @parkingb, I merged it.
Well I was able to make it visible yesterday. I described what I did. inexplicably: it was visibile, so from yesterday on I tried to do something. but without anything great since to save/export MIDI is not possible in MU4.0
I tried to use FileIO, startCmd() to verify if there was a kind of workaround but there isn't any.
I noticed also that .slice() and .replace() they don't work. Or so it seems (perhaps because it is undefined?). Hence I commented them
In reply to Hi @parkingb, I merged it… by tormyvancool
> Or so it seems (perhaps because it is undefined?).
Indeed.
curScore.path
returns an undefined string. You've reach the limit of what is working on MU4.0.In reply to > Or so it seems (perhaps… by parkingb
ok so the only one thing I can do now is to freeze the code, and to wait that a 4.1 will bring this functionality back.