MuseScore Example Manager - an extension for LibreOffice

• Aug 9, 2012 - 21:47

As discussed here , I have been working on a system for managing the insertion of notated examples into text documents, using MuseScore for editing the examples and LibreOffice (or, presumably, OpenOffice) for the text documents. I have come up with something that could be generally useful to others, so I thought I'd share it. If I have dotted my i's and crossed my t's correctly, you should be able to download and install this facility as a LbreOffice extension:

http://extensions.libreoffice.org/extension-center/musescore-example-ma…

I posted this as a beta release. It basically works but hasn't been tested thoroughly. So let me know if you run into problems. I know that errors are not handled especially gracefully, and the macro facility in LibreOffice/OpenOffice is actually pretty limiting in this way. But if something that should work doesn't, I will definitely try to fix it.

Here is the full description:

Create musical examples with MuseScore and insert them into your document using this extension. MSCZ files are automatically converted to graphics with hyperlinks to the corresponding MSCZ files, so that if you ctrl-click the graphic example within your document, MuseScore is invoked and you can edit the original example. Changes to the example from within MuseScore can be propagated back to your document.

Examples can also be created from inline ABC source, and ABC can be generated for examples created from MuseScore. ABC can be a convenient way of creating simple examples directly from within LibreOffice, and it also has the advantage of being potentially readable by blind musicians. The ability to generate ABC from MuseScore examples allows you to create documents with notated examples that are accessible to all, with no knowledge of ABC required on your part.

Usage:

Put cursor where you want an example to appear. Click the "MuseScore" button on the toolbar and select an MSCZ file. A graphic representation of the example (with excess whitespace removed) will be generated and inserted into your document with a link to the original MSCZ file. ctr-click the example to edit it further in MuseScore. After editing and saving the example in MuseScore, you can select the graphic in LibreOffice and press the MuseScore button again to update it.

To generate an example from ABC source, simply type your ABC directly into your document, select it, and click the "ABC" button on the toolbar. You will be prompted for a filename to save the converted MSCZ to. Assuming the conversion succeeds, everything from there should work just as if you created the MSCZ file in MuseScore. The ABC source in your document will be replaced by a graphic generated from the MSCZ file, with the corresponding ABC attached to the graphic as the Description. The graphic will be linked to the MSCZ file, allowing you to ctrl-click and edit it further in MuseScore. After editing and saving the example in MuseScore, you can update the graphic in LibreOffice by selecting it clicking the MuseScore button, and update the Description (ABC source) by clicking the ABC button again.

Requirements:

You must first install both MuseScore and Image Magick and make sure the folders containing their executables are in your PATH. Both MuseScore and Image Magick are supported on Windows, MacOS, and Linux. In order to use the ABC features, you must install abc2xml and xml2abc and make sure they are in your PATH as well. Currently, the ABC utilities are provided in executable form for Windows only, but the Python source is also available, and it should be possible to generate executables for other systems.

Credits:

MuseScore Example Manager: Marc Sabatella

MuseScore: Werner Schweer, Nicolas Froment, Leon Vinken, & others

Image Magick: John Cristy, Anthony Thyssen & others

abc2xml / xml2abc: Willem Vree


Comments

MuseScore 1.2
ubuntu 12.04
LibreOffice 3
HP LaserJet 2200

Even with the rough edges, this is pretty bloody wonderful. A few dialog boxes and errors popped up - on initial opening it said that it couldn't open a folder but it did so anyway after pressing the "OK" button and then it said "Read Error" but still worked. After saving a document and then going back to edit it I had to manually switch over to MuseScore once I'd clicked on the link instead of it taking me there directly, but that's not a big problem.

Initial on-screen appearance of my edited document suggested that image quality was a bit grainy but when I printed it out (at 600dpi, default printer settings) the quality was very good.

For anyone who has the same setup as me (ubuntu and LibreOffice already installed) and who is wondering how to install ImageMagick, just go to the ubuntu Software Centre, search for ImageMagick and you won't see it. You will, however, see a list of other applications. Click on LibreOffice, choose "More Info" and scroll down until you see the Add-ons. Check the box that refers to Image software using ImageMagick, scroll back up the page and press the "Update" button.

Thank you, Marc.

In reply to by underquark

Glad it's mostly working for you!

I wish I knew how to make ctrl-clicking a link in LibreOffice actually give focus to MuseScore, but same thing happens to me on Windows 7. When I ctrl-click an example, the score loads into MuseScore, but focus remains on the LibreOffice window. Another oddity I have no control over - ctrl-click only works if the graphic isn't already selected. I could probably fix both issues by not relying on LibreOffice's builtin hyperlink handling at all and instead taking over the actions myself, but I'm not sure I'm ready to do that.

Curious to hear about the errors. When exactly did the message about not being able to open a folder show up? When you first click the MuseScore button (or ABC button), I try to find the folder containing the document itself and open that, but if the document hasn't been saved yet, it just defaults to something like the last folder you used, and if there is a problem finding that folder, I could see getting an error.

"Read Error" is something LibreOffice seems to sometimes display in lieu of a graphic upon initial insert, when a document is first loaded but before it has had a chance to load and render the graphic, or when scrolling really fast. It is replaced by the rendered graphic as soon as possible. Seems to be a "feature" of linked graphics. So assuming this is what you are seeing, it's nothing to be concerned about.

The graphics are generated at 300dpi. It's possible LibreOffice is doing just a quick and dirty downsampling for screen display, but indeed, they should print just fine. If someone really wants 600dpi graphics (I bet hardly anyone could see a difference) you could edit the macros - a search and replace on 300 should turn up the location.

In reply to by Marc Sabatella

Start LibreOffice - new document opens by default.
Click on MuseScore button for the first time - error dialog pops up.
Click on 'OK' - usual folder and file box opens up and lets you select a MuseScore file. It always seems to open at the "Recently used" files.

Clicking on the ABC box does nothing if nothing has been selected (I presume that that is its default setting although might suggest that a dialog box could pop up to tell you to select something). Clicking on it after entering some notes and selecting them brings up the same "folder contents could not be displayed" dialog box and clicking on 'OK' takes me to the Recently Used list and prompts me to select a directory before allowing save.

