lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: "unroll code"


From: David Wright
Subject: Re: "unroll code"
Date: Sat, 14 May 2016 09:48:27 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat 14 May 2016 at 23:54:17 (+1000), Andrew Bernard wrote:
> Well, despite that I think this is an absolutely terrible hack, exporting to 
> midi and importing it back produces more or less what you want, with a lot of 
> editing. Works on 2.19.41 on openSUSE Leap 42.1 linux.
> 
> Still interested to know why you want to do this.

I would put this more strongly. The hack to use depends on whether the
problem is a single case, on its extent, and on its depth of recursion.

The OP showed the easiest method: make sure it's \absolute, use a
sensible source layout (ie keep lines with {} and lines with notes
separate) and use an editor. With careful naming of variables, it
could probably be done with multiple passes of sed (multiple, to
handle recursion) or, as you suggested, python/perl etc.
I keep a couple of programs, filter-files-lines.py and
filter-files-files.py for this purpose. The middle of each is a set of
simple and regular-expression replacements. The rest of each program
just does the file handling for mass editing of trees of files.
(One works line-by-line, the other file-by-file.)

If there's a large quantity of material to be processed, then a MIDI
hack might well be easier. As long as its output is accurate,
post-processing what's given here should be straightforward.

> trackBchannelB = \relative c {
>   a'4 b c, d
>   | % 2
>   a' b c, d
>   | % 3
>   a' b c, d
>   | % 4
>   a' b c, d
>   | % 5
>   e f g a
>   | % 6
>   a b c, d
>   | % 7
>   e f g a
>   | % 8

(A dose of frescobaldi to add a duration to each bar, removal of those
barnumbers and reinsertion of appropriate ones, conversion back to
\absolute, all optional of course.)

MIDI might give problems if there are notes with articulations,
ties, slurs etc.

Saying all that, I'd be loath to multiply out such well-factorised
code into a long error-prone sequence of individual notes without
a pretty good reason. That's why these folded constructions exist
in the first place.

Cheers,
David.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]