lilypond-user
[Top][All Lists]
Advanced

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

Re: Minimum padding after barlines for notes with accidentals?


From: Markus Schneider
Subject: Re: Minimum padding after barlines for notes with accidentals?
Date: Thu, 14 Sep 2006 01:14:32 +0200

Here a fully automated function called "accidentalSpacer" which taks two
parameters:

1. the time signature (to obtain barlines)
2. a music variable to calculate the total amount of bars

The example shows the behaviour in 4/4, 2/4 and 1/4 time signatures.

If someone knows how to derive the time-signature from a given music
variable in scheme, we could reduce the input variables to only one (the
actual music).

Cheers,
Markus

%%%
\version "2.9.17"

music = \relative c'' {
  cis4 dis e fis |
  f ges b bes |
  b,! cis a g |
  g? f fis c |
  cis' c d d
}

accidentalSpacer = #(define-music-function (parser location timesig
duration ) (pair? ly:music?)
  (make-music
    'UnfoldedRepeatedMusic
    'elements
    '()
    'repeat-count
    (inexact->exact (round
    (/ (* (ly:moment-main-numerator   (ly:music-length duration))
          (cdr timesig))
       (* (ly:moment-main-denominator (ly:music-length duration))
          (car timesig)))))
    'element
    (make-music
        'SequentialMusic
        'elements
        (list (make-music
                'ContextSpeccedMusic
                'context-type
                'Staff
                'element
                (make-music
                  'OverrideProperty
                  'pop-first
                  #t
                  'grob-property-path
                  (list (quote left-padding))
                  'grob-value
                  0.8
                  'once
                  #t
                  'symbol
                  'AccidentalPlacement))
              (make-music
                  'EventChord
                  'elements
                  (list (make-music
                          'SkipEvent
                          'duration
                          (ly:make-duration 0 0 (car timesig) (cdr
timesig) ))))))))

\score {
  \new Staff <<
    \context Voice = "A" \music
    \context Voice = "A" \accidentalSpacer #'(4 . 4) \music
  >>
  \layout { indent = 0 ragged-last = ##t }
}

\score {
  \new Staff <<
    \context Voice = "B" { \time 2/4 \music }
    \context Voice = "B" \accidentalSpacer #'(2 . 4) \music
  >>
  \layout { indent = 0 ragged-last = ##t }
}

\score {
  \new Staff <<
    \context Voice = "C" { \time 1/4 \music }
    \context Voice = "C" \accidentalSpacer #'(1 . 4) \music
  >>
  \layout { indent = 0 ragged-last = ##t }
}
%%%







reply via email to

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