Yes, the "Read Error" is a LibreOffice feature, I think, and it only appears in the frame of the linked score before it displays.

I don't know how focus is handled - probably each window has a unique identifier or something - but it's not difficult to [Alt]-[Tab] between MS and LO.

Attachment Size
Rubb_Screenshot_MuseScoreDialogError.png 13.76 KB

In reply to by underquark

Thanks for the followup!

I can't reproduce this error on my system (Windows 7), but looking at the source and searching for info online, I am pretty sure I see the problem. Looks like it would affect OS's other than recent versions of Windows (7 and Vista at least), and maybe only with relatively recent versions of LibreOffice or OpenOffice. You'd definitely see an error on the first attempt to press either the MuseScore button or ABC button on a document that has yet to ever be saved, and possibly also subsequent presses of these buttons until the document is saved. The error would be as you say - you'd get a warning about a folder that cannot be opened, and then you'd get a file picker dialog anyhow and all would be well.

Because this is a system-specific issue that I can't test, would you be comfortable with opening the macro organizer/editor (Tools->Macros->Organize Macro->LibreOffice Basic) and trying a couple of things out for me? Actually, on the assumption that you or someone else on Linux or MacOS (not sure about WIndows XP) would be up for this, I'll just describe what I think needs to happen.

From the macro organizer, open My Macros & Dialogs / MuseScore / Examples and edit the userSelectExampleName function. Find the line that reads:

fp.setDisplayDirectory(documentDirectory)

Try changing that to:

if documentDirectory <> "" then
fp.setDisplayDirectory(documentDirectory)
end if

and the error should go away.

The only question is whether the code will even work at all. The idea was to make sure the file picker starts out in the directory the document was saved in, rather than the last used directory as it would normally default to. Maybe that's not always the most desirable behavior, but it's useful if you're working on multiple documents at once and are keeping the examples for each document in the same folder as the document itself. So I added code to do that even though a (known) bug in LibreOffice prevents it from working (or generating an error) on my system.

The test would be to open two or more documents, saved to different folders, and go back and forth between them pressing the MuseScore button in each then immediately hitting Cancel. The file picker *should* default to the appropriate folder for each document. If it continues to default to the same last used folder no matter which document you are in when you press the button, try moving the block of code you just edited down a few lines - say, to right below the statement:

fp.Initialize(args)

Let me know if anyone has success with any of this.

In reply to by Marc Sabatella

That did the trick! with regards to the error dialogue box on initial opening (never mind that I initially made a hash of pasting the code in, created a LibreOffice macro error and had to delete the macro and re-install).

I'll try the other bit (multiple documents, checking the file picker) later.

I note that the generated score follows the rules of the parent document insofar as left margin is concerned but that the right side of the score goes all the way to the right side of the page (i.e. disregards the margin settings).

In reply to by underquark

Cool. Do let me know if the file picker setDisplayDirectory ends up actually working. I'm kind of thinking it feels safer to move it after the rest of the initialize call anyhow. Oh, I have also added an info dialog if you press ABC with nothing selected, and I've made a few other minor cleanups to error handling.

As for margins:

LibreOffice does not automatically resize linked graphics to fit within margins - at least, not consistently or well (sometimes it *does* resize them, but only horizontally and not vertically, which is worse than no resizing at all). I tried having my macros resize graphics to fit, but this ended up being a drag, because different examples might need different amounts of resizing (and some might need none), leading to inconsistent example sizes with no easy way to control this. So I elected instead to make the user create his examples at appropriate sizes in the first place. I recommend creating a template for examples created in MuseScore, with your margins set to be greater than or equal to your LibreOffice margins.

BTW, for examples created via ABC, the macros calculate the page width minus margins and pass appropriate parameters to abc2xml so that the generated examples are guaranteed to fit. But of course, the macros can't control how with you create your examples in MuseScore :-)

In reply to by Marc Sabatella

Yes, it selects the directory/folder in which the document was created and looks for music there.

Regarding image width. As such it sets it up to respect left margin but goes all the way across to right page edge as the width is set to 17cm (I have A4 size pages, porttrait set as default). If I right-click on the image, select Picture -> Type -> Width and check the "Relative" checkbox then this corrects the image width (changes it from 17cm to 100%) and causes it to span from left margin to right margin.

In reply to by underquark

Are you saying that the size of the actual example in MuseScore is being ignored? That is, your example in MuseScore is 17cm (170mm), but when you import it into LibreOffice it comes out larger than that?

I think that either I am misunderstanding you, or I failed to explain myself clearly enough in my comment above. What I am trying to say is that whatever width you want your example to be in LibreOffice, you must make sure the example is that same width in MuseScore. LibreOffice *will not resize it for you*.

A4 paper is 210mm wide, and the default margins in MuseScore are 10mm left and 10mm right. That means your examples are 190mm by default. If you want them your examples to come out only 170mm wide so they will fit in your LibreOffice document, you'll need to increase your margins in MuseScore to 20mm on each side. So that's what I suggested setting up a template to do for you.

In reply to by Marc Sabatella

OK, I got it. MS sets margins to 10mm by default and LibreOffice sets them to 20mm. Your macro places the MS score actual size, left-aligned to the left margin, The user can modify this alignment and appearance of the score in the LibreOffice document in one of the following ways:

1] Adjust the margins in the original MS score (Layout -> Page Settings -> Odd Page Margins -> Left Margin)
2] Adjust the page margins in LibreOffice
3] Right-click on the image score in LibreOffice, choose Picture -> Type and check the box marked "Relative" and ensure that "Width is set to 100% if you want it to fill the page horizontally within the margins.

As a variant on 1] and 2] you could set up either:
4] a template in MS with the margins already set or
5] a template in LibreOffice with the margins already set.

I'm sorry to report that I''ve maybe found another bug. Whilst editing MS and LO documents and playing around with margins etc. I find that LO is not inserting the edited MS score but inserting the older, unedited copy if the file has the same name.

Let me clarify - I create a score in MS called "xxxx", save it, close it. I open LO, click on the MuseScore button and open and edit my score - so far, so good.

Now, I can totally alter the score in MS, save it, return to LO and it's OK. I can then , however, close both applications, open MS and edit the score and close it. When I open LO again and create a new document and then click on the MuseScore button it inserts the previous version of the MS score and not the mew file.

