If it has to be a music expression transformation, the way I would approach this would be:
1. Reverse the music expression 2. Use fold-some-music to simply drop every element until we hit a rhythmic event that isn't a multimeasure rest 3. *cons* onto the head of the remaining expression a multimeasure rest of the appropriate full bar duration with the tacet text override 4. Reverse the expression But that's going to be a bit slow for large scores since it iterates through the whole piece extra times. In terms of making a tool that does this, an engraver might be better that would print the appropriate tacet rest as long as the music for that context ends before the end of the score. Along these lines: 1. During initialize, create a multimeasure rest spanner but don't set the bounds yet. Override the MMR number with the tacet text, probably based on a context property. 2. During any timestep that is the beginning of a bar and in which no rhythmic events were heard in this context, if the left bound is not yet set, set the current non-musical column as the MMR's left bound. 3. Acknowledge all the grobs we might want to kill, such as time signatures, key signatures, marks and store them in a list or array. 4. Any time a relevant musical event is heard, unset the MMR's left bound and reset the grob kill list. 5. In finalize, kill all the grobs in the kill list and set the MMR right bound to the current non-musical column. There might need to be some handling of the edge case where left and right columns are the same column. Probably an engraver like this could also be adapted to work as intended for the case where the music expression contains explicit rests at the end, by adjusting the types of listened events and acknowledged grobs. Saul On Thu, Oct 10, 2024 at 1:35 AM Werner LEMBERG <w...@gnu.org> wrote: > > Folks, > > > has anybody written a 'tacet al fine' function that converts all rests > at the end of a piece into a single, multi-measure rest with the text > 'tacet al fine' above instead of the number of measures? The attached > image comes from Gould's book 'Behind Bars'. > > Such a function should suppress rehearsal numbers together with tempo > and time signature changes (and probably more things). > > > Werner >