Plugin for search and replace in lyrics

• May 30, 2024 - 22:05

The are many forum entries related to this topic.

Having edited and transcribed about 500 choral scores over the past years I have spend many hours editing lyrics and searching for mistakes. I finally got around to building my version 1 of a standard search and replace tool as a plugin. I prefer to view the text that I am changing in the musescore pane, because I get a better view at the context than in a separate text window, especially when it comes to voices and verses.

Short summary of the functionality:
The plugin finds all occurrences of lyric syllables that contain the given search string and paints them in color in the score. The current item is highlighted by an additional frame.
• “Search All” will start the search and highlights all matches
Doing "search all" again during the editing, will abort the current process and start new from the beginning of the score with the new pattern.
• “Next”: Move to the next match without changing anything
• “Replace”: Pushing the “replace” button will substitute the search pattern in the current syllable with the replace pattern and move to the next match.
You can also edit the text in the “replace value” field. With the “ENTER” key the values is substituted in the lyrics line and tzhe process moves to the next match.
• “Replace All” will do the replace action for all remaining matches in the score until the and.
• “Close” will cleanup all the highlighting and close the plugin.
Make sure to leave the plugin always with this button or you might have some colored lyrics left.
(I could not get the onClosing event to work yet. Any hints here are welcome)
Traversing the list of matches is controlled by the setting at the top of the plugin window:
This defines the sorting of the matches.
Possible values:
tick- part – staff - voice – verse
Default value is tick, this means the items appear in the order the have in the timeline, going vertical through each segment of the score. Choosing any other value from the list above means that the match list is first traversed horizontally through the score on that level (eg. staff).
Technically this is done by using the above list for the sorting priority, with the tick property moved behind the specified value.

Known issues:
• Only for Musescore 3 at the moment.
a) Musescore 4 is still missing some features I heavily rely on for my work
b) With the plugin framework to be changed soon it makes no sense for me to invest time at the moment.
• Highlighting is done by modifying the score (coloring the lyrics). I did not find any other mean from a plugin.
• Matchlist can be traversed only forward. Since preceding items in the list could have been modified already. Going backward would raise the complexity to another level.
• Not all error handling done – still work in progress.
• Automatic cleanup when plugin window is closed
• UI of plugin windows. I am not a pro in QT and QML
• And maybe more
Improvements planned:
• More elaborate search pattern
o Match for beginning or end of syllable
o Patterns for spanning two adjacent syllables – would be very convenient to correct hyphenation mistakes
o Regular expressions (id this makes sense)

• Handling of melisma (underscore) where the end of a word is extended due to ties or slurs
I spent a couple of nights trying to find out how they are represented in the data model.
Any insights are welcome.

Any feedback, comments, suggestions for features or improvements welcome.
Thanks to the authors of plugins lilyrics and roblyric where I got some ideas on how to access lyrics from a plugin. The plugin API is still one of the sparcely covered areas of the documentation.

Attachment Size
PluginWindow.png 41.06 KB
MusescoreWindow.png 169.79 KB
LyricsSearchReplace.qml 15.82 KB


In reply to by sammik

Thanks for your remark. I wanted to get some experience using this and may first feedback from other's.
In the meantime id did a quick test on Musescore 4 and with 2 minor modifications this seems to work as well.
I will add a bit more to the docu and publish afterwards

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