I though that this may be a quirk of ubuntu, of course, where the file exists in memory and where the macro was opening this rather than the real, saved-on-disc file but I restarted ubuntu and the problem persisted. I then double-checked that only one "xxxx" MuseSCore file existed and I noted that several .PNG files (xxxx, xxxx-1, xxxx-2 etc.) had been created. I deleted those .PNG files and this forced the macro to open the actual MS file. So some way of clearing up the debris looks needed so that only the latest PNG file is saved to disc.

In reply to by underquark

Don't be sorry to find bugs! I'm happy to be getting help.

However, I am going to assume that this is with the original 1.0.2 beta (with your edit discussed above, of course)? This should have been one of the bugs fixed in the 1.0.3 version I posted last night. In fact, this same bug is also the reason you were seeing read errors that weren't just brief temporarily flashes as I was thinking you were. The initial insertion code was still left over from my original implementation where you had to explicitly generate graphics from MuseScore via a plugin. I have fixed the macros to (re)generate the graphic as necessary.

So installing 1.0.3 is definitely recommended, although I won't guarantee that thus particular fix didn't introduce some other problem elsewhere, so I still appreciate bug reports!

In reply to by underquark

Just realized there was a very stupid major bug in the beta version where when you first hit the MuseScore button to insert a new example for which you had never previous generated a graphic, you get the "read error" and an empty box until you hit the MuseScore button a second time. That's not how it was supposed to be - only a single press of the MuseScore button should be needed to insert a new example.

So that's probably why you noticed and reported the "read error" whereas I was thinking it was only a temporary fleeting thing. Not sure how I missed that, except that I guess I kept re-using the same examples over and over (the bug doesn't affect an example that has already been inserted in the past) . Anyhow, that will be fixed too.

I've uploaded an update to the beta release. Same link as before, just download the new 1.0.3 version and install it (I guess you are supposed to manually uninstall the old). This fixes the issues discussed here and a couple of others I found along the way.

In reply to by JoeAlders

I'm not understanding your question. What "whole text" are you referring to? And where do you want to post it? Or are you asking me to post something?

Maybe you are saying you'd like to print out the instructions for use that I posted in the initial message of this thread? That should be just a matter of copying and paste from my description into Writer (or whatever) and then printing. But I'd use the description right on the extension main page http://extensions.libreoffice.org/extension-center/musescore-example-ma… rather than the version here on the forum, because I've updated it some to clarify a few points and describe an additional customization.

Not sure if that's really what you're asking about, though.

BTW, I'm pleased to say I've been using this pretty extensively the last several days with no further problems. I have been working on a jazz theory textbook for the past couple of years using a variety of different methods of creating examples, and I already have much of it converted over to my new system. I am also now deep into a couple of new chapters I started just just after completing this extension. It really is a joy to work with if I do say so myself :-).

I've made only minor cosmetic tweaks to the code since posting the last beta. Unless I hear problem reports form anyone else in the next few days, I'll probably just make this a full "official" release soon, as I think it is working as well as it needs to right now.

Subsequent releases will probably add a facility to automatically regenerate and update all graphics and/or ABC descriptions at once, a "play" facility, a facility to export a document in an even more blind-accessible form (with ABC descriptions placed inline with the text), and who knows what else might occur to me.

In reply to by [DELETED] 5

Thanks for the heads up! He actually added the page layout stuff at my request (I took one look at the Python script and realized it would take a while for me to figure out how to implement anything myself), so I knew about it and was already taking advantage of it - it's in the betas I posted. But he added that at v40, and I didn't know about v41, which adds a few more goodies. Got it now!

BTW, another future direction for my extension - Braille output, assuming any of the tools I am seeing out there turn out to be as viable as abc2xml and xml2abc. I realize lots of people will have no interest in the accessibility angle, but I already have the code structured in such a way that the ABC stuff is in a separate module; I'd do the same with Braille.

In reply to by JoeAlders

*You* don't have to use ImageMagick; the macros do that autmatically. The reason the extension needs to use this is to trim the excess whitespace from around your examples. Otherwise, all your examples would be a full page long each, most of that being empty space. The extension trims them down for you. But again, you don't have to do a thing except install ImageMagick. The whole point of the extension is to automate things so you don't have to trim each and every example by hand.

The reason I chose ImageMagick is that it seems to be the most well-established free and open source tool that can do the job automatically. There are one or two others out there, but ImageMagick seems to be the best candidate, so that's what the extension uses. It would be possibly to edit the extension to use a different tool, but I can't see why anyone would want to take the time and effort to do that.

As far as I know, the program you mentioned cannot do the job automatically - you'd have to edit each example by hand. So I don't think it would be possible to modify the extension to use it. Nor would it make sense to - why add a dependency on a commercial product when the extension can do its job better with free and open source tools?

In reply to by Marc Sabatella

O.K. not having ImageMagick on my pc I downloaded it and after first having to download and execute ‘SoftonicDownloader for ImageMagick.exe’,
during installation of the program itself, its installation wizard tried in a very sneaky way to install an extra (unnecessary)toolbar and a (trial)program called ‘regcleaner’. Is tried to persuade you to do this by stating ‘(recommended)’ for both issues. This for me was very annoying and I stopped the further installation process.
I hope that this is not a standard habit for open source programs.

In reply to by JoeAlders

This has nothing to do with Open source software! SoftonicDownloader is a software by Softonic, a company whose business is to install toolbars and others ads. They just repackage imagemagick, and manage to end up in the first result of Google for "image magick", so that "non experimented" users will install it via their "Downloader" and in the meantime they are making money from open source and free software while developers get nothing but bad reviews like yours.

Always get software from the official website and not these aggregator websites. You can download image magick, for free, without ads, and for Windows here : http://www.imagemagick.org/script/binary-releases.php#windows ImageMagick is a very powerful and fine software for image manipulation on the command line. Nothing similar to the proprietary one you refered in a previous post.

See also the story of Notepad++ another fine open source project at the bottom of this page.

