lilypond-user
[Top][All Lists]
Advanced

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

SOLUTION: Re: scheme function to align time-sig above nearest RehearsalM


From: Adam James Wilson
Subject: SOLUTION: Re: scheme function to align time-sig above nearest RehearsalMark?
Date: Fri, 19 Oct 2007 17:45:19 -0700

There is a much easier way to do this thant I originally imagined.  I
enclosed the function that I came up with and a snippet to
demonstrate.

When you compile, note that the only problem is that the alignment
behavior of the ReheasalMarks is undesirable, due to the ReheasalMark
being moved to the Staff context.

Marks at the beginning of the line incorrectly align to the bar
instead of the clef, and marks mid-system incorrectly align to
mid-system clefs when they should align to barlines.

I'm willing to sponsor a fix to this if anyone is willing.

This function is useful for proportionalNotation scores because it
automates placement of faux time signatures completely outside the
staff.  It is a little hacky because I found that the markformatter
function had to be re-defined in each instance in order to be able to
pass a different timesig argument to it.

Best,
Adam

%%%%% START EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\version "2.11.34"

#(set-global-staff-size 10)

\paper {
        #(set-paper-size "letter")
        ragged-right = ##t
        width = 11\in
        height = 8.5\in 
}

\layout {
        \context { \Score               
                \remove "Mark_engraver"
                \remove "Bar_number_engraver"
                \remove "Metronome_mark_engraver"
                \remove "Timing_translator"
                \remove "Time_signature_engraver"
                \remove "Default_bar_line_engraver"
                \override SpacingSpanner #'uniform-stretching = ##t
                \override SpacingSpanner #'strict-note-spacing = ##t
                proportionalNotationDuration = #(ly:make-moment 1 64)
        }
        \context { \Staff
                \consists "Timing_translator"
                \consists "Mark_engraver"
                \consists "Time_signature_engraver"
                \override TimeSignature #'transparent = ##t
                \override TimeSignature #'X-extent = #'(0 . 0)
                \override TimeSignature #'Y-extent = #'(0 . 0)
                \consists "Default_bar_line_engraver"
                %\override RehearsalMark #'self-alignment-X = #-1 %
        }
}

markTime = #(define-music-function (parser location timesig) (pair?)
        "Use this function a the start of every measure to place a barline, set
        the measureLength and beatLength of the bar, and draw a false
        time signature above the automatically-numbered RehearsalMark. If the
        time signature is the same as in the previous bar, then the car of the
        pair passed to the function should be set to zero."
        (let ((n (car timesig)) (d (cdr timesig)))
                (cond
                        ((= (car timesig) 0)
                        #{
                        #(define (my-mark-formatter mark context)
                                (markup
                                        (#:center-align (#:box (#:bold 
(number->string mark))))
                                )
                        )
                        \set Staff.markFormatter = #my-mark-formatter
                        \bar "|" \mark \default
                        #}
                        )
                        ((> (car timesig) 0)
                        #{
                        #(define (my-mark-formatter mark context)
                                (markup
                                        (#:column
                                                (       
                                                (#:center-align (#:raise 3.0 
(#:bold
                                                        (#:fontsize 5.0 
(#:number
                                                                (number->string 
$n))))))
                                                (#:center-align (#:raise 1.5 
(#:bold
                                                        (#:fontsize 5.0 
(#:number
                                                                (number->string 
$d))))))
                                                (#:center-align (#:box (#:bold 
(number->string
                                                        mark))))
                                                )
                                        )
                                )
                        )
                        \set Staff.markFormatter = #my-mark-formatter
                        \set Timing.beatLength = #(ly:make-moment $n $d)
                        \set Timing.measureLength = #(ly:make-moment $n $d)
                        \set Staff.timeSignatureFraction = $timesig
                        \bar "|" \mark \default
                        #}
                        )
                )
        )
)

\new Score <<
        \new StaffGroup <<
                \new Staff {
                        \markTime #'(3 . 4)
                        \clef treble
                        c'4 c'4 c'4
                        \markTime #'(3 . 32)
                        \clef bass
                        c'16 c'32
                        \markTime #'(0 . 0)
                        c'16 c'32
                        \markTime #'(3 . 4)
                        c'4 c'4 c'4
                        \bar "|"
                }
                \new Staff {
                        \markTime #'(3 . 32)
                        \clef bass
                        c'16 c'32
                        \markTime #'(0 . 0)
                        \clef treble
                        c'16 c'32
                        \markTime #'(3 . 4)
                        c'4 c'4 c'4
                        \markTime #'(0 . 0)
                        c'4 c'4 c'4
                        \bar "|"
                }
        >>
>>

%%%%% END EXAMPLE %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%




reply via email to

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