Skip to main content
Topic: "Compactify rests"? (Read 4277 times) previous topic - next topic

"Compactify rests"?

The Parts user tool is helpful, but it leaves rest sequences like the following when a voice is completely deleted:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
|Rest|Dur:4th
|Rest|Dur:8th,Dotted
|Rest|Dur:16th
|Rest|Dur:8th,Slur
|Rest|Dur:8th
|Rest|Dur:8th,Staccato
|Rest|Dur:8th,Staccato
|Bar
|Rest|Dur:4th
|Rest|Dur:4th
|Rest|Dur:Half
|Bar
!NoteWorthyComposerClip-End

(from this:

Code: (nwc) [Select · Download]
!NoteWorthyComposerClip(2.75,Single)
|Rest|Dur:4th
|Note|Dur:8th,Dotted|Pos:2|Opts:Stem=Down,Beam=First
|Note|Dur:16th|Pos:3|Opts:Stem=Down,Beam=End
|Note|Dur:8th,Slur|Pos:4|Opts:Stem=Down,Beam=First
|Note|Dur:8th|Pos:3|Opts:Stem=Down,Beam
|Note|Dur:8th,Staccato|Pos:2|Opts:Stem=Down,Beam
|Note|Dur:8th,Staccato|Pos:1|Opts:Stem=Down,Beam=End
|Bar
|Note|Dur:4th|Pos:0
|Rest|Dur:4th
|Rest|Dur:Half
|Bar
!NoteWorthyComposerClip-End

Is there an easy way (read: a tool) to rewrite these rest sequences (and, more generally, also sequences of identical notes and chords) to the shortest possible rest/note/chord?

(Additional "possible hiccup": Musically, it is not ok to span a note over a "beat boundary", e.g., the 4th and 5th eighth in a 4/4 measure - they must be written as two tied eights. But then again, in some rhythms - e.g. when the 4/4 measures are split into 3+3+2 eighths -, it is ok to write a single quarter note. I do not know which and how many additional parameters one would need to control this - a string of the form "2+2/4" for a standard 4/4 time signature or "3+3+2/8" with semantics "no note spanning the boundaries indicated by +" might be the most versatile ...

//Edit: No, this is not enough; one needs such a string for each subdivision: 1/1, 2/2, [none for /4], 3+3+2/8, 2/16 as a shortcut for the repeated group 2+2+2+2+2+2+2+2/16, meaning that no eights can start at an odd sixteenths; etc.

// Edit^2: I think this is about the 3rd or 4th time I invent this, isn't it?? - including the Edit^2 idea :) ... I should use "search" more often and not invent so many things ...).

Thanks for help!
Harald

Re: "Compactify rests"?

Reply #1
I have a tool that can do this, and it creates whole rests when the duration of all objects matches what the key signature says its supposed to have. nwc Look for "Resting Staff" at the bottom of "User Tools". 

Run against both of your samples it creates a pair of hidden whole rests.

Edit: This might not be exactly what you need, but it should be easy to modify.  The tool was for those occasions when you realize you need a new layered staff 100 measures into your transcription.
Since 1998

 

Re: "Compactify rests"?

Reply #2
Thank you! - no, does not what I want (and need), but yes, is a starting point! (and the problem you solved is one I also have oftentimes - so the tool as-is comes in handy!).

Regards
Harald

Re: "Compactify rests"?

Reply #3
On my commute, I've started to write an "Audit Ties" user tool, which should be able to rewrite sequences of rests and tied notes and chords to shorter ones. What seemed not too hard, has now become quite a long algorithm, which is still not finished (no handling of two-duration chords and restchords, for example) ... I'm not really sure that I am on the right track here. Would anyone care to discuss this a little with me?

Here is the current (untested) source, with function ordered "top down" (i.e., called helper functions are below the functions that call them - the main function is "auditTies"): http://hmmueller.de/NoteworthyComposer/AuditTies.lua.
A set of helper functions is in hmmueller.de/NoteworthyComposer/NWCUtils.lua.

One main question I have: I want to include unit tests in the source (there are a few in AuditTies, e.g. for createDurPatterns()). But for further such tests, I need the NWC lua libraries so that I can create NWCItems from text; and use functions like :Get() etc. Is there a possibility to require() the NWC lua libraries without calling through NWC?

// Edit - I understand now that this would be a posting for the "Software rehearsal" area! ... I'll repost it there, but leave this as an anchor here (but it could be deleted ...).

Regards
Harald