I could understand if an open source goes this way, it's the decision of the maker after all and we all need money to par for the food & the bandwith. MuseScore relies on donation for the last one. But in this case, it's a company doing it for a lot of software they didn't create. It's for sure legal if they respect the GPL, but ethically... it's just bad.

In reply to by [DELETED] 5

Well I was apparently misled by that softonic software. I had to download that ‘downloader software’ first. The strange thing is that after I aborted the installation it
is impossible for me to trace that ‘downloader software’ on my pc in order to get rid of this also.

In reply to by JoeAlders

Yes, you do have to be careful. I try to only download programs from the actual project sites wherever possible. Often, that means sourceforge.net, which is also fine.

Wihen installing ImageMagick, it should ask if you want it added into your path. Say yes, otherwise my extension won't be able to find it. Actually, I had trouble with this anyhow and ended up having to edit the path manually, which on Window is done by Computer / System / Avanced System Properties / Environment Variables. I guess you need to edit the path manually anyhow to add MuseScore, too.

I wish this none of this were necessary, but one way or another, thise examples need to be trimmed down to size, and of the various ways that can be done, this is actually the easiest, sicne you pay your pain up front and then never have to think about it again. BTW, there is one other suitable open source command line tool I know of - GraphicsMagick, which apparently was forked from Image Magick some times ago. Some sort of political differences, I guess. Not sure if there is any advantage to me in switching my extension to GraphicsMagick.

For MuseScore 2.0, I might look into adding a command line option to do the trimming automatically when the PNG is generated in the first place. Now that I have a build environment up and running, this seems like a low risk thing I could implement myself. Actually, though, when MuseScore 2.0 comes out, I might switch to using SVG.

Oh, apparently my extension chokes on examples created from ABC on systems in locales where a comma is used as a decimal point. I'll try to have that fixed soon.

I have now posted version 1.0.4 with the remaining bugs I know about (eg, the issue with examples created from ABC on systems where commas are used for decimal points) fixed.

Question for anyone who might consider using this.

