aligning variables with upbeats

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

aligning variables with upbeats

智樂喬
I'm sure I'm not the first person to ask this, but I'm looking for a clean, way to align music variables which begin with partial measures. For example,

\version "2.19.82"
partA = { c'2 b | R1*3 }
partB = { \partial 4 g4 | \bar "||"  c'1 }
\score { { \partA \partB } }

In reality, there would be multiple partBs and some of them would start with a pickup and some of them wouldn't. One think I can do is explicitly shorten the end of partA so that partB lines up, but it involves some mixing of content and structure. Is there a best practice for this situation?

Thanks,

Randy

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

Re: aligning variables with upbeats

Valentin Villenave-3
On 2/7/19, 智樂喬 <[hidden email]> wrote:
> In reality, there would be multiple partBs and some of them would start
> with a pickup and some of them wouldn't. One think I can do is explicitly
> shorten the end of partA so that partB lines up, but it involves some
> mixing of content and structure. Is there a best practice for this
> situation?

Greetings,
not really (as far as I know).
If you really want to keep your variables separate, you’ll have to use
simultaneous music instead of sequential expressions :

partA = { c'2 b | R1*3 }
partB = { \partial 4 g4 | \bar "||"  c'1 e }
\score {
  <<
    {\oneVoice \partA}
    \\
    {\oneVoice s1*15/4 \partB}
  >>
}

Cheers,
V.

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

Re: aligning variables with upbeats

Gianmaria Lari
In reply to this post by 智樂喬

On Thu, 7 Feb 2019 at 15:24, 智樂喬 <[hidden email]> wrote:
I'm sure I'm not the first person to ask this, but I'm looking for a clean, way to align music variables which begin with partial measures. For example,

\version "2.19.82"
partA = { c'2 b | R1*3 }
partB = { \partial 4 g4 | \bar "||"  c'1 }
\score { { \partA \partB } }

In reality, there would be multiple partBs and some of them would start with a pickup and some of them wouldn't. One think I can do is explicitly shorten the end of partA so that partB lines up, but it involves some mixing of content and structure. Is there a best practice for this situation?

I'm sorry, I don't understand what do you want to do. Could you try to explain again what you need?
Thank you, g.

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

Re: aligning variables with upbeats

David Kastrup
In reply to this post by Valentin Villenave-3
Valentin Villenave <[hidden email]> writes:

> On 2/7/19, 智樂喬 <[hidden email]> wrote:
>> In reality, there would be multiple partBs and some of them would start
>> with a pickup and some of them wouldn't. One think I can do is explicitly
>> shorten the end of partA so that partB lines up, but it involves some
>> mixing of content and structure. Is there a best practice for this
>> situation?
>
> Greetings,
> not really (as far as I know).
> If you really want to keep your variables separate, you’ll have to use
> simultaneous music instead of sequential expressions :
>
> partA = { c'2 b | R1*3 }
> partB = { \partial 4 g4 | \bar "||"  c'1 e }
> \score {
>   <<
>     {\oneVoice \partA}
>     \\
>     {\oneVoice s1*15/4 \partB}
>   >>
> }

Don't abuse \\ like that.  Rather use something like

\score {
  << \new Voice \partA
     \new Voice { s1*15/4 \part B }
  >>
}

But I guess that's weird (full-measure rest _and_ upbeat?).  I'd rather
just have two versions of partA, one before an upbeat and one not.

--
David Kastrup

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

Re: aligning variables with upbeats

智樂喬
In reply to this post by Gianmaria Lari
\version "2.19.82"
partA = { c'2 b | R1*3 }
partB = { \partial 4 g4 | \bar "||"  c'1 }
\score { { \partA \partB } }

Yes, so partA is a full four bars, the last bar being a measure of rest. partB starts after partA, but partB contains a pickup note, which should actually be in the last beat of partA's rest. If you run the code above, you should see that the G in partB gets its own one-beat measure instead of what I explained.

On Thu, Feb 7, 2019 at 10:53 PM Gianmaria Lari <[hidden email]> wrote:

On Thu, 7 Feb 2019 at 15:24, 智樂喬 <[hidden email]> wrote:
I'm sure I'm not the first person to ask this, but I'm looking for a clean, way to align music variables which begin with partial measures. For example,

\version "2.19.82"
partA = { c'2 b | R1*3 }
partB = { \partial 4 g4 | \bar "||"  c'1 }
\score { { \partA \partB } }

In reality, there would be multiple partBs and some of them would start with a pickup and some of them wouldn't. One think I can do is explicitly shorten the end of partA so that partB lines up, but it involves some mixing of content and structure. Is there a best practice for this situation?

I'm sorry, I don't understand what do you want to do. Could you try to explain again what you need?
Thank you, g.

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

Re: aligning variables with upbeats

智樂喬
In reply to this post by David Kastrup
Valentin:
If you really want to keep your variables separate, you’ll have to use simultaneous music instead of sequential expressions :

That's what I was afraid of…

{\oneVoice s1*15/4 \partB}

I'd like to avoid having to count bars/beats because it's kind of inefficient and makes using variables in this way a lot more clumsy and prone to error.

David:
I'd rather just have two versions of partA, one before an upbeat and one not.

I'd also like to avoid defining two variables, to keep things a little DRYer.

What I imagine might be idea would be a function which works similarly to skip-of-length, but takes an argument to subtract a specified length from the variable. I imagined something like the following:

#{skip-of-length (- (ly:length-of partA) (ly:make-moment 1/4))) \partB

And then put that in a function to make it more compact and easy to use.

Randy

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

Re: aligning variables with upbeats

Mats Bengtsson-4
In reply to this post by 智樂喬

On 2019-02-07 15:08, 智樂喬 wrote:

> I'm sure I'm not the first person to ask this, but I'm looking for a
> clean, way to align music variables which begin with partial measures.
> For example,
>
> \version "2.19.82"
> partA = { c'2 b | R1*3 }
> partB = { \partial 4 g4 | \bar "||"  c'1 }
> \score { { \partA \partB } }
>
> In reality, there would be multiple partBs and some of them would
> start with a pickup and some of them wouldn't. One think I can do is
> explicitly shorten the end of partA so that partB lines up, but it
> involves some mixing of content and structure. Is there a best
> practice for this situation?

As illustrated by the diverse responses you already recevied, the
question is what you want to achieve.

I recently typeset a Telemann suite with a number of "movements" to be
played attacca, which in the original print was typeset without any
separation between these movements. I then took the typesetting decision
to keep it that way and used a solution more or less identical to your
example above, with an additional \bar "||" \break between these parts.
Thanks to the improvements introduced in Lilypond 2.19, these mid-piece
\partials work smoothly. However, I could also have chosen other ways to
typeset the music.

If this is a way of saving typing when typesetting music with recurring
material, you might be able to use \tag to handle slight variations,
such as shortening a measure that is to be followed by a pickup. Or
simply leave out the bar that varies, and insert it manually between the
music that's stored in variables.

    /Mats


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

Re: aligning variables with upbeats

Kieren MacMillan
In reply to this post by 智樂喬
Hi Randy,

> I'm looking for a clean, way to align music variables which begin with partial measures. For example,
>
> \version "2.19.82"
> partA = { c'2 b | R1*3 }
> partB = { \partial 4 g4 | \bar "||"  c'1 }
> \score { { \partA \partB } }

This is one of the few situations where I would whole-heartedly recommend using Lilypond’s \tag mechanism. (Most things that might seem to be good candidates for \tags are, in my opinion, better handled via the edition-engraver.) This is exactly how I keep different versions of songs from my musicals (e.g., show version, medley version, standalone version, etc.).

%%%  SNIPPET BEGINS  %%%
partA = {
  c'2 b |
  \tag #'full { R1*3 }
  \tag #'short { R1*2 r2 r4 }
}

partB = {
  \partial 4 g4 | \bar "||"  c'1
}

\score {
  { \keepWithTag #'full \partA }
}

\score {
  { \keepWithTag #'short \partA \partB }
}
%%%  SNIPPET ENDS  %%%

Hope that helps!
Kieren.
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


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

Re: aligning variables with upbeats

智樂喬
In reply to this post by Mats Bengtsson-4
As illustrated by the diverse responses you already recevied, the
question is what you want to achieve.

Yes… maybe I should think about that some more. Usually I spend more time looking at ways to "do it right" than actually just writing some music. It's a bad habit!
 
If this is a way of saving typing when typesetting music with recurring
material, you might be able to use \tag to handle slight variations,
such as shortening a measure that is to be followed by a pickup.

I'll look into that. It may be what I'm looking for.

Thanks!

Randy

On Thu, Feb 7, 2019 at 11:34 PM Mats Bengtsson <[hidden email]> wrote:

On 2019-02-07 15:08, 智樂喬 wrote:
> I'm sure I'm not the first person to ask this, but I'm looking for a
> clean, way to align music variables which begin with partial measures.
> For example,
>
> \version "2.19.82"
> partA = { c'2 b | R1*3 }
> partB = { \partial 4 g4 | \bar "||"  c'1 }
> \score { { \partA \partB } }
>
> In reality, there would be multiple partBs and some of them would
> start with a pickup and some of them wouldn't. One think I can do is
> explicitly shorten the end of partA so that partB lines up, but it
> involves some mixing of content and structure. Is there a best
> practice for this situation?

As illustrated by the diverse responses you already recevied, the
question is what you want to achieve.

I recently typeset a Telemann suite with a number of "movements" to be
played attacca, which in the original print was typeset without any
separation between these movements. I then took the typesetting decision
to keep it that way and used a solution more or less identical to your
example above, with an additional \bar "||" \break between these parts.
Thanks to the improvements introduced in Lilypond 2.19, these mid-piece
\partials work smoothly. However, I could also have chosen other ways to
typeset the music.

If this is a way of saving typing when typesetting music with recurring
material, you might be able to use \tag to handle slight variations,
such as shortening a measure that is to be followed by a pickup. Or
simply leave out the bar that varies, and insert it manually between the
music that's stored in variables.

    /Mats


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

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

Re: aligning variables with upbeats

智樂喬
In reply to this post by Kieren MacMillan
Hope that helps!

Yes, it does. I have no idea what the edition-engraver is, but I'm curious to read more about it when I have time.

Thanks!

Randy

On Thu, Feb 7, 2019 at 11:44 PM Kieren MacMillan <[hidden email]> wrote:
Hi Randy,

> I'm looking for a clean, way to align music variables which begin with partial measures. For example,
>
> \version "2.19.82"
> partA = { c'2 b | R1*3 }
> partB = { \partial 4 g4 | \bar "||"  c'1 }
> \score { { \partA \partB } }

This is one of the few situations where I would whole-heartedly recommend using Lilypond’s \tag mechanism. (Most things that might seem to be good candidates for \tags are, in my opinion, better handled via the edition-engraver.) This is exactly how I keep different versions of songs from my musicals (e.g., show version, medley version, standalone version, etc.).

%%%  SNIPPET BEGINS  %%%
partA = {
  c'2 b |
  \tag #'full { R1*3 }
  \tag #'short { R1*2 r2 r4 }
}

partB = {
  \partial 4 g4 | \bar "||"  c'1
}

\score {
  { \keepWithTag #'full \partA }
}

\score {
  { \keepWithTag #'short \partA \partB }
}
%%%  SNIPPET ENDS  %%%

Hope that helps!
Kieren.
________________________________

Kieren MacMillan, composer
‣ website: www.kierenmacmillan.info
‣ email: [hidden email]


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

Re: aligning variables with upbeats

David Kastrup
In reply to this post by 智樂喬
智樂喬 <[hidden email]> writes:

> I'd also like to avoid defining two variables, to keep things a little
> DRYer.
>
> What I imagine might be idea would be a function which works similarly to
> skip-of-length, but takes an argument to subtract a specified length from
> the variable. I imagined something like the following:
>
> #{skip-of-length (- (ly:length-of partA) (ly:make-moment 1/4))) \partB
>
> And then put that in a function to make it more compact and easy to use.

It won't give you multi-measure rests padded with ordinary rests.  It
might be a great addition to multi-measure rests if they self-padded
with ordinary rests for incomplete measures but it would likely not be
easy to implement properly.

--
David Kastrup

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

Re: aligning variables with upbeats

智樂喬
but it would likely not be
easy to implement properly.

That's what I figured… It's okay, I'll try what Mats and Kieren have suggested with the tags, and if that turns out to be more work than it's worth, then I can always just manually pad the variables with rests, I guess.

Thanks,

Randy

On Thu, Feb 7, 2019 at 11:52 PM David Kastrup <[hidden email]> wrote:
智樂喬 <[hidden email]> writes:

> I'd also like to avoid defining two variables, to keep things a little
> DRYer.
>
> What I imagine might be idea would be a function which works similarly to
> skip-of-length, but takes an argument to subtract a specified length from
> the variable. I imagined something like the following:
>
> #{skip-of-length (- (ly:length-of partA) (ly:make-moment 1/4))) \partB
>
> And then put that in a function to make it more compact and easy to use.

It won't give you multi-measure rests padded with ordinary rests.  It
might be a great addition to multi-measure rests if they self-padded
with ordinary rests for incomplete measures but it would likely not be
easy to implement properly.

--
David Kastrup

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

Re: aligning variables with upbeats

Pedro Pessoa
In reply to this post by 智樂喬
Hello John,
I took this task as a way of learning a bit more about moments and durations
(and also, I wanted to achieve this a while ago). It is certainly not a very
robust or elegant solution, but seems to work for this particular case.

%% \makeRestOfLenght \mus "rest/skip" upbeat %%

\version "2.19.82"
partA = { c'2 b | R1*3 }
partB = { \partial 4 g4 | \bar "||"  c'1 }

#(define (make-dynamic-rest len event)
   "The rest/skip body."
   (make-music
    event ; To choose if it is gonna be Skip or Rest
    'duration
    ; intlog transforms the rational values used in Moments (the
denominator) into log values used in Durations.
    ; 1 (whole)->0
    ; 2 (half)->1
    ; 4 (quarter)->2 ... etc
    (ly:make-duration (ly:intlog2 len))))

#(define (makeRestofLog num den opts)
   "Logging function"
   (display (format "~%>> \\makeRestOfLenght:~%~A ~As of value ~A will be
created:~%" num opts den)))

makeRestOfLenght=
#(define-scheme-function (mus opts upbeat)(ly:music? string? ly:music?)
   "Creates a series of rests/skips of the same length as the given music
minus an upbeat value. Opts are 'rest', 'skip'. Anything else calls 'rest'."
   (let* ((musLen (ly:music-length mus));
           (upBeatLen (ly:music-length upbeat))
           (musMinusUp (ly:moment-sub musLen upBeatLen))
           (den (ly:moment-main-denominator musMinusUp))
           (num (ly:moment-main-numerator musMinusUp))
           (event (cond
                   ((string>= opts "skip")
                    'SkipEvent)
                   ((string>= opts "rest")
                    'RestEvent)
                   (else
                    (set! opts "rest")
                    'RestEvent)
                   ))
           (rests '()))
     (makeRestofLog num den opts) ; Didatic logging.
   
     ; Iterate over the number of rest needed (given by the numerator).
     ; The value of the rest is given by the denominator.
     (let loop ((i 0))
       (if (< i num)
           (begin
            (set! rests (append rests (list (make-dynamic-rest den event))))
            (loop (+ i 1)))))
     (newline)
     (make-music
      'SequentialMusic
      'elements
      rests)
     ))

\score {
  \new Staff <<
    \new Voice \partA
    \new Voice {
      % \makeRestOfLenght \partA "rest" 4 % To visualize rests.
      \makeRestOfLenght \partA "skip" 4
      \partB
    }
  >>
}





--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

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

Re: aligning variables with upbeats

智樂喬
Thanks, Pedro, this is some interesting code! There's definitely something for me to learn here.

On Wed, Feb 13, 2019 at 4:13 AM Pedro Pessoa <[hidden email]> wrote:
Hello John,
I took this task as a way of learning a bit more about moments and durations
(and also, I wanted to achieve this a while ago). It is certainly not a very
robust or elegant solution, but seems to work for this particular case.

%% \makeRestOfLenght \mus "rest/skip" upbeat %%

\version "2.19.82"
partA = { c'2 b | R1*3 }
partB = { \partial 4 g4 | \bar "||"  c'1 }

#(define (make-dynamic-rest len event)
   "The rest/skip body."
   (make-music
    event ; To choose if it is gonna be Skip or Rest
    'duration
    ; intlog transforms the rational values used in Moments (the
denominator) into log values used in Durations.
    ; 1 (whole)->0
    ; 2 (half)->1
    ; 4 (quarter)->2 ... etc
    (ly:make-duration (ly:intlog2 len))))

#(define (makeRestofLog num den opts)
   "Logging function"
   (display (format "~%>> \\makeRestOfLenght:~%~A ~As of value ~A will be
created:~%" num opts den)))

makeRestOfLenght=
#(define-scheme-function (mus opts upbeat)(ly:music? string? ly:music?)
   "Creates a series of rests/skips of the same length as the given music
minus an upbeat value. Opts are 'rest', 'skip'. Anything else calls 'rest'."
   (let* ((musLen (ly:music-length mus));
           (upBeatLen (ly:music-length upbeat))
           (musMinusUp (ly:moment-sub musLen upBeatLen))
           (den (ly:moment-main-denominator musMinusUp))
           (num (ly:moment-main-numerator musMinusUp))
           (event (cond
                   ((string>= opts "skip")
                    'SkipEvent)
                   ((string>= opts "rest")
                    'RestEvent)
                   (else
                    (set! opts "rest")
                    'RestEvent)
                   ))
           (rests '()))
     (makeRestofLog num den opts) ; Didatic logging.

     ; Iterate over the number of rest needed (given by the numerator).
     ; The value of the rest is given by the denominator.
     (let loop ((i 0))
       (if (< i num)
           (begin
            (set! rests (append rests (list (make-dynamic-rest den event))))
            (loop (+ i 1)))))
     (newline)
     (make-music
      'SequentialMusic
      'elements
      rests)
     ))

\score {
  \new Staff <<
    \new Voice \partA
    \new Voice {
      % \makeRestOfLenght \partA "rest" 4 % To visualize rests.
      \makeRestOfLenght \partA "skip" 4
      \partB
    }
  >>
}





--
Sent from: http://lilypond.1069038.n5.nabble.com/User-f3.html

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

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