Re: Absolute temporal positioning of mm-rests

2018-03-10 Thread Malte Meyn



Am 09.03.2018 um 11:45 schrieb Arttu Punkkinen:


I was wondering, if there is a way to specify a multimeasure rest which 
length is only relatively defined so that it ends at predetermined bar 
number?


I often find myself needing to adjust or add material between 
multimeasure rests, which currently need manual adjustment to keep 
alignment.


Not for bar numbers but for “anchors” that can be placed in a separate 
music expression, you could use the code below. You find the file 
alignTo.ily attached. This is a modified version of the file posted 
here: http://lists.gnu.org/archive/html/lilypond-user/2015-07/msg00235.html


The following commands are defined:
• \anchor, to be used as
\anchor "anchorname"
• \until, to be used as
s \until "anchorname"
or
R \until "anchorname"
or even
f \until "anchorname"
The latter for long notes is probably useful only if you use the 
Completion_heads_engraver.

• \quoteUntil, to be used as
\quoteUntil "instrument" "anchorname"
Here you have to use \alignTo in the \addQuote command for correct results.
• \alignTo and \useAndAlignTo, to be used as
\alignTo \anchormusic \music
The former only makes use of the anchors, the latter also uses the music 
of \anchormusic (f. e. key signature changes).


Thanks to the original authors!

%%%

\version "2.19.81"

\include "alignTo.ily"

global = {
  \key es \major
  s1*3
  \anchor "1st theme"
  \time 3/4
  s2.*8
  \anchor "mid"
  s2.*4
  \anchor "coda"
  \tempo "Coda"
  s2. \bar "|."
}

flute = \relative {
  R \until "1st theme"
  es'4 f g as bes c d2.
  s \until "mid"
  es4 d c bes as g f es f es2.
}
\addQuote "flute" \alignTo \global \flute

clarinet = \relative {
  \transposition bes
  c'1
  R \until "mid"
  es4 f g as bes c
  \quoteUntil "flute" "coda"
  es2.
}
\addQuote "clarinet" \alignTo \global \clarinet

\new StaffGroup <<
  \new Staff \useAndAlignTo \global \flute
  \new Staff \transpose bes c' \useAndAlignTo \global \clarinet
>>
\version "2.19.25"

#(define anchor-color blue)

% slightly modified/improved version of
% alignTo from 
http://lists.gnu.org/archive/html/lilypond-user/2015-07/msg00235.html
alignTo =
#(define-music-function (conductor music) (ly:music? ly:music?)
   "Lengthen any note or rest in the sequence MUSIC just before each tag
that matches a tag in the sequence CONDUCTOR, so that the tags occur
at the same times from to the beginnings of MUSIC and CONDUCTOR."
   (define (find-sequence music)
 (or (fold-some-music
  (lambda (x) (music-is-of-type? x 'sequential-music))
  (lambda (x e1) (or e1 ; use the first nonempty sequence
 (let ((es (ly:music-property x 'elements)))
   (if (null? es) #f es
  #f
  music)
 (begin
  (ly:input-warning (ly:music-property music 'origin)
"alignTo: cannot find sequential music")
  '(
   (let loop ((aligner (find-sequence conductor))
  (alignee (find-sequence music))
  (time-left (ly:music-length conductor)))
 (case (length alignee)
   ((0) music)
   ((1) music)
   (else
(let* ((a (first alignee)) ; music that might be lengthened,
(b (second alignee)) ; if this music is tagged
; if a has an until property, add this to tag (which is b’s 
tags)
(tag (if (not (null? (ly:music-property a 'until)))
 (cons (ly:music-property a 'until)
   (ly:music-property b 'tags))
 (ly:music-property b 'tags)))
(tail (and (not (null? tag))
   (find-tail
(lambda (x)
  (not (null? (lset-intersection
   eq? tag
   (ly:music-property x 'tags)
aligner
  (if tail
  (let ((tail-length (ly:music-length
  (make-sequential-music tail
(if (ly:moment>
   #})

anchor =
#(define-music-function (text) (string?)
   (if (ly:get-option 'point-and-click)
   #{
 \tag #(string->symbol text)
 \single \override RehearsalMark.self-alignment-X = #LEFT
 \mark \markup \with-color #anchor-color #text
   #}
   #{
 \tag #(string->symbol text) s1*0
   #}))

until =
#(define-music-function (anchor) (string?)
   #{
 \tag #(string->symbol anchor) s1*0
   #})

% don’t redefine quoteUntil if advancedQuote.ily was included before
% because of different transposition behaviour
#(if (not (defined? 'quoteUntil))
 (define quoteUntil
   (define-music-function (what anchor) (string? string?)
 (make-music 'QuoteMusic
   'until (string->symbol anchor)
   'quoted-music-name 

Absolute temporal positioning of mm-rests

2018-03-09 Thread Arttu Punkkinen
Hi!

I was wondering, if there is a way to specify a multimeasure rest which
length is only relatively defined so that it ends at predetermined bar
number?

I often find myself needing to adjust or add material between multimeasure
rests, which currently need manual adjustment to keep alignment.

An example.
R1*4
c4 d e f
R1*4
g4 g g g

Now if we adjust the length of the middle section there, we need to adjust
multimeasure rests accordingly.

R1*4
c4 d e f
g4 e d c
R1*3
g4 g g g

So, if we had some "absolute bar alignment", it might make orchestral music
a bit easier.

Like...

\restUntil #5
c4 d e f
\restUntil #9
g4 g g g

Or do we perhaps already have a way for that?

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