[prev in list] [next in list] [prev in thread] [next in thread] 

List:       lilypond-user
Subject:    help with writing scheme function for divisi
From:       Shevek <saul () saultobin ! com>
Date:       2011-10-28 5:13:52
Message-ID: 32736042.post () talk ! nabble ! com
[Download RAW message or body]

I just hacked together a couple simple functions to streamline the process of
divisi writing. They basically work, but I have a couple issues. First, why
does the instrumentCueName display three times? Is there a way to get it to
only display once? Second, it's a bit annoying to have to enter \voiceOne
and \oneVoice in the non-divisi voice. Is there a way to e.g. set \oneVoice
not for the current context, but rather for a different named context?


\version "2.14.2"
\language "english"

\paper {
  left-margin = 1\in
  right-margin = 1\in
  top-margin = 1\in
  bottom-margin = 1\in
  ragged-bottom = ##t
  oddFooterMarkup=##f
  oddHeaderMarkup=##f
  bookTitleMarkup = ##f
  scoreTitleMarkup = ##f
}

divisiDown = #(define-music-function
  (parser location staff grp_name s1_name s2_name)
  (string? markup? markup? markup?)
  (make-sequential-music
    (list
      #{
        \set Staff.shortInstrumentName = $s1_name
      #}
      (make-music
        'ContextChange
        'change-to-id staff
        'change-to-type 'Staff)
      #{
        \set StaffGroup.shortInstrumentName = $grp_name
        \set Staff.shortInstrumentName = $s2_name
        \oneVoice
      #}
      )
    )
  )

divisiUp = #(define-music-function
  (parser location staff grp_name s_name cue)
  (string? markup? markup? markup?)
  (make-sequential-music
    (list
      (make-music
        'ContextChange
        'change-to-id staff
        'change-to-type 'Staff)
      #{
        \voiceTwo
        \set StaffGroup.shortInstrumentName = $grp_name
        \set Staff.shortInstrumentName = $s_name
        \set Staff.instrumentCueName = $cue
      #}
      )
    )
  )

obI = \relative c'' {
  \tag #'score \voiceOne
  c4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
  \tag #'score \oneVoice
  c4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
  \tag #'score \voiceOne
  c4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
}

obII = \relative c' {
  \tag #'score \voiceTwo
  e4 f g f |
  e4 f g f |
  e4 f g f |
  e4 f g f |
  \tag #'score \divisiDown #"Ob2" "Oboe  " "1" "2"
  e4 f g f |
  e4 f g f |
  e4 f g f |
  e4 f g f |
  \tag #'score \divisiUp #"Ob1" "Oboe  " \markup \column {"1" "2"} "a2"
  c'4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
}

global = {
  s1*4 | \break
  s1*4 | \break
  s1*4 |
}

\score {
  \keepWithTag #'score <<
    \new StaffGroup \with {
      instrumentName = "Oboe 1-2"
      shortInstrumentName = "Ob. 1-2"
      systemStartDelimiter = #'SystemStartSquare
      %This is to keep the bracket from displaying when there is only one
staff
      \override SystemStartSquare #'collapse-height = #5
    } <<
      \new Staff = "Ob1" << \global <<
          \obI
          \\
          \obII
        >>
      >>
      \new Staff = "Ob2" \with {
        %This is all from a snippet to have the second staff display only
when
        %There are notes in it
        \remove "Axis_group_engraver"
        \consists "Hara_kiri_engraver"
        \override Beam #'auto-knee-gap = #'()
        \override VerticalAxisGroup #'remove-empty = ##t
        \override VerticalAxisGroup #'remove-first = ##t 
      } \global
    >>
  >>
  \layout {}
}

-- 
View this message in context: \
http://old.nabble.com/best-practices-for-divisi-string-writing-tp32503916p32736042.html
 Sent from the Gnu - Lilypond - User mailing list archive at Nabble.com.