[ EDIT: never mind, I think. I have pretty much decided to go through some handstands in my code to make this as painless as possible - no manual editing of PATH or INI files required. But for the record, here's what I was pondering ]

I recognize the installation procedure is more complex than one would like. There is no getting around the need to install ImageMagick (or GraphicsMagick, if I decide to make that change). But needing to edit your PATH is unfortunate.

In a previous set of similar macros, I didn't use PATH at all. You had to edit an INI file by hand, making sure it contained the correct full pathnames where the executables were installed, and then you had to copy that file to a special folder where the extension could find it. And there is no way I know of to include the INI file with the OXT file for the extension itself - it would have to be downloaded separately (although both could be done from the same page). Plus, the code to deal with the INI file was icky and I was glad to be rid of it.

So I thought that using PATH was the lesser of these evils, but am second guessing myself here. What does anyone else think?

I have posted yet another update (1.0.6) . This one eliminates the need to mess with PATH. The first time the extension needs to run any utility (mscore, mogrify, abc2xml, xml2abc), it will prompt you for the pathname. The pathnames are stored in an INI file so you only need to enter them once. It also allows you to use GraphicsMagick instead of ImageMagick if you prefer.

The INI handling is OS-specific and I can test only on Windows. I'd love to hear feedback from MacOS and/or Linux users if it works for you. I realize INI files are an outmoded convention - on Windows too - but it's really the only semi-convenient way LibreOffice macros have for storing info. WIndows at least still has a dedicated place for this kind of user-independent but application-specific data, but I'm not so sure about MacOS or Linux. I'm storing the INI file on both systems as

$HOME/.MuseScore Example Manager/msem.ini

(note the dot in front of "MuseScore Extension Manager).

If I hear a consensus as to a better place to store this file, I'm happy to make the change. Aside from that possible issue, I think these are ready for prime time.

In reply to by JoeAlders

Have you tried it? It's as step by step as it could possibly be now. The first time you run it, it asks you where you have installed the various program it needs, and you simply tell it. Couldn't realistically be any simpler than that. And using it once installed is also as simple as it could possible be: press a button, select an MSCZ, and it gets inserted for you. That could not possibly be any simpler, either. This is the whole point of these macros - to simplify something that otherwise took very many steps.

MuseScore 2.0 will in no way change any of this. Unless, I suppose, it implements an auto-trim option that would eliminate the need to install ImageMagick. So it would save you one minute when you first install it, but I take it you've already installed that, so it's kind of moot. then

Perhaps you are thinking of the Foto Mode feature where you can cut and paste directly from MuseScore to LibreOffice? That's all well and good for simple usage, but the whole point of my extension is to making managing these easier longer term. Consider - what happens if later on you decide you want to edit one of the examples you inserted? You'd have to remember which score had that example in, load the score, find the example, make the change, re-select the region, then repeat the cut and paste. That's what my extension simplifies - just ctrl-click the example from within LibreOffice and it is automatically loaded back into MuseScore, then after editing it, hit a sinlge button and it is automatically updates in LibreOffice. I absolutely guarantee it will never get any simpler than that!

In reply to by Marc Sabatella

All right , I finally installed ImageMagick but they asked to check the correct installing via the windows command prompt (I understood) with two lines:

convert logo: logo miff
imdisplay logo.miff

Could not get through the first line because of some syntax error.
There you are, I am completely lost due to not being familiar with simple msdos commands.
Hope somebody will help me out here?

Moreover:
'The first time you run it, it asks you where you have installed the various program it needs, and you simply tell it.'
Nothing of that kind was asked when I ran it for the first time
Joe.

In reply to by JoeAlders

Thanks for continuing to bear with me! I will walk you through everything else you need to do, step by step. Don't worry, this only needs to be done once, and even then, it won't take but a minute. When you're done, you should find you won't need any instructions at all to actually *use* the extension.

As it turns out, the error you are seeing is a mistake on the part of the ImageMagick folks, and it is harmless. "convert" is also the name of a Windows program, so when you typed what they asked, it tried to run the Windows program of that name instead of theirs. Ignore the error and we'll just assume everything went fine with the installation.

BTW, I assume if you *just* installed ImageMagick, you got version 6.7.9 (it was 6.7.8 when I installed it a few weeks ago).

So let's just go on to the next step: installing the most version of my extension. It looks like perhaps you have already installed it, but that was an older version, from a couple of days ago? If so, you will need to uninstall it. Go to Tools->Extension Manager, click MuseScore Example Manager, and hit Remove. Then install the latest version.

At that point, the next time you start up LibreOffice Writer, you should see a new toolbar with two buttons on it: "MuseScore" and "ABC". By default, it will probably show up somewhere near the top left of your screen, but you can drag the toolbar elsewhere if you prefer.

I'm guessing you don't care about the ABC features. That's great - it means all you will ever need to do to use the extension after today is press the MuseScore button.

To get started, open a document, and press the MuseScore button to insert an example. Up pops a dialog asking you what MSCZ file you want to insert. Find and select one.

At that point - and I cannot emphasize strongly enough that this will only ever happen *once*, and after that you'll never have to worry about it again - you will see a series of two more dialog boxes. The first will ask you where you installed MuseScore ("mscore"), and the other will ask where you installed ImageMagick ("mogrify"). Assuming you have a typical modern Windows installation, just copy and paste the following text.

For the mscore dialog:

C:\Program Files (x86)\MuseScore\bin\mscore.exe

For the mogrify dialog:

C:\Program Files (x86)\ImageMagick-6.7.9-Q16\mogrify.exe

If you have an older / 32-bit computer system, you might not have the "Program Files (x86)" folder, so instead use the following:

C:\Program Files\MuseScore\bin\mscore.exe

and

C:\Program Files\ImageMagick-6.7.9-Q16\mogrify.exe

If you installed ImageMagick more than a couple of days ago, you might have 6.7.8 like I do, so change the "9" in the above to "8".

Once you have entered the info into those dialogs, the music from the MSCZ file you selected will then be inserted into your document, all nicely trimmed down to size, and you will be done with the installation. I am sorry that it is necessary to manually enter the location for mscore and mogrify, but again, once it is done, it is done.

Actually *using* the extension is much simpler. The following are all the instructions you should need:

To insert an example at the cursor location, press the MuseScore button and select a file. The example will be inserted and trimmed down to size for you.

To edit an example, make sure it is not already selected, then ctrl-click it, then switch to the MuseScore window. You should find the example has already been loaded for you.

To update your document to use an edited version of an example, make sure to save your changes in MuseScore, then switch back to LibreOffice, click the example, and press the MuseScore button. The edited example will replace the original version into your document.

In reply to by JoeAlders

Marc, I do not want to be a pain in the neck but after downloading your latest version of MuseScore Example Manager 1.0.6 as a .zip file and after unzipping it, there are a lot of files and folders but which one do I have to install via Tools>Extension Manager?
Joe.

In reply to by Jojo-Schmitz

I worked my way through that document. It says that I have to look for an .oxt file.
Nothing of that kind in the .zip file. It is clear that I do not understand something
vital in this whole matter. Getting a little desperate here.

In reply to by JoeAlders

Don't worry about being a pain - I want to make things as easy as possible (my whole reason for creating the extension in the first place), so if things don't go as smoothly as they could, I do want to know.

Anyhow, where did you download this ZIP file from? The only ZIP file is the one I posted here in the thread last night that contains bug fixes for Linux users. You shouldn't need that, but if you did already download it, just rename it to end in ".oxt" instead of ".zip". If you downloaded from http://extensions.libreoffice.org/extension-center/musescore-example-ma… (scroll down to the bottom of the page, right below where is says Current Release in big bold letters) then it should already be ".oxt" and not ".zip".

In any case, there should be no need to unzip anything. Just double click the downloaded ".oxt" file in Explorer and it should install itself - it will fire up LibreOffice and the Extension Manager and confirm that you want to install MuseScore Example Manager. Say yes, then when it is done, close LibreOffice. It also should install itself automatically if you had choose "run" instead of "save" when downloading from the LibreOffice site.

In reply to by Marc Sabatella

An issue has been reported that affects some Linux systems; it might affect MacOS too. Symptoms could be spurious error messages or edits to examples not showing up after pressing the MuseScore button. I think that installing the attached should fix it, but I can't test for myself to be sure. Donwload the attachment, change the extension from "zip" to "oxt", and install it. Shouldn't affect Windows users.

Attachment Size
MuseScore-1.0.7.zip 13.96 KB

Marc, I again downloaded that file and it appears again as a .zip file ( do not know why this is so). After renaming it into a .oxt file double clicking on it every thing went as you wrote.
The next step for me is to get started inserting a .mscz file and executing the rest of what you wrote in one of your last answers. I will keep you informed!
Joe.

In reply to by JoeAlders

Great! I assuming that the ZIP file came directly from my post on this thread, here:

http://musescore.org/en/node/17724#comment-64714

And not from the LibreOffice site, here:

http://extensions.libreoffice.org/extension-center/musescore-example-ma…

If you downloaded from the LibreOffice site, right where it says "Get MuseScore Example Manager for All platforms", and you are seeing a ZIP file, then here's what I think may have happened: I think you may have downloaded *both* versions at different times, then when looking for the file later, you found the ZIP version first. Seem possible?

Anyhow, no matter - sounds like it's installed now. Do be sure to close LibreOffice and reopen or else you may not see the new toolbar. Once you do, you should see the MuseScore toolbar, and you'll be all set to complete the installation and start using it!

In reply to by Marc Sabatella

Hi Marc, Everything works fine after I did copy and paste the two text lines for mscore.exe and mogrify.exe.
But after pressing the MuseScore button and selecting a file to insert into the document,
there is no ‘all nicely trimmed down to size’. It overlaps to the right side of the sheet.
I must have forgotten something to do.Can you tell me what that is please?
By the way, ctrl-clicking on the inserted MuseScore pic indeed starts MusScore and the file is already loaded there. Very nice!
Joe.

In reply to by JoeAlders

Glad you got it working!

The extension *trims* your examples (removes all the excess white space so you each example doesn't take a full page), but it doesn't *resize* them. If your example is too big to fit within the margins of your LibreOffice document, it will indeed extend past them. As it says in the instructions, it is up to you to make sure your examples fit. way to do that is to make your margin settings in MuseScore match the ones you are using in LibreOffice, or vice versa.

The way I did this is, I went ahead and created a template that had everything set the way I like (Layout / Page Settings, space=1.8mm, margins=20mm all the way around, all fonts set to MuseJazz, etc). To do this create a new score, get everything how you like it, then select all and hit Ctrl-Del to remove all measures. Save that file, then copy it to C:\Program Files\MuseScore\templates. Now it will show up as a template, and you'll be able to create examples from it from the New Score Wizard in MuseScore.

Actually, what I'm also likely to do is create one example from that template, then, for the rest of the examples in that chapter, I just keep doing a "Save As" to create new ones - it's faster.

I've written five chapters of my textbook so far over the past week or two using this extension. I've probably already broken even on the time it took to develop it :-)

In response to some user comments, and things I noticed in my own usage over the past few weeks, I've posted an update with some small improvements. The most notable is that if you try to insert an example that is too wide for the margins of your document, you will now be asked whether you want to have it resized automatically. Your answer will be remembered, so as with entering pathnames, you only need to bother with this once.

Another improvement for those using the ABC features is that hitting the ABC button to update the description of an example now produces a dialog showing you the results, so you don't have to guess or go out of your way to check whether or not it worked. I've also added some slightly better error checking.

The update is available from the same page as before

http://extensions.libreoffice.org/extension-center/musescore-example-ma…

I still don't fully understand how the update process works, so I'd recommend deleting the old version before installing the new.

Over the past three weeks or so I have used this to create well over 100 pages worth of text and examples for a book I am writing. I have attached an excerpt.

Attachment Size
Excerpt.pdf 760.38 KB

In reply to by ciacnorris

There is a bug that showed up in a couple of LibreOffice versions that caused an error like this. It started somewhere around 3.5.6 but is fixed in 3.6.2 and later.

If you can''t update LibreOffice to something 3.6.2 or later, and have any familiarity with the marco facility in LibreOffice, I can try to direct you to how to edit the code for my extension to workaround the bug - it's just a couple of lines. But there's a whole bunch of fiddling around with dialogs to get to that point, and that's harder for me to explain.

In reply to by Marc Sabatella

Sorry, I didn't see newer versions of LibreOffice were available. I'll update as soon as possible.

In the meanwhile I tried it on Debian Wheezy, it works.
The only (little) problem I found was that it asked me the full path of mscore and mogrify. Luckily I remembered about the "which" command! :)

Maybe a default "/usr/bin/mscore" insted of just "mscore" would help users.

Anyway... this is just the piece of software I had been looking for for months! Thanks!

In reply to by Slasch512

Which error? And it occurs exactly when? That is, what is the last thing you press or click before the error occurs? Wat version of the extension? Did you already go through the steps to install ImageMagick or GraphicsMagick, and point LibreOffice to the various executables?

Yes, this does work once you have it set up, so I'm sure once you provide more information, I'll be able to help you get it running.

In reply to by Marc Sabatella

Hey Marc,
the error is called "an unknown error occured".
I'm running both musescor and libreoffice under Ubuntu 12.04LTS. As you wrote in the Extensions description I should have installed abc2xml and xml2abc, but how do i do this under Ubuntu/Linux? Do I need it at all? ImageMagick and GraphicsMagick is already installed. I tried it with Extension Version 1.0.8. I tried several times to add a musescore File in a blank page directly after starting Libreoffice.

Thank you again!

In reply to by Slasch512

You don't need the abc tools except to use the abc-relaed features. Simoly inserting a MuseScore file should be no problem.

That error message is a very generic one that is displayed when something goes wrong that should not have worked. Only time I ever used to see it was when using a buggy wraion of LibreOffice in which any macro that used static local ariab,es would generate that error. This was fied quite some time ago, at least in the Windows builds. i suppose it, or some other LibreOffice bug, has crept back in to the Ubuntu builds.

I don't know much aout how things world on Ubuntu, but I don't suppose you would be able to figure out how to get into the LibreOffice macro facility and turn on the debugger? It would be interesting to see what is actually generating the error. Or we could edit the macro to turn off the code where I trap unexpected errors so we see the error message from LibreOffice instead of my error message. Unfortunately, I don't know enough about Ubuntu to feel confident walking you through this.

I used a ImageMagick installer for Mac OS X
http://cactuslab.com/imagemagick/

If I click on the musescore-button in libreoffice and choose a mscz-file then a window pops up:
"This is the first time Muse....
Please enter full pathname of executable file:
mscore"
If I just press OK:
"mscore not found"
"Unabable to convert MSCZ to PNG"

What do I have to do or is there a bug using the mac-version?
Should I try to install a nightly build of musescore 2.0?

Thanks a lot

Mac OS 10.7.5 (Lion)
example manager 1.08
Musescore 1.2
Libre Office Version 3.6.3.2 (Build ID: 58f22d5)

In reply to by Woody2209

You can't just press OK when that dialog appears - you have to actually enter the full pathname of the executable.

On windows, it is usually something like C:\Program Files\MuseScore\bin\mscore.exe, but can vary from system to system depending on if you installed with all defaults or chose a custom location; also depending on whether you are on a 32 bit or 64 system).

