lilypond-user
[Top][All Lists]
Advanced

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

Re: Add text to rehearsal mark


From: Ed Gordijn
Subject: Re: Add text to rehearsal mark
Date: Sun, 03 Apr 2011 22:38:53 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.13) Gecko/20101208 Thunderbird/3.1.7

Hi,

I decided to split the problem in pieces, starting with the allignment.

I have two options. The first option (IIa in the script) is how I would do this as I would do this writing a score, setting an override to adjust the allignment. This works fine but I don't know how I could calculate the override value in this way. Is It possible?

Option IIb is something that I got from a snippet about centering Dynamics. It works almost, but doesn't behave as I would expect when the mark is alligned on the clef. Can that be solved?

Greetings, Ed

Op 01-04-11 13:57, Ed Gordijn schreef:
Hi,

I'am working on a music function that creates a rehearsal mark with
extra text added. It would be nice if the end result would be
something that would work as: \mark \default "text".
These are my first steps into the world of scheme, so I suppose that
some of my questions are rather basic.
The code below more or less works and shows what I am trying to
achieve but is not perfect at all! So, I need some help to solve the
drawbacks.

Here are the issues that need attention:
1 - I would like to use the current format for the rehearsal mark. Is
it possible to call/use the current Score.markFormatter and store the
mark in a markup-variable?
2 - Now I redefine the Score.markFormater with "/once /set" but
"/once" generates warnings. What is wrong?
3 - Is it possible to avoid the /set Score.markFormatter and use the
/mark /markup /center-at-mark directly?
     I could use [1] to retrieve the current mark and should increment
the counter: Score.rehearsalMark = Score.rehearsalMark + 1
4 - Allignment is ok but the extend is not correct, see the allignment
of the first rehearsal mark that moves up because of the second mark.

Any advise?

Greetings, Ed

%%% Example

\version "2.13.39"

#(define-markup-command (center-at-mark layout props mark text)
(markup? string?)
  "x-align on the center of the rehaersal mark"
  (let* (
              (txt (markup #:normal-text #:bold #:normalsize #:concat
(" " text)))

              (txt-stencil  (interpret-markup layout props txt))
            (txt-x-ext    (ly:stencil-extent txt-stencil X))
            (txt-width    (- (cdr txt-x-ext)(car txt-x-ext)))
             )

             (interpret-markup layout props
               (markup #:hspace 0 #:translate (cons txt-width 0)
                       #:concat (mark txt)))
  ))


BoxMarkText = #(define-music-function (parser location AddText) (string?)
"Create a Rehearsal mark and add the string AddText"
#{
    % Redefine the Rehearsal mark
    % \once does work but generates multiple warning.
    \once \set Score.markFormatter = #(lambda (mark context)
                                      (markup #:center-at-mark
(format-mark-box-numbers mark context)$AddText))
    \mark \default
#})


\score {
    \relative c'' {

        \clef "G"
        \key c \major
        \time 4/4

        % Rehearsal mark
        \set Score.rehearsalMark = #10
        \set Score.markFormatter = #format-mark-box-numbers
        \mark \default
        c1 \bar "||"

        % Add text to the next rehearsal mark
        \BoxMarkText #"Theme from 007"
        e( f)

        % Revert to default mark
        \mark \default
        g( e) \break
   }
}

\layout{
    indent = 0
    ragged-right = ##t
}
%%% end of example




Attachment: CenterMark.ly
Description: Text document

Attachment: CenterMark.pdf
Description: Adobe PDF document


reply via email to

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