MuseScore icon indicating copy to clipboard operation
MuseScore copied to clipboard

Plugin API: partially restore readScore, closeScore and writeScore

Open dmitrio95 opened this issue 1 year ago • 13 comments

Resolves (partially): #13593

The changes in this pull request partially restores the functionality of the plugins' readScore(), closeScore() and writeScore() functions to the extent that doesn't require changing the current multi-instance logic. With these changes it will be possible to:

  • Use readScore() to open a score in the current window, if it is empty, or in a new window if the current window already has an opened project;
  • Use writeScore() to write the currently opened score;
  • Use closeScore() to close the notation project opened in the current window.

In addition to the limitations of the multi-instance model, there are two more limitations in the proposed implementation of these functions which may be addressed in future (this will probably require changes in the code not related to plugins):

  • The noninteractive flag of readScore() is not currently implemented, addressing this will require changes in the code related to notation projects loading and import;
  • writeScore() can only write the currently selected notation and not other (part and master) scores within the current project, as the export logic seems to rely on Notation and NotationProject objects, while plugins have access only to Score objects.

The proposed implementation, of course, is far from a full functionality of this API but this will still allow the most basic import/export plugins to function.

  • [x] I signed the CLA
  • [x] The title of the PR describes the problem it addresses
  • [x] Each commit's message describes its purpose and effects, and references the issue it resolves
  • [x] If changes are extensive, there is a sequence of easily reviewable commits
  • [x] The code in the PR follows the coding rules
  • [x] There are no unnecessary changes
  • [x] The code compiles and runs on my machine, preferably after each commit individually
  • [ ] I created a unit test or vtest to verify the changes I made (if applicable)

dmitrio95 avatar Jan 03 '24 17:01 dmitrio95

Batch Convert does seem to work fine with this!

Jojo-Schmitz avatar Jan 04 '24 10:01 Jojo-Schmitz

Tested on Win11.

@dmitrio95 @Jojo-Schmitz To what extent Batch Convert and ABC Import plugins should work better than in master?

  1. Using Batch Convert plugin, now it works in Import mode (batch processing of folder with scores) and doesn't work in Export current score and Export opened scores. In master build the plugin doesn't work at all

Screenshot 2024-02-12 190916

  1. Using ABC Import plugin, it works the same as in master (as described in https://musescore.org/en/project/abc-import)

DmitryArefiev avatar Feb 12 '24 17:02 DmitryArefiev

Concerning Batch Convert:

  • Import mode should work as expected at least if no scores are currently opened in the current window (this can be checked by a plugin).
  • The "export current score" mode doesn't work because MuseScore 4 does not support the score.path property that is available for plugins in 3.6.2. This can be corrected either on the plugin's side (by avoiding using this property and exporting the score directly) or on the MuseScore's side by implementing this property.
  • The "export opened scores" may not work for the same reason, although this mode will probably face an additional difficultly because of inability to access scores opened in different windows, and it will likely work effectively the same as the "export current score" mode.

Concerning the ABC Import plugin, it will need to be corrected to re-enable this line which has been disabled exactly because the readScore() API function was not working in MuseScore 4.

dmitrio95 avatar Feb 12 '24 19:02 dmitrio95

rebase needed

Jojo-Schmitz avatar Feb 17 '24 14:02 Jojo-Schmitz

Rebased

dmitrio95 avatar Feb 17 '24 21:02 dmitrio95

@dmitrio95 Sorry for the delay..

Concerning the ABC Import plugin, it will need to be corrected to re-enable this line which has been disabled exactly because the readScore() API function was not working in MuseScore 4.

Can you correct that line so I can check it on my side?

DmitryArefiev avatar Feb 21 '24 16:02 DmitryArefiev

It is in a different repository, @jeetee's

Jojo-Schmitz avatar Feb 21 '24 16:02 Jojo-Schmitz

Here is the modified plugin: abc_import-4.0.0.zip. I enabled back the readScore() call and removed the workaround with copying the path to the imported file. Seems to work fine on my build.

dmitrio95 avatar Feb 22 '24 06:02 dmitrio95

@dmitrio95 Thanks! But when I wanted to check you PR, I found a bug in master branch #21659 which blocking me now..

DmitryArefiev avatar Feb 23 '24 16:02 DmitryArefiev

I guess for now you'd better rebase it to 4.3.0?

Jojo-Schmitz avatar Feb 25 '24 12:02 Jojo-Schmitz

@dmitrio95 please rebase

RomanPudashkin avatar Apr 04 '24 09:04 RomanPudashkin

Tested on Win11.

@dmitrio95 @Jojo-Schmitz To what extent Batch Convert and ABC Import plugins should work better than in master?

  1. Using Batch Convert plugin, now it works in Import mode (batch processing of folder with scores) and doesn't work in Export current score and Export opened scores. In master build the plugin doesn't work at all

Screenshot 2024-02-12 190916

  1. Using ABC Import plugin, it works the same as in master (as described in https://musescore.org/en/project/abc-import)

Hello, can your Batch Convert work normally in import mode? Why do I display error open score in versions 4.2.1 and 4.3.0

yedaming12 avatar May 06 '24 01:05 yedaming12

Because this PR hasn't been merged yet (and needs another rebase)

Jojo-Schmitz avatar May 06 '24 16:05 Jojo-Schmitz