Re: "unroll code"
Am 15. Mai 2016 17:18:10 GMT+01:00, schrieb Paul : >On 05/15/2016 09:01 AM, David Wright wrote: >> On Sun 15 May 2016 at 13:07:31 (+0200), imj-muz...@bluewin.ch wrote: >>> Would such manipulations be easy in Scheme, using DisplayMusic to >output the result ? >Maybe \displayLilyMusic would be useful? > >\version "2.18.2" > >ab = { c d e f } >cd = { g a b c } > >\displayLilyMusic { > \ab > \cd >} > >% prints: >% { { c d e f } { g a b c } } > No, because there's still the "repeat" info in the expression. >___ >lilypond-user mailing list >lilypond-user@gnu.org >https://lists.gnu.org/mailman/listinfo/lilypond-user -- Diese Nachricht wurde von meinem Android-Mobiltelefon mit K-9 Mail gesendet. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "unroll code"
Le vendredi 13 mai 2016, 23:01:12 Gianmaria Lari a écrit : > Is there any tool to "unroll" the code. For instance, suppose you have > something like this... > music = > { > \repeat unfold 3 {\fragment.1} > \repeat unfold 2 {\fragment.1 \fragment.2} > } It is note possible with \repeat Use instead, an alternative function \nCopy described here : http://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00358.html and apply the corrections of David Kastrup http://lists.gnu.org/archive/html/lilypond-user/2015-11/msg00361.html In conjunction with \displayLilyMusic, it should work. -- Gilles ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "unroll code"
That was my first thought too, but the OP wanted to have something like \repeat unfold 3 { c d e f } unfolded into c d e f c d e f c d e f and \displayLilyMusic doesn't do that. Instead it outputs \repeat unfold 3 { c d e f } Am 15/05/16 um 18:18 schrieb Paul: On 05/15/2016 09:01 AM, David Wright wrote: On Sun 15 May 2016 at 13:07:31 (+0200), imj-muz...@bluewin.ch wrote: Would such manipulations be easy in Scheme, using DisplayMusic to output the result ? Maybe \displayLilyMusic would be useful? \version "2.18.2" ab = { c d e f } cd = { g a b c } \displayLilyMusic { \ab \cd } % prints: % { { c d e f } { g a b c } } ___ 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: "unroll code"
On 05/15/2016 09:01 AM, David Wright wrote: On Sun 15 May 2016 at 13:07:31 (+0200), imj-muz...@bluewin.ch wrote: Would such manipulations be easy in Scheme, using DisplayMusic to output the result ? Maybe \displayLilyMusic would be useful? \version "2.18.2" ab = { c d e f } cd = { g a b c } \displayLilyMusic { \ab \cd } % prints: % { { c d e f } { g a b c } } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "unroll code"
On Sun 15 May 2016 at 13:07:31 (+0200), imj-muz...@bluewin.ch wrote: > Would such manipulations be easy in Scheme, using DisplayMusic to output the > result ? It's still rolled up: GNU LilyPond 2.19.36 Processing `rol.ly' Parsing... (make-music 'SequentialMusic 'elements (list (make-music 'UnfoldedRepeatedMusic 'elements '() 'repeat-count 3 'element (make-music 'SequentialMusic 'elements (list (make-music 'SequentialMusic 'elements (list (make-music 'NoteEvent 'pitch (ly:make-pitch -1 5) 'duration (ly:make-duration 2)) Cheers, David. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "unroll code"
Greetings All, I am by no means offering up a solution to "unroll" code, but I certainly was intrigued by the question, because, as a composer, I have had instances where such an ability would have been immensely useful. When I felt fluent enough in Lily to use variables (or, for that matter, "q" for chordal repetition), I applied the "shortcuts" with enthusiasm and - foolishly - with abandon. Inevitably, I would later desire to make fine alterations in the completed score, but doing so would often force me to burst the tight construction I had coded, resulting in much manual unrolling. After a while, application of such general substitutions came to seem dangerously risky business for a composer but incredibly beneficial for a transcriber of a fixed artifact. This is why I no longer use these tools, preferring to write out all the information directly in the \score block and, in the end, saving myself an untold amount of time. Hwaen Ch'uqi On 5/14/16, Gianmaria Lari wrote: > Thank you to Robert Schmaus, Andrew Bernard, David Wright for the > suggestions. > > I try to be more precise. > It's not that really I need to be able to enroll some lilypond code. > (1) I was curios to know if LP or Frescobaldi give this functionality > (2) I thought that maybe this functionality was available because LP > compiler probably create a intermediate enrolled structure (substituting > variable with their contents, substituing function like "\traspose" with > the > trasnposed music etc.). > (3) I have written some lilypond music in a terrible way and I would be > curios to see it in a more linear way :) > > I also thought that having the music enrolled would be the preliminary step > for the opposite process. Having an alghorithm that looks for repetition > and > try to rewrite the music in a more more compacted way (using repetition, > transpose etc. etc.) > > As you can understand this is very much a curiosity than a need. But I'm > expecially curious about (2). > > The Robert idea: LP -> Midi -> LP is correct but I have some experience > going from Midi to LP and I always hope to be able to avoid it :) As Andrew > and David point out you need a lot of work after the conversion. In my > opinion this is to be considered possible only just in theory or for > simple/short music. > g. > > > > -- > View this message in context: > http://lilypond.1069038.n5.nabble.com/unroll-code-tp190602p190618.html > Sent from the User mailing list archive at Nabble.com. > > ___ > 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: "unroll code"
Hello, Would such manipulations be easy in Scheme, using DisplayMusic to output the result ? Jacques Menu, iPhone > Le 14 mai 2016 à 23:54, Gianmaria Lari a écrit : > > Thank you to Robert Schmaus, Andrew Bernard, David Wright for the > suggestions. > > I try to be more precise. > It's not that really I need to be able to enroll some lilypond code. > (1) I was curios to know if LP or Frescobaldi give this functionality > (2) I thought that maybe this functionality was available because LP > compiler probably create a intermediate enrolled structure (substituting > variable with their contents, substituing function like "\traspose" with the > trasnposed music etc.). > (3) I have written some lilypond music in a terrible way and I would be > curios to see it in a more linear way :) > > I also thought that having the music enrolled would be the preliminary step > for the opposite process. Having an alghorithm that looks for repetition and > try to rewrite the music in a more more compacted way (using repetition, > transpose etc. etc.) > > As you can understand this is very much a curiosity than a need. But I'm > expecially curious about (2). > > The Robert idea: LP -> Midi -> LP is correct but I have some experience > going from Midi to LP and I always hope to be able to avoid it :) As Andrew > and David point out you need a lot of work after the conversion. In my > opinion this is to be considered possible only just in theory or for > simple/short music. > g. > > > > -- > View this message in context: > http://lilypond.1069038.n5.nabble.com/unroll-code-tp190602p190618.html > Sent from the User mailing list archive at Nabble.com. > > ___ > 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: "unroll code"
Thank you to Robert Schmaus, Andrew Bernard, David Wright for the suggestions. I try to be more precise. It's not that really I need to be able to enroll some lilypond code. (1) I was curios to know if LP or Frescobaldi give this functionality (2) I thought that maybe this functionality was available because LP compiler probably create a intermediate enrolled structure (substituting variable with their contents, substituing function like "\traspose" with the trasnposed music etc.). (3) I have written some lilypond music in a terrible way and I would be curios to see it in a more linear way :) I also thought that having the music enrolled would be the preliminary step for the opposite process. Having an alghorithm that looks for repetition and try to rewrite the music in a more more compacted way (using repetition, transpose etc. etc.) As you can understand this is very much a curiosity than a need. But I'm expecially curious about (2). The Robert idea: LP -> Midi -> LP is correct but I have some experience going from Midi to LP and I always hope to be able to avoid it :) As Andrew and David point out you need a lot of work after the conversion. In my opinion this is to be considered possible only just in theory or for simple/short music. g. -- View this message in context: http://lilypond.1069038.n5.nabble.com/unroll-code-tp190602p190618.html Sent from the User mailing list archive at Nabble.com. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "unroll code"
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. ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "unroll code"
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. Andrew == snip Using your input: \version "2.14.0" \layout { \context { \Voice \remove "Note_heads_engraver" \consists "Completion_heads_engraver" \remove "Rest_engraver" \consists "Completion_rest_engraver" } } trackAchannelA = { % [TEXT_EVENT] creator: % [TEXT_EVENT] GNU LilyPond 2.19.41 \time 4/4 \tempo 4 = 60 } trackA = << \context Voice = voiceA \trackAchannelA >> trackBchannelA = { \set Staff.instrumentName = "\new:" } 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 } trackB = << \clef bass \context Voice = voiceA \trackBchannelA \context Voice = voiceB \trackBchannelB >> \score { << \context Staff=trackB \trackA \context Staff=trackB \trackB >> \layout {} \midi {} } ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: "unroll code"
Hi Gianmaria, if you use Frescobaldi, there's a "Import Midi" function in the File Menu. In principle, if you produce a midi file from your original ly file, you should be able to reimport the music fully unfolded. The problem is, I've never used this function, and a quick trial just now didn't really work on my Mac. So, if you use Frescobaldi and *do* get it to work, that should help you. Otoh, if you happen to have Musescore available (thats a open source wysiwyg note engraver), this program does support midi import and ly export. So that would be another possibility. Best, Robert Am 13/05/16 um 23:01 schrieb Gianmaria Lari: Is there any tool to "unroll" the code. For instance, suppose you have something like this... \version "2.19.40" fragment.1 = { a b c d } fragment.2 = { e f g a } music = { \repeat unfold 3 {\fragment.1} \repeat unfold 2 {\fragment.1 \fragment.2} } \score { \music \layout{} } is there any way to transform it in this: \score { { a b c d a b c d a b c d a b c d e f g a a b c d e f g a } \layout{} } ? ___ 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: "unroll code"
Hi Gianmaria, On 14/05/2016, 7:01 AM, "lilypond-user on behalf of Gianmaria Lari" wrote: >Is there any tool to "unroll" the code. For instance, suppose you have >something like this... That’s a textual transformation on source code isn’t it? Therefore you would have to do it external to lilypond, to process the file and output a new source code file. You could write a script in perl or python or scheme or whatever takes your fancy. Out of interest, why do you want this function? Andrew ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
"unroll code"
Is there any tool to "unroll" the code. For instance, suppose you have something like this... \version "2.19.40" fragment.1 = { a b c d } fragment.2 = { e f g a } music = { \repeat unfold 3 {\fragment.1} \repeat unfold 2 {\fragment.1 \fragment.2} } \score { \music \layout{} } is there any way to transform it in this: \score { { a b c d a b c d a b c d a b c d e f g a a b c d e f g a } \layout{} } ? ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user