unfoldRepeats for midi

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

unfoldRepeats for midi

Paul Scott-3
2.13.1

I have read all of NR 3.5

If I have this structure:
global = { \repeat volta 2 s1*6 \alternative { { s1*2 } { s1*2 } } }

Should the following work to unfold the above repeats for a MIDI file?

\score{
  \new Score{ << { \unfoldRepeats \global } \melody >> }
  \midi{
    \context{ \Score tempoWholesPerMinute = #(ly:make-moment 120 4) }
  }
}

Thanks,

Paul Scott









_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: unfoldRepeats for midi

Mark Polesky

Paul Scott wrote:
> 2.13.1
> I have read all of NR 3.5
> Should the following work to unfold the above repeats for a MIDI
> file?

I'm assuming you read this page:
http://lilypond.org/doc/v2.13/Documentation/user/lilypond/Repeats-in-MIDI

Following the template provided there, I believe this should work:

\score {
  << { \unfoldRepeats \global } \melody >>
  \layout {
    % layout stuff...
  }
}
\score {
  << { \unfoldRepeats \global } \melody >>
  \midi {
    \context {
      \Score tempoWholesPerMinute = #(ly:make-moment 120 4)
    }
  }
}

Let me know if it doesn't. If it does, then the next question is:
Did you read NR 3.5.4 "Repeats in MIDI" and did you find it
confusing? If so, what exactly confused you? That way we can try
to make it clearer for future users, which is always important to
us!

HTH.
- Mark


     


_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: unfoldRepeats for midi

Paul Scott-3
Mark Polesky wrote:

> Paul Scott wrote:
>  
>> 2.13.1
>> I have read all of NR 3.5
>> Should the following work to unfold the above repeats for a MIDI
>> file?
>>    
>
> I'm assuming you read this page:
> http://lilypond.org/doc/v2.13/Documentation/user/lilypond/Repeats-in-MIDI
>  

I said I read all of 3.5 :)

> Following the template provided there, I believe this should work:
>
> \score {
>   << { \unfoldRepeats \global } \melody >>
>   \layout {
>     % layout stuff...
>   }
> }
> \score {
>   << { \unfoldRepeats \global } \melody >>
>   \midi {
>     \context {
>       \Score tempoWholesPerMinute = #(ly:make-moment 120 4)
>     }
>   }
> }
>
> Let me know if it doesn't.

It doesn't work.  At first I didn't use \unfoldRepeats for the graphical
output as you show above.  But adding the \unfoldRepeats to the first
(graphical) part the graphical music is unfolded in a strange way.  The
graphical music is generated with the repeat signs omitted but nothing
unfolded.  The music would be 16 bars long and it is but the last 6 bars
are blank.

Here is what I used last:

\version "2.13.1"
\include "english.ly"
#(set-global-staff-size 24)

global = { \repeat volta 2 s1*6 \alternative { { s1*2 } { s1*2 } } }
melody = \relative c' {
  \key d \major
  fs2 fs4. fs8 g4 fs e d d2( ~ d8 e8 d4) a2 a8 b d4 fs e2. fs4 e d e
  fs2 ~ fs8 g fs4 e1 e8 d ~ d2. ~ d1
}

\score {
  <<
    \new Staff = soprano <<
      \context Voice = soprano { << { \unfoldRepeats \global } \melody >> }
    >>
  >>
  \layout{ }
}

