Forums => Tips & Tricks => User Tools => Topic started by: Flurmy on 2019-08-31 07:36 AM
Title: Percussion splitter
Post by: Flurmy on 2019-08-31 07:36 AM
This tool splits a percussion staff, tipically containing all the percussions, in different staves, one for each "instrument", i.e. note. The staff to be splitted is the one selected in the editor. The staves are added at the end of the score. To undo, just delete the staves which were added.
There is an optional parameter. If the program is called with a parameter value of 1, the "notes" of triangle and hi-hat are grouped so as to use only a single staff each. If the parameter is 2, also the bongos, congas, timbales, agogo, whistle, guiro, wood blocks and cuica are grouped on a staff each. If the parameter is 3 or more, also toms and cymbals are grouped. If there's no parameter or the parameter is <= 0 then there will be no grouping.
N.B. When importing from MIDI you often get two staves for the percussions, one with treble clef and the other with percussion (or bass) clef. There is no harm in repeating the splitting, so you can split one staff and then the other. The only drawback is that possibly, if you're using grouping, you can have two staves of the same group and you have to merge them manually. To avoid this you can widen the "maximum single track chord size" so as to have all in a single staff.
This is my first attempt at programming in Lua. I would never have it done without the great help of Bart. Thank you, Bart.
Title: Re: Percussion splitter
Post by: yukulele on 2019-09-03 11:15 AM
Very useful tool, thanks! 👍 grouping rocks! 😍
I have some suggestion:
keep original staff options (ending bar, volume/pan/muted, playback device, MIDI patch instructions, Default dynamic velocity, ...)
take into consideration original staff transposition
set smaller upper/lower boundaries between generated staves (=6?)
Title: Re: Percussion splitter
Post by: Flurmy on 2019-09-03 08:00 PM
Hello yukulele, thank you for your suggestions. Here below my comments.
keep original staff options (ending bar, volume/pan/muted, playback device, MIDI patch instructions, Default dynamic velocity, ...)
Well, the default dynamic velocities were already maintaned. :D The staff ending bar was set to none (hidden) because that's how I always use it, but it's easy to change it once as needed in the original staff before splitting, so now it copies the original in all the added staves. I forgot to copy the staff volume. ;D I think it makes no sense to copy the original mute status. You can easily mute and unmute the whole group at once with the NWC muting dialog. Each percussion "instrument" already has its acoustic position. I don't see why to pan the whole lot. You can pan each single instrument via special MIDI commands, but that's another story... :D MIDI patch instructions? Those are "per channel" data and all the percussion we are dealing now are on channel 10! Just set them once. Playback device? Are you kidding? :P
I'm not kidding, in some case devices are used to workaround 16 channel midi limitation (by using several virtual midi devices). but I admit that I don't use it very often (and probably never for percussion).
Title: Re: Percussion splitter
Post by: Flurmy on 2019-09-05 08:11 PM
Quote
I think this fix create a regression in case of time signature change
Thank you for discovering this bug. I also fixed another couple, so here attached you can find the new version 1.2.
Title: Re: Percussion splitter
Post by: Flurmy on 2025-05-12 10:29 AM
A program update. The changes are too many to be listed, hence version 2.0, but in a nutshell I can resume them as: much, much less need for manual adjust of the resulting staves. The usage instruction are unchanged. You can find the new code in the first message of this thread.
Title: Re: Percussion splitter
Post by: yukulele on 2026-02-07 03:52 PM
Hi Bart!
I just reinstalled NWC, one of the first things to do is to reinstall the essential percussions-split plugin!
Unfortunately, I'm getting an error that I don't think I've encountered before:
function dump(o) if type(o) == 'table' then local s = '{ ' for k,v in pairs(o) do if type(k) ~= 'number' then k = '"'..k..'"' end s = s .. '['..k..'] = ' .. dump(v) .. ',' end return s .. '} ' else return tostring(o) end end
Title: Re: Percussion splitter
Post by: Flurmy on 2026-02-08 10:52 AM
Sorry, the answer is obvious: in your snippet the label and the label abbr. are missing. But no "text"!
I still get no error: the name field is present and ignored as it should.
Title: Re: Percussion splitter
Post by: Flurmy on 2026-02-08 11:19 AM
A-ha! I seem to remember (quite surprising for me! ;D ) that a small change about this was made in the lua libraries in NWC 2.8 Beta 1 (the one I'm using). Which version of NWC are you using?
Title: Re: Percussion splitter
Post by: Flurmy on 2026-02-08 11:26 AM
Yes, indeed: https://github.com/nwsw/nwcutlib/commit/9940e568bc67f6ca5068127f16b651cb691730cb (https://github.com/nwsw/nwcutlib/commit/9940e568bc67f6ca5068127f16b651cb691730cb) I'm very surprised of myself! :))
Title: Re: Percussion splitter
Post by: Flurmy on 2026-02-08 01:34 PM
Quote
In the new beta, the |Text:*| property and User object properties are now stored as strings (replaces the nwcOptText object).
In the current general release, text properties use a nwcOptText class for storage. This is a heavy operation that requires an additional allocated table just to store the encoded string. In this same release, user object properties are all stored as raw, encoded strings. This creates a complicated approach to handling the text properties.
In the new beta, all of these text properties are maintained as simple decoded strings. All simple strings are passed through an encoding filter before writing them back into a nwctxt file stream, which strives to make scripting changes to these properties much simpler. It does create an issue for current tools.
As it currently stands, changes will be required in tool code when accessing these text properties. Perhaps the easiest way to handle this is by two utility functions:
I guess yukulele has version 2.8 beta 1 and Flurmy has version 2.751
Exactly the opposit! :))
Title: Re: Percussion splitter
Post by: Flurmy on 2026-02-08 02:38 PM
Since I don't want to roll back my NWC installation and I'm almost sure I forgot to change some items :P , yukulele, could you please try this (beta) version? Thanks.
[edit: tool version officially released and attached to the first message]
Title: Re: Percussion splitter
Post by: yukulele on 2026-02-09 02:01 PM