Discussion:
Extract the first notes from a musical expression
Gianmaria Lari
2018-11-14 23:16:08 UTC
Permalink
Consider a simple code similar to the following one:

\version "2.19.82"
myVar = \fixed c' { a4 b c' a | a4 4 b c | b4 a b c' | ........
{\myVar}


This will generate a score containing *all* the notes specified in myVar.

Now, suppose that I don't want to generate all the notes in myVar but only
the first 8 quarter notes (the first 2 bars) . Is there any function that
can do it? something like "\extractMusic \myVar 4*4".

Thank you, g.
Gianmaria Lari
2018-11-15 07:08:34 UTC
Permalink
I read my msg. and I found it not very clear. I hope this is a bit more
clear:
Suppose I have a variable containing the following music expression:


{

a4 b4 c'4 d'4 |

b4 b4 a4 a4 |

c'4 b4 a4 b4 |

a4 a4 c'4 a4 |

c'4 b4 a4 c'4

}


How can I get only the first n quarters of the variable? Something like:


\extractMusic \myVar 4

that should generate

{

a4 b4 c'4 d'4 |
}

?
Post by Gianmaria Lari
\version "2.19.82"
myVar = \fixed c' { a4 b c' a | a4 4 b c | b4 a b c' | ........
{\myVar}
This will generate a score containing *all* the notes specified in myVar.
Now, suppose that I don't want to generate all the notes in myVar but only
the first 8 quarter notes (the first 2 bars) . Is there any function that
can do it? something like "\extractMusic \myVar 4*4".
Thank you, g.
Mark Knoop
2018-11-15 07:53:25 UTC
Permalink
Post by Gianmaria Lari
\version "2.19.82"
myVar = \fixed c' { a4 b c' a | a4 4 b c | b4 a b c' | ........
{\myVar}
This will generate a score containing *all* the notes specified in myVar.
Now, suppose that I don't want to generate all the notes in myVar but
only the first 8 quarter notes (the first 2 bars) . Is there any
function that can do it? something like "\extractMusic \myVar 4*4".
There is indeed code available to do this.

http://gillesth.free.fr/Lilypond/extractMusic/
--
Mark Knoop
Gianmaria Lari
2018-11-15 08:10:17 UTC
Permalink
Great Mark, thank you!!!

Strange that I didn't find this code in the LSR...

Ciao, g.
Post by Mark Knoop
Post by Gianmaria Lari
\version "2.19.82"
myVar = \fixed c' { a4 b c' a | a4 4 b c | b4 a b c' | ........
{\myVar}
This will generate a score containing *all* the notes specified in myVar.
Now, suppose that I don't want to generate all the notes in myVar but
only the first 8 quarter notes (the first 2 bars) . Is there any
function that can do it? something like "\extractMusic \myVar 4*4".
There is indeed code available to do this.
http://gillesth.free.fr/Lilypond/extractMusic/
--
Mark Knoop
_______________________________________________
lilypond-user mailing list
https://lists.gnu.org/mailman/listinfo/lilypond-user
Gianmaria Lari
2018-11-15 08:17:16 UTC
Permalink
Post by Gianmaria Lari
Strange that I didn't find this code in the LSR...
No, that's not true. I didn't find it but it was there:
http://lsr.di.unimi.it/LSR/Item?id=542

Thank again Mark!
g.
Gilles Thibault
2018-11-16 14:22:13 UTC
Permalink
Post by Gianmaria Lari
http://lsr.di.unimi.it/LSR/Item?id=542
For Lilypond 2.19.XX, you'll need this updated version :

http://gillesth.free.fr/Lilypond/extractMusic/2.19/extractMusic.ly


Note that there is a doc here :

http://gillesth.free.fr/Lilypond/extractMusic/extractMusic-doc.pdf

(well, probably in bad English, sorry for that)
--
Gilles
Gianmaria Lari
2018-11-16 16:50:15 UTC
Permalink
Thank you Gilles!
g.
Post by Gilles Thibault
Post by Gianmaria Lari
http://lsr.di.unimi.it/LSR/Item?id=542
http://gillesth.free.fr/Lilypond/extractMusic/2.19/extractMusic.ly
http://gillesth.free.fr/Lilypond/extractMusic/extractMusic-doc.pdf
(well, probably in bad English, sorry for that)
--
Gilles
Loading...