You need to enter whatever the Mac equivalent is. Presumably when you installed MuseScore, it asked where you wanted it nstalled and you either accepted the default location or chose your own. You need to find where you installed it.

The same will be true for ImageMagick. Once you tell the extension where to find mscore.exe, it will next want to know where to find the mogrify command.

In reply to by Marc Sabatella

Thank you for your quick response.

Before my post I was confused and wondering "what path - to what software",
but you inspired me how and where to look.

My little Linux/unix-knowledge was enough to figure it out:

path to mscore:
/Applications/MuseScore.app/Contents/MacOS/mscore

(hidden) path to mogrify in my imagemagick:
/usr/local/ImageMagick/bin/mogrify

Sometimes "shrink to fit" pops up and works.
If I do changes in my musescore file, save it and then press the musescore-button in libreoffice, it updates it (it rewrites the png-file).

So far great :)

But:
- Not every mscz-file could be converted - no tragedy.
- In my libreOffice-page or the converted png-file the green symbols for line breaks and spacer are still shown/also converted.
- In my works I don´t need a whole page from musescore. I won´t have my header and footer converted, only just the 2 lines of bars. If I would like to work "(with excess whitespace removed)" suitable for my purpuses, I have to erase header and footer before. But probable that´s the way imageMagick is working and not knowing what a header or footer is.

