lilypond-user
[Top][All Lists]
Advanced

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

Re: conditional branch within scheme


From: Jan-Peter Voigt
Subject: Re: conditional branch within scheme
Date: Mon, 23 Apr 2012 20:10:40 +0200

Dear Stefan,

here's a try, that has a parameter dir, which takes a symbol. If the symbol 
equals 'above, the Staff is aligned above, else below:
--snip--
\version "2.14.2"
ossiastaff = #(define-music-function (parser location x dir y) ( string? 
symbol? ly:music? )
  (let ((align (if (eq? 'above dir) #{ \set Staff.alignAboveContext = $x #} #{ 
\set Staff.alignBelowContext = $x #})))
  #{ 
   \new Staff = "ossia" \with { 
      \override Clef #'stencil = ##f
      \override KeySignature #'stencil = ##f
      \override TimeSignature #'stencil = ##f
      fontSize = #-3
      \override StaffSymbol #'staff-space = #(magstep -3)
      \override StaffSymbol #'thickness = #(magstep -3)
    } {  $align \override PianoStaff.SpanBar #'glyph-name = #":" $y }  
  #}
))

\score {
  \new PianoStaff <<
    \new Staff="mainstaff" \relative c'' { \time 3/4 \key g \major
          d4 g,8 a b c d4 g, g 
          << {  e'4  c8 \mordent d e fis g4 g, g   } { \ossiastaff "mainstaff" 
#'above { s4 c32[ b c16.] s4 s4 }  } >> 
    }
  >>
}
\score {
  \new PianoStaff <<
    \new Staff="mainstaff" \relative c'' { \time 3/4 \key g \major
          d4 g,8 a b c d4 g, g 
          << {  e'4  c8 \mordent d e fis g4 g, g   } { \ossiastaff "mainstaff" 
#'below { s4 c32[ b c16.] s4 s4 }  } >> 
    }
  >>
}
--snip--

If you want to use strings "above" and "below", you have to compare them with 
string=?

HTH
Cheers, Jan-Peter

Am 22.04.2012 um 20:27 schrieb Stefan Thomas:

> Dear community,
> I've written some scheme-code for making it easier to create ossia-staffs. 
> The syntax for the code I've created is \ossiastaff "staffname" { music} 
> It works fine but now it works only for ossia-staffs above. I would prefer a 
> syntax like
> \ossiastaff "staffname" "above" (or below) { music} 
> Here is my code:
> 
> 
> \version "2.14.2"
> ossiastaff = #(define-music-function (parser location x y) ( string? 
> ly:music?  )
>   #{ 
>    \new Staff = "ossia" \with { 
>      alignAboveContext = $x
>       \override Clef #'stencil = ##f
>       \override KeySignature #'stencil = ##f
>       \override TimeSignature #'stencil = ##f
>       fontSize = #-3
>       \override StaffSymbol #'staff-space = #(magstep -3)
>       \override StaffSymbol #'thickness = #(magstep -3)
>     } { \override PianoStaff.SpanBar #'glyph-name = #":" $y }  
> #})
> 
> mainthing = \relative c'' { \time 3/4 \key g \major
> d4 g,8 a b c d4 g, g 
> <<    {  e'4  c8 \mordent d e fis g4 g, g   } { \ossiastaff "mainstaff" {  
>       
>       s4 c32[ b c16.] s4 s4 }  } >> 
>   
> }
> 
> \score {
>   \new PianoStaff <<
>   \new Staff="mainstaff" \mainthing
>   
> >>
> }
> 
> 
> 
> _______________________________________________
> lilypond-user mailing list
> address@hidden
> https://lists.gnu.org/mailman/listinfo/lilypond-user




reply via email to

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