lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Sending around contexts


From: Kieren MacMillan
Subject: Re: Sending around contexts
Date: Sun, 22 Nov 2020 16:26:31 -0500

Hi Aaron,

> The context is not being kept alive long enough.  Change s1 to at least s1*4:

Thanks. (Valentin also sent me that hint off-line.)

I’m trying to send music to a context "far away".
Any thoughts on how this can be done?
The snippet below doesn’t work as I would expect it to.

Thanks,
Kieren.

%%%
\version "2.20"

\layout {
  \context {
    \name "Notes"
    \type "Engraver_group"
  }
  \context {
    \Voice
    \accepts "Notes"
  }
  \context {
    \name "Container"
    \type "Engraver_group"
    \accepts "Notes"
    \accepts "Voice"
  }
  \context {
    \Staff
    \accepts "Container"
  }
  \context {
    \Dynamics
    \accepts "Container"
  }
}

send =
#(define-music-function (ctxname ctxlabel music1 music2) (string? string? 
ly:music? ly:music?)
   #{
     << #music1 \new Container \new Notes { \change #ctxname = #ctxlabel 
#music2 } >>
   #})

pfdyn = \send Container "piano_dynamics" \etc

piano_upper = {
  c'4\p d' e' f'
  \pfdyn g'1 <>\mp
  g'4\f f' e' d'
  \send Container "test" g'4 { c''\f } f' e' d'
  c'1
}

piano_lower = {
  \clef bass
  c1
  g,1
  g,1
  c1
}

\score {
  <<
    \new Staff \new Container = "test" { #(skip-of-length piano_upper) }
    \new Staff { c''1 }
    \new Staff { c''1 }
    \new Staff { c''1 }
    \new Staff { c''1 }
    \new Staff { c''1 }
    \new PianoStaff <<
      \new Staff \piano_upper
      \new Dynamics \new Container = "piano_dynamics" { #(skip-of-length 
piano_upper) }
      \new Staff \piano_lower
    >>
  >>
  %%%  layout mod to show the centred dynamics
  \layout {
    \context {
      \PianoStaff
      \override VerticalAxisGroup.staff-staff-spacing.padding = #10
    }
  }
}
%%%
________________________________

Kieren MacMillan, composer (he/him/his)
‣ website: www.kierenmacmillan.info
‣ email: kieren@kierenmacmillan.info




reply via email to

[Prev in Thread] Current Thread [Next in Thread]