Re: rhythm shift

2016-03-30 Thread Gianmaria Lari
Ciao Robert,

sorry if I reply so late.
What you propose to do is a bit too complicated for me and I'll use it as a
last resort. What I'm trying to do now is just to open the midi file with
musescore and add a note in the file to correctly shift the others.

Anyway, it would be great having some programming tools to manipulate
lilypond source code like what I was asking for.

Thank a lot for you help Robert!!!
Best regards, Gianmaria
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: rhythm shift

2016-03-28 Thread Gilles THIBAULT

> %% TODO: this function [twoTiedNotesToOneNote] probably does not work with 
chords -:(
No it doesn't and it is probably better :

music = { 4~   } is correct in Lilypond.

So what would be a good result for { \twoTiedNotesToOneNote \music } ?
Not smart enough to answer.

-- 
Gilles

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: rhythm shift

2016-03-28 Thread Gilles THIBAULT
> \time 2/4
> r4 a4 ~ |
> a4 b4 ~|
> b4 r4

> How can I shift (convert) it to:
> \time 2/4
> a2 |
> b2 |
> r4

For "shifting" rhythm, you can use this snippet :
http://lsr.di.unimi.it/LSR/Item?id=542

To transform 2 tied notes into a single note, you have to make your own 
function...



\include "extractMusic.ly"
%% to download here
%% http://gillesth.free.fr/Lilypond/extractMusic/

#(define (name-of music)
 (ly:music-property music 'name))

%% TODO: this function probably does not work with chords -:(
twoTiedNotesToOneNote = #(define-music-function (parser location music) 
(ly:music?)
"Transform 2 tied notes in a note with a length equal to the sum of their 
lengths"
 (let loop ((notes (reverse ;; easier for managing multiple tied notes)
 (extract-named-music music 'NoteEvent ;; 'EventChords 
   
   (if (or (null? notes)(null? (cdr notes)))
 (music-filter (lambda(mus)(not (eq? 'Music (name-of mus
   music)
 (let ((note1 (first notes))
   (note2 (second notes)))
   ;; (display "-"\n)
   ;; (display-scheme-music note1) 
   ;; (display-scheme-music note2)  
   (if (pair? (extract-named-music note2 'TieEvent))
 (let* ((mom1 (ly:music-length note1))
(mom2 (ly:music-length note2))
(new-mom2 (ly:moment-add mom1 mom2))
   ;; the following moment->rhythm function 
   ;; is defined in "extractMusic.ly"
(new-dur2 (moment->rhythm new-mom2)))
   (ly:music-set-property! note2 'duration new-dur2)
   (ly:music-set-property! note2 'articulations 
 (filter (lambda(mus)(not (eq? 'TieEvent (name-of mus
 (ly:music-property note2 'articulations)))
   ;; (set! note1 (ly:make-music 'Music)) ;; doesn't work...
   (ly:music-set-property! note1 'name 'Music))) 
   ;; well, changing the property 'name is not "standard"
   (loop (cdr notes))




music = { 
  \time 2/4
  r4 a4-"4" ~ 
  a4-"3" b4-"2" ~
  b4-"1" r4 
}


\new Staff \music
\new Staff { 
  \time 2/4
  \extractEnd
 \twoTiedNotesToOneNote \music
 s4

}

music = \relative c' {  
s2. s8. d16 ~  % 31
d8. d16 ~ d8 b'16 b16 ~ b16 b8 b16 ~ b16 b8 b16 ~  % 32
b8 a16 g16 ~ g4
}

\new Staff \music
\new Staff { 
  \extractEnd
 \twoTiedNotesToOneNote \music
 { s2. s8.  }

}
--

Note that if you "shift" rhythm, you have to delete barcheck |

-- 
Gilles

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: rhythm shift

2016-03-26 Thread David Wright
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
16 ~ 8
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.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: rhythm shift

2016-03-26 Thread Gianmaria Lari
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). 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. 


Thank you, g.

On Sat, Mar 26, 2016 at 8:11 AM, Robert Schmaus 
wrote:

> Hi Gianmaria,
>
> In addition to the completion head engraver (David's mail), I'd pack the
> notes without shift in a variable, like
>
> variable = { a2 b2 }
>
> And use
>
> r4 \variable r4
>
> or
>
> r8 \variable r8 r4
>
> Or whatever you'd like in the score.
> Just leave out the bar checks, they'll throw warnings ...
>
> Best, Robert
>
> __
>
> The cure for a fallacious argument is a better argument, not the
> suppression of ideas.
> *-- Carl Sagan*
>
>
> On 26 Mar 2016, at 01:06, Gianmaria Lari  wrote:
>
> Hello,
> Is there any automatic tool to shift some lilypond music of a certain
> rhythm amount? For instance consider the following fragment:
>
> \time 2/4
> r4 a4 ~ |
> a4 b4 ~|
> b4 r4
> 
>
>
> How can I shift (convert) it to:
>
> \time 2/4
> a2 |
> b2 |
> r4
> 
>
>
> Thank you, g.
>
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
>
>
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: rhythm shift

2016-03-26 Thread Robert Schmaus
Hi Gianmaria,

In addition to the completion head engraver (David's mail), I'd pack the notes 
without shift in a variable, like

variable = { a2 b2 }

And use 

r4 \variable r4

or

r8 \variable r8 r4

Or whatever you'd like in the score. 
Just leave out the bar checks, they'll throw warnings ...

Best, Robert

__

The cure for a fallacious argument is a better argument, not the suppression of 
ideas.
-- Carl Sagan


> On 26 Mar 2016, at 01:06, Gianmaria Lari  wrote:
> 
> Hello,
> Is there any automatic tool to shift some lilypond music of a certain rhythm 
> amount? For instance consider the following fragment:
> 
> \time 2/4
> r4 a4 ~ |
> a4 b4 ~|
> b4 r4
> 
>  
> How can I shift (convert) it to:
> 
> \time 2/4
> a2 |
> b2 |
> r4 
> 
>  
> Thank you, g.
> ___
> lilypond-user mailing list
> lilypond-user@gnu.org
> https://lists.gnu.org/mailman/listinfo/lilypond-user
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: rhythm shift

2016-03-25 Thread David Wright
On Sat 26 Mar 2016 at 01:06:58 (+0100), Gianmaria Lari wrote:
> Hello,
> Is there any automatic tool to shift some lilypond music of a certain
> rhythm amount? For instance consider the following fragment:
> 
> \time 2/4
> r4 a4 ~ |
> a4 b4 ~|
> b4 r4
> 
> 
> How can I shift (convert) it to:
> 
> \time 2/4
> a2 |
> b2 |
> r4
> 

Take a look at the Notation Manual's Automatic note splitting in chapter 1:

\new Voice \with {
  \remove "Note_heads_engraver"
  \consists "Completion_heads_engraver"
  \remove "Rest_engraver"
  \consists "Completion_rest_engraver"
}

Cheers,
David.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


rhythm shift

2016-03-25 Thread Gianmaria Lari
Hello,
Is there any automatic tool to shift some lilypond music of a certain
rhythm amount? For instance consider the following fragment:

\time 2/4
r4 a4 ~ |
a4 b4 ~|
b4 r4



How can I shift (convert) it to:

\time 2/4
a2 |
b2 |
r4



Thank you, g.
___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user