By the way, all single pages of a musescore-file are converted to extra single png-files. Only the first is shown in my libreOffice-page.

Woody

In reply to by Woody2209

Anything particular about the the files that wouldn't convert that you think would be causing the problem? What goes wrong when you try? Can you post one of the examples?

The "shrink to fit" was added at the request of users, but the behavior is less than ideal. It shrinks things too wide to fit in the margins, but then that means they will appear at a smaller scale than other examples that already fit without shrinking. And I don't think I even considered the case of something not fitting vertically. My assumptions we were dealing with short examples that would easily fit on a page, and certainly, no multiple page examples.

The green symbols for the lines breaks - ah, you must have the "Screen shot function" option checked in MuseScore (Edit/Preferences/Export). I'd have hoped that would only affect conversions launched from within the MsueScore GUI, not via the command line. Or that were would at least be a command line option to override it. Anyhow. assuming you don't need that option set for other reasons, turn it off and all should be well.

Regarding header footer, indeed, you have to create your scores with no header or footer for this to work. But assuming you do that, you *will* get just the music. So I'd definitely get in the habit of creating your scores this way. If you are trying to create excerpts from "real" scores, I'd recommend saving the excerpts as separate scores, each with no header or no footer.

In reply to by angelsguitar

Glad it's OK so far. I haven't done any work on this in a while, but I haven't had any recent bug reports, and it's been workong flawlessly for me, so there has been no pressing need. I still have ideas for ways I'd like to extend it further, mostly to make it easier to automatically convert examples to other formats. And when MuseScore 2.0 comes out I plan to update the extension as necessary. If I can avoid the need for people to install a third party graphics package, that would be great.

But for now, the basic functionality is about as finished as it can be, I think.

In reply to by Marc Sabatella

It is good to know this project is still alive. I use this type of functionality a lot for creating teaching materials. Although the new photo tool on MuseScore seems to do the trick (for what I mostly need), it is nice to have this extension as an alternate option.

I'm not a programmer, but let me know if I can be of help testing it out in the future.

In reply to by Marc Sabatella

Hi Marc,
we tried to get the plugin to work a few months ago but I didn't get it to work. Still the same error telling me "an unknown error occured". You told me last time, that you haven't got enough experience with Linux machines. Do you know if there is somebody out there running your plugin under Ubuntu?

Thanks indeed!
Johannes

In reply to by Slasch512

I have no idea if anyone is using the extension on Ubuntu. I'm thinking the most likely explanation is something not installed right on your system, though. I probably asked this before, but is there any way you can fire up the macro debugger in LibreOffice? Perhaps get someone to help you? That's a very generic error message because it shouldn't ever be generated - it indicates something very wrong on the system. As I mentioned before, it happened once on my system due to a LibreOffice bug that was fixed long ago. If you can get into the debugger, we can try some things to narrow down why there is a problem on your system.

In reply to by Slasch512

Hi again.

Indeed, I'm testing it on Ubuntu 12.04 (actually on Lubuntu, a variant with LXDE Desktop) and LibreOffice 4.1.1.2. I have not experienced that error.

Perhaps you could describe the process you are doing (when you see the error) so I can try to replicate on my computer?

In reply to by angelsguitar

OK, I don't really know how to use the Makro Debugger, but if I run the Musescore Extension (in the Musescore Folder) via the Makro Editor in Libreoffice it changes to the error at the Codeline with if mszUrl="" then...
Just have a look at the screenshot. Is this the way I use the Makrodebugger correctly?

I get the Error everytime I try to open a Musescore File. The Explorer Thing pops up and I choose a specific file. Clicking the ok button releases the Error.

Thanks again!

Attachment Size
Bildschirmfoto vom 2013-10-23 09:28:50.png 151.27 KB

In reply to by Slasch512

Thanks, this does seems helpful. Sure seems likely to be another LibreOffice bug - hard to imagine how testing a string variable against the null string could trigger an exception. But the bug I mentioned was iind of similar, except it was only static variables. I'll look into this further. What version of LibreOffice were you running when this happened?

In reply to by Slasch512

I'm not finding any reference to a current bug like this in the LibreOffice issue tracker, so I'd like to be more sure about what is happening. Seems a bit incomprehensible that this line could really be generating an error - if a simple test of a local string variable against "" generates an exception, it seems no macros could possibly work at all.

You should be able to set a breakpoint on that line by double-clicking right that arrow is in the left-hand margin of the code listing. A red dot should appear indicating the breakpoint has been set. If you do this, then run the operation again, does it stop at the breakpoint with no error yet? If you hit F8 to single step, does it still generate the error, or does it move on to the line assigning graphicUrl?

Alternatively, you could try installing the latest version of LibreOffice to see if the problem goes away.

For some reasons SVGs instead of PNGs would be great to have in my eBooks.
Are there any plans or developements (parallel to the introduction of musescore 2.0) to get svg-files (background transparent) via a 2nd version of your extension?

Probably without the need of imagemagic - I mean for my little understanding imagemagick is to convert (from any kind of intern SVG?) to png (with excess whitespace removed) ?

I testet svg with musescore2.0nightlybuilt (latest version) on my mac-system:
Generally svg-export already works without having font-troubles (version 1.3).
And by the way … in my 16th-note-example-export not all stems/lines (or beams – depending on point of view) are in correct position.
"Export Parts“ does not (yet?) work to export to svg!?

Thank you

In reply to by Woody2209

I definitely plan an update to support MuseScore 2.0. And if SVG seems a viable option, I include it. I haven't played with it. ImageMagick, btw, is used for the whitespace trimming only. If I can find a good way around that I will, as I recognize this greatly complicates installation and setup of the plugin.

In reply to by Marc Sabatella

1) The plugin seems to work fine even with MuseScore 2.0 for me on Ubuntu 14.10, which is great, since I only use current builds. Even more, it works with the current LibreOffice version! Only when Ctrl-clicking an inserted example, MuseScore 1.3 is invoked instead of the specified 2.0-executable. Is it possible to manually change this path too?