\score{
  \new Score{ << { \unfoldRepeats \global } \melody >> }
  \midi{
    \context{ \Score tempoWholesPerMinute = #(ly:make-moment 120 4) }
  }
}

Thanks,

Paul





_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user
Reply | Threaded
Open this post in threaded view
|

Re: unfoldRepeats for midi

Mark Polesky
Paul Scott wrote:
> It doesn't work.  At first I didn't use \unfoldRepeats for the
> graphical output as you show above.  But adding the
> \unfoldRepeats to the first (graphical) part the graphical music
> is unfolded in a strange way.  The graphical music is generated
> with the repeat signs omitted but nothing unfolded.  The music
> would be 16 bars long and it is but the last 6 bars are blank.


Okay, I looked into this, and here's what I've learned.

> global = { \repeat volta 2 s1*6 \alternative { { s1*2 } { s1*2 } } }

Change s1*6 to { s1*6 }. The \repeat syntax is
  \repeat volta repeatcount musicexpr
and all music expressions require curly braces.


> \score {
> <<
>   \new Staff = soprano <<
>     \context Voice = soprano { << { \unfoldRepeats \global } \melody >> }
>   >>
> >>
> \layout{ }
> }

If you're going to use \unfoldRepeats in a \score with \layout, it
doesn't make sense to apply it to only one music expression if
there are other simultaneous expressions. Since \global and
\melody are simultaneous expressions, move \unfoldRepeats outside:

\score {
  <<
  \new Staff = soprano
    <<
    \context Voice = soprano
      \unfoldRepeats { << \global \melody >> }
    >>
  >>
  \layout{ }
}

However, it may make even more sense to apply \unfoldRepeats to
the whole score, so you don't have to keep applying it to other
voices (should there be any)...

\score {
  \unfoldRepeats
  <<
  \new Staff = soprano
    <<
    \context Voice = soprano { << \global \melody >> }
    >>
  >>
  \layout{ }
}

Also consider Staff and Voice naming. Are you going to have
non-soprano Voices in the soprano Staff? If not, you probably
don't need the \context Voice = soprano since a Voice context is
implicitly created with any music expression (though there are
reasons for explicitly instantiating the Voice context). Either
way (and honestly I don't know if this makes a difference), I
wouldn't want two different contexts with the same name, even if
they are nested within each other. You might consider sopranoStaff
and sopranoVoice, for instance.

Also, << and >> are only needed when there's more than one
simultaneous expression. So if sopranoStaff will only contain
sopranoVoice, you could do this:

\score {
  \unfoldRepeats
  <<
  \new Staff = sopranoStaff
    \context Voice = sopranoVoice { << \global \melody >> }
  >>
  \layout { }
}

And if << and >> enclose simultaneous expressions which already
have curly braces built into their definition -- like \global and
\melody do, you don't need an extra pair of curly braces around
the << >>.

\score {
  \unfoldRepeats
  <<
  \new Staff = sopranoStaff
    \context Voice = sopranoVoice << \global \melody >>
  >>
  \layout { }
}

I've left the outer << >> with the assumption that other voices
will eventually be added, but if not, you could remove those too.

Unfortunately, after all this, I've learned that \unfoldRepeats
doesn't natively work when the repeats are in an expression
separate from the notes, even if they're funneled together before
calling \unfoldRepeats. See
http://lists.gnu.org/archive/html/lilypond-devel/2009-06/msg00161.html
for a response to my post on the developers mailing-list regarding
this question.

So you must do something like this:

global = { \key d \major }
melody = \relative c' {  
  \repeat volta 2 {
    fs2 fs4. fs8
    g4 fs e d
    d2( ~ d8 e8 d4)
    a2 a8 b d4
    fs e2.
    fs4 e d e
  }
  \alternative {
    {
      fs2 ~ fs8 g fs4
      e1
    } {
      e8 d ~ d2. ~
      d1
    }
  }
}

\score {
  \unfoldRepeats
  <<
  \new Staff = sopranoStaff
    \context Voice = sopranoVoice << \global \melody >>
  >>
  \layout { }
}

Also, in your \score with the \midi block, you have this line:
> \new Score{ << { \unfoldRepeats \global } \melody >> }

I don't think \new Score is used anymore. You could reduce this
line to

  \unfoldRepeats
  <<
  \melody
  >>

I've left the << >> with the assumption that other voices will
eventually be added, and if so, consider renaming "melody" to
something like "sopMusic". If "melody" is the only voice, then of
course you don't need the << >>, and you can just do

  \unfoldRepeats \melody


\score {
  \unfoldRepeats
  <<
  \melody
  >>
  \midi {
    \context {
      \Score tempoWholesPerMinute = #(ly:make-moment 120 4)
    }
  }
}

Also, use \new instead of \context when a Voice first appears. Not
strictly necessary, but in complex scores, it's helpful to be able
to find the first instance of a specific context.

One last note: it may save space to put a lot of notes on one line
in your ly file, but it's easier for others to read your code if
it's nicely indented.

I've attached a working version of the file.

HTH.
- Mark



     
_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user

unfold-repeats.ly (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: unfoldRepeats for midi

Paul Scott-3
Hi Mark,

After I wrote most of what I wrote below I discovered your comment  
about your thread on the developers list.  I haven't read that thread  
yet but it seems to show that unfoldRepeats is not a very useful  
command.

Thanks, Mark, for all the work you have done on this.  Unfortunately  
you have gone in a direction that is not useful to me and have left  
me without a useful answer.

The most important thing is that I want the timing structure in my  
\global as I originally had it so that I don't have to duplicate it  
for everything part or voice.  I have tried to make a few simple  
changes to your code to get back to my structure and no longer have  
working code.  I have attached that code.


I will also make some comments on your thoughts below.

On Jun 6, 2009, at 1:19 PM, Mark Polesky wrote:

> Paul Scott wrote:
>> It doesn't work.  At first I didn't use \unfoldRepeats for the
>> graphical output as you show above.  But adding the
>> \unfoldRepeats to the first (graphical) part the graphical music
>> is unfolded in a strange way.  The graphical music is generated
>> with the repeat signs omitted but nothing unfolded.  The music
>> would be 16 bars long and it is but the last 6 bars are blank.
>
>
> Okay, I looked into this, and here's what I've learned.
>
>> global = { \repeat volta 2 s1*6 \alternative { { s1*2 } { s1*2 } } }
>
> Change s1*6 to { s1*6 }. The \repeat syntax is
>   \repeat volta repeatcount musicexpr
> and all music expressions require curly braces.

This is simply not true.  I have done this and similar things many  
times.  In most or all of the programming languages I have written  
code in and in Lilypond curly braces are only needed to combine more  
than one simple piece of code into a single entity.  For example
repeat unfold 25 d16
works just fine.


>
>
>> \score {
>> <<
>>   \new Staff = soprano <<
>>     \context Voice = soprano { << { \unfoldRepeats \global }  
>> \melody >> }
>>>>
>>>>
>> \layout{ }
>> }
>
> If you're going to use \unfoldRepeats in a \score with \layout, it
> doesn't make sense to apply it to only one music expression if
> there are other simultaneous expressions. Since \global and
> \melody are simultaneous expressions, move \unfoldRepeats outside:

I think it does make sense to keep the timing structure separate from  
the pitch structure.  I know there are other Lily users who do the  
same thing.


>
> \score {
>   <<
>   \new Staff = soprano
>     <<
>     \context Voice = soprano
>       \unfoldRepeats { << \global \melody >> }
>>>
>>>
>   \layout{ }
> }
>
> However, it may make even more sense to apply \unfoldRepeats to
> the whole score, so you don't have to keep applying it to other
> voices (should there be any)...

I didn't want the written music to be unfolded.

>
> Also consider Staff and Voice naming. Are you going to have
> non-soprano Voices in the soprano Staff? If not, you probably
> don't need the \context Voice = soprano since a Voice context is
> implicitly created with any music expression (though there are
> reasons for explicitly instantiating the Voice context). Either
> way (and honestly I don't know if this makes a difference), I
> wouldn't want two different contexts with the same name, even if
> they are nested within each other. You might consider sopranoStaff
> and sopranoVoice, for instance.

This was a quick attempt based on old code of mine and was not  
totally cleaned up.

>
> Also, << and >> are only needed when there's more than one
> simultaneous expression. So if sopranoStaff will only contain
> sopranoVoice, you could do this:
>
> \score {
>   \unfoldRepeats
>   <<
>   \new Staff = sopranoStaff
>     \context Voice = sopranoVoice { << \global \melody >> }
>>>
>   \layout { }
> }
>
> And if << and >> enclose simultaneous expressions which already
> have curly braces built into their definition -- like \global and
> \melody do, you don't need an extra pair of curly braces around
> the << >>.

I do know that.

>
> \score {
>   \unfoldRepeats
>   <<
>   \new Staff = sopranoStaff
>     \context Voice = sopranoVoice << \global \melody >>
>>>
>   \layout { }
> }
>
> I've left the outer << >> with the assumption that other voices
> will eventually be added, but if not, you could remove those too.
>
> Unfortunately, after all this, I've learned that \unfoldRepeats
> doesn't natively work when the repeats are in an expression
> separate from the notes, even if they're funneled together before
> calling \unfoldRepeats. See
> http://lists.gnu.org/archive/html/lilypond-devel/2009-06/msg00161.html
> for a response to my post on the developers mailing-list regarding
> this question.

I hadn't read this part when I did my testing and wrote what I wrote  
above.  I will check out that thread.  If that is true than  
unfoldRepeats seems pointless to me.

Your code misses any usefulness of unfoldRepeats which you must have  
have discovered in your other thread.

>
> One last note: it may save space to put a lot of notes on one line
> in your ly file, but it's easier for others to read your code if
> it's nicely indented.


Emacs indents my code just fine but sticking to one bar per line  
would take far too much scrolling in much of the music I work on.  My  
compromise is to never break a line in the middle of a bar.

Thanks again,

Paul



_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user

unfold-repeatspaul.ly (1K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: unfoldRepeats for midi

Mark Polesky
In reply to this post by Paul Scott-3

Paul Scott wrote:
>> Change s1*6 to { s1*6 }. The \repeat syntax is
>>  \repeat volta repeatcount musicexpr
>> and all music expressions require curly braces.
>
> This is simply not true.

I now see that I was wrong about that, sorry. This construct does
in fact work:

\relative {
  \repeat volta 2
  a'1
  \alternative {
    { b }
    { c }
  }
}


******


>> If you're going to use \unfoldRepeats in a \score with
>> \layout, it doesn't make sense to apply it to only one music
>> expression if there are other simultaneous expressions. Since
>> \global and \melody are simultaneous expressions, move
>> \unfoldRepeats outside:
>
> I think it does make sense to keep the timing structure separate
> from the pitch structure.  I know there are other Lily users who
> do the same thing.

Yes, I do too. The approach works marvelously when setting
contemporary ensemble works which have meter changes in every
other measure. It is easy to write one "meters" expression and
funnel that into all the voices. That saves a lot of file-space,
typing, and aggravation.

Regarding my original comment though, my point was that
   << { \unfoldRepeats \global } \melody >>
ought to unfold the spacers only, and not the actual notes. But
it's a moot point, because that's what \unfoldRepeats does anyway,
even if you type
  \unfoldRepeats << \global \melody >>
Though I do agree that it would be useful if it worked the way you
suggest. Let's see if something comes out of the -devel thread.


******


>> However, it may make even more sense to apply \unfoldRepeats
>> to the whole score, so you don't have to keep applying it to
>> other voices (should there be any)...
>
> I didn't want the written music to be unfolded.

Then remove \unfoldRepeats from the \score block that has \layout
and only use \unfoldRepeats from the \score block that has \midi.


******


> I hadn't read this part when I did my testing and wrote what I
> wrote above.  I will check out that thread.  If that is true
> than unfoldRepeats seems pointless to me.
>
> Your code misses any usefulness of unfoldRepeats which you must
> have discovered in your other thread.

I think that's somewhat exaggerated. \unfoldRepeats is not
pointless, it's just not as advanced as you want it to be. Let's
see if something comes out of the -devel thread.


******


> Emacs indents my code just fine but sticking to one bar per line
> would take far too much scrolling in much of the music I work
> on.  My compromise is to never break a line in the middle of a
> bar.

That's fine, but keep in mind that it's easier for others to spot
errors in your code if it's nicely organized. Consequently, you're
more likely to get a response if it is. A proofreader may end up
reformatting your code anyway just so s/he can read it clearly.


******


> Thanks again

Happy to help.
- Mark


     


_______________________________________________
lilypond-user mailing list
[hidden email]
http://lists.gnu.org/mailman/listinfo/lilypond-user