lilypond-user
[Top][All Lists]
Advanced

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

Re: rhythm shift


From: David Wright
Subject: Re: rhythm shift
Date: Sat, 26 Mar 2016 18:29:25 -0500
User-agent: Mutt/1.5.21 (2010-09-15)

On Sat 26 Mar 2016 at 23:23:51 (+0100), Gianmaria Lari wrote:
> Very sorry David and Robert my example was not at all clear.
> 
> I have a long lilypond source that is shifted of three sixteenth note (the
> file has been generated using the midi to lilypond conversion tool).

Well, I did wonder that at the time, but decided to ignore it as it's
a far tougher problem. I can only give you hints as to how *I* would go
about it. You'd end up with LP code containing *no* ties, so some
manual post-processing would be required, or using the solution given
before (ie automatic note splitting).

> Here
> it is a small fragment of it:
> 
> % \time 4/4
> ...
> 
> ... d16 ~ | % 31
> d8. d16 ~ d8 b'16 b16 ~ b16 b8 b16 ~ b16 b8 b16 ~ | % 32
> b8 a16 g16 ~ g4
> ...
> 
> 
> I would like to know if does exist a tool able to convert it to the
> following source lilypond code:
> 
> ... d4 |
> d8. b'16 b8 b8 b8 b8  b8. a16 |
> g4. ....

I would start by putting a single part in a separate file and
sanitising it by removing extraneous information, ie anything like
\bar "|" or anything lying between a note and a tie. I don't
suppose there would be any slurs.
Using an editor, I would then kill all the bar numbering, ie
search to a |, move back before it, kill the rest of the line and
delete a char (the newline) so that the entire part was on one
uninterrupted line (with a space at each end)..

(Actually, with care, you could have all the parts in a file, each on
one line.)

Then the clever bit, which is to write a regular expression in python
(or perl or whatever) to match    " ([a-gs,']+)16 ~ ([a-gs,'])+8 "
and replace it with " \18. ".
(I'm using english note names and writing in pseudocode.) In other words
<space><notename characters>16 ~ <notename characters>8<space>
is replaced by \1 which is the saved notename, followed by 8.
(Using the first namename should take acre of the octavations.)

I would not bother to automate the durations, but just write a rule
for each combination and each way round (8 16 and 16 8 etc).

I would run this and see if all the ties disappeared. If not, add
another rule (eg 8 4 → 4.) and repeat. As you can see, it's a
complete hack, but an enjoyable challenge if you're trying to keep
your little grey cells ticking over.

A strategist would probably hack the code of python-ly and do the
job properly. Then you wouldn't get tripped up by any inconsistencies
in the way the notes are written.

Sorry that I can only come up with something that requires facility
with an editor and/or programming language.

Cheers,
David.



reply via email to

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