2) I would like too add that I'd prefer SVG as well.

Thank you for this great plugin anyway!

In reply to by jschwalm

Ctrl-Click uses whatever you have configured as the default application for that file type in your OS. So, whatever programs opens when double-clicking an MSCZ file in your file mnager. Change that and it should work.

Nice to know it works as is for 2.0, but I'll definitiely be getitng on making sure MuseScdore can trim images itself so we can eliminate the need to install a separate utility to trim the image. Not sure if SVG support is fully supported in MuseScore 2.0 or not, but if so, I'll see about adding that possibility to the plugin.

In reply to by jschwalm

Hi there,

I used this addon in Libreoffice for quite a while. now I downloaded MS2.0 (beta 2)and I love it :) but I am unable to use the files I created with MS2.0. If I try to insert a mscz in a libreoffice file, after quite a while I got the error message in a popup: unable to convert MSCZ to png.

Any Idea what I have to do?
Thanks in advance, and best wisches from Berlin
Jürgen

In reply to by JuhaBerlin

Hmm, there's no specific reason the add-on shouldn't work with MuseScore 2.0 builds; I used it just the other day in fact. Although I do need to update it to take advantage of the new 2.0 auto-trimming behavior so I can remove the dependency on GraphicsMagick/ImageMagick.

Anyhow, I can only guess the file you are trying to insert is crashing MuseScore. Does it work to load the file intoi MuseScore normally? Can you post one of the files that is giving you problems? Was it created in 1.3, in the 2.0 Beta 2, or perhaps in some earlier incompatible 2.0 build (in which case, there isn't really anything that can be done about it)?

In reply to by Marc Sabatella

Hi Marc, and thank you for the quick answer. I did a few tests again.
First some facts about my system: When I installed MS2 beta, I chosed a new folder for it, so I could use both versions (I would want to test the new version first) So maybe it is not an issue based on version problems but based on a wrong path? When I changed the standard program for .mscz back to the MS1.3 (old folder) the libreoffice addon works fine.

I would try to reinstall the musescore extension in libreoffice (so I would prompted again for the executables needed), but I have no idea how to do this. If I try to uninstall and reinstall the extension, nothing happens. the variables are still saved somewhere. I found a folder with the extension in C:\Users\...\AppData\Roaming\LibreOffice\4\user\uno_packages\cache\uno_packages\lu1ito1s.tmp_\musescore-1.0.8.oxt I tried to rename it and then start libreoffice again, then install the extension. It does not work. When I try to install the extension afterwards, I got an error message, that this folder does not exist.
Could you please tell me how I can rerun the first initialization of the extension? I have a feeling that this could solve my problem.

Anyway - thank you a lot for a great extension, wich makes life a lot easier. I would really miss it.
Kind regards
Jürgen

In reply to by xavierjazz

Word and LibreOffice use different plugin programming languages, so the same plugin cannot work with both. A Word version could be written someday, to be sure. But FWIW, LibreOffice is almost completely cross-compatible with Word for all normal purposes. You could probably uninstall Word and install LibreOffice today and never miss a beat. Certainly would be a much easier adjustment than going from Finale to MuseScore or vice versa :-)

In reply to by JuhaBerlin

From your description, I suspect the original problem was that you had installed a 2.0 build but not changed your default file associations to the 2.0 version. So you were creating scores in a 2.0 build, but the extension was trying to use 1.3 to convert to PNG. That won't work. The extension uses the default program for MSCZ files, so you'd need change that to 2.0.

The extension itself shouldn't have needed re-installation - it would not be affected by any installationsm, re-installations, or de-installations of MuseScore. Unfortunately, I'm no expert in LibreOffice extension installation issues, so I'm not sure how to advise you as far as recovering it. You might need to ask on a LibreOffice forum.

In reply to by Marc Sabatella

Hello Marc,

I'm just again on the task to download your nice extension from the LibreOffice-Extension-Site and am again directed to the outdated 1.0.8 version. This is due to the language settings on your Release page. If you want make sure that other people from other countries find the correct 2.0 version you could change the language to "language-independent".
Cheers
Kai

Hi there,
I've got a problem with the latest extension. If I try to export a pdf file out of the writer, I get heavy distorted graphics, where the musescore graphics were added (see file attached).
Can you help me out?

Attachment Size
Hördiktat_Vorzeichen_AB.pdf 743.65 KB

In reply to by Slasch512

Hmm, if it works with an export using the image capture, this suggests that something is wrong with the direct PNG export. But I've never experienced any such problem, and I use this feasure a lot, including generating PDF from LibreOffice. What version of LibreOffice are you using? And what version of MuseScore? Also, can you attach one of the PNG's you're having trouble with so we can see if we can reproduce the problem from that?

In reply to by jschwalm

Wow, that's not good. To be clear: the problem exists even when inserting the PNG "normally" (eg, not via my extension)? But other PNG files work normally? So something is presumably different about MuseScore-generated PNG files as opposed to those generated by other means? Oh, and PNG's exported by File / Export have the issue, but not ones generated by the image capture tool?

Is the problem only with images that are as wide as the page? Is it reproducible with PNG files depicting only a single empty measure, for example?

In reply to by Slasch512

The reason is transparency in png's
LibreOffice 5.1.03 has problems with transparent png's. I really hope they manage to fix all the lots of bugs it has altogether someday.

If you export nontransparent png from musescore it works. (preferences->export)

Or: PDF export also works when you select PDF/A-1a because it removes any transparency.

But these are all unacceptable workarounds. Better use LibreOffice 4.4.7

In reply to by Marc Sabatella

Hi,
Discovered the same problem here, but not when using MuseScore. When importing a png into a document using L.O. 5.1.0.3, that png becomes blurred when I try to print it. I was puzzled for quite some time trying to discover the cause of this. Reading this thread I see this now: the transperancy.
Marc wrote :
"OK, I guess that explains it then. But indeed, this is very unfortunate. I take it the bug is already reported to them?"

And that is exactly where it comes to a main obstacle using L.O. : Where to report this bug?
Until now, I did not discover where to drop bugs, or wishes etc. other then using that "Ask LibreOffice"
forum which is not the most user friendly one. But that is my personal opinion.

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