[Attachment #3 (text/html)]

I just hacked together a couple simple functions to streamline the process of divisi \
writing. They basically work, but I have a couple issues. First, why does the \
instrumentCueName display three times? Is there a way to get it to only display once? \
Second, it's a bit annoying to have to enter \voiceOne and \oneVoice in the \
non-divisi voice. Is there a way to e.g. set \oneVoice not for the current context, \
but rather for a different named context?

<pre>
\version "2.14.2"
\language "english"

\paper {
  left-margin = 1\in
  right-margin = 1\in
  top-margin = 1\in
  bottom-margin = 1\in
  ragged-bottom = ##t
  oddFooterMarkup=##f
  oddHeaderMarkup=##f
  bookTitleMarkup = ##f
  scoreTitleMarkup = ##f
}

divisiDown = #(define-music-function
  (parser location staff grp_name s1_name s2_name)
  (string? markup? markup? markup?)
  (make-sequential-music
    (list
      #{
        \set Staff.shortInstrumentName = $s1_name
      #}
      (make-music
        'ContextChange
        'change-to-id staff
        'change-to-type 'Staff)
      #{
        \set StaffGroup.shortInstrumentName = $grp_name
        \set Staff.shortInstrumentName = $s2_name
        \oneVoice
      #}
      )
    )
  )

divisiUp = #(define-music-function
  (parser location staff grp_name s_name cue)
  (string? markup? markup? markup?)
  (make-sequential-music
    (list
      (make-music
        'ContextChange
        'change-to-id staff
        'change-to-type 'Staff)
      #{
        \voiceTwo
        \set StaffGroup.shortInstrumentName = $grp_name
        \set Staff.shortInstrumentName = $s_name
        \set Staff.instrumentCueName = $cue
      #}
      )
    )
  )

obI = \relative c'' {
  \tag #'score \voiceOne
  c4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
  \tag #'score \oneVoice
  c4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
  \tag #'score \voiceOne
  c4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
}

obII = \relative c' {
  \tag #'score \voiceTwo
  e4 f g f |
  e4 f g f |
  e4 f g f |
  e4 f g f |
  \tag #'score \divisiDown #"Ob2" "Oboe  " "1" "2"
  e4 f g f |
  e4 f g f |
  e4 f g f |
  e4 f g f |
  \tag #'score \divisiUp #"Ob1" "Oboe  " \markup \column {"1" "2"} "a2"
  c'4 d e d |
  c4 d e d |
  c4 d e d |
  c4 d e d |
}

global = {
  s1*4 | \break
  s1*4 | \break
  s1*4 |
}

\score {
  \keepWithTag #'score <<
    \new StaffGroup \with {
      instrumentName = "Oboe 1-2"
      shortInstrumentName = "Ob. 1-2"
      systemStartDelimiter = #'SystemStartSquare
      %This is to keep the bracket from displaying when there is only one staff
      \override SystemStartSquare #'collapse-height = #5
    } <<
      \new Staff = "Ob1" << \global <<
          \obI
          \\
          \obII
        >>
      >>
      \new Staff = "Ob2" \with {
        %This is all from a snippet to have the second staff display only when
        %There are notes in it
        \remove "Axis_group_engraver"
        \consists "Hara_kiri_engraver"
        \override Beam #'auto-knee-gap = #'()
        \override VerticalAxisGroup #'remove-empty = ##t
        \override VerticalAxisGroup #'remove-first = ##t 
      } \global
    >>
  >>
  \layout {}
}
</pre>
<br><hr align="left" width="300">
View this message in context: <a \
href="http://old.nabble.com/best-practices-for-divisi-string-writing-tp32503916p32736042.html">help \
with writing scheme function for divisi</a><br> Sent from the <a \
href="http://old.nabble.com/Gnu---Lilypond---User-f1722.html">Gnu - Lilypond - User \
mailing list archive</a> at Nabble.com.<br>



[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic