lilypond-user
[Top][All Lists]
Advanced

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

Ambitus - was:move clef


From: Thomas Morley
Subject: Ambitus - was:move clef
Date: Wed, 24 Jul 2013 00:14:31 +0200

2013/7/23 Bockett Hunter <address@hidden>:
> I'd like to get the ambitus after the modern clef signs, in the modern clef
> vertical location instead
> of the old clef vertical location.
>
> Here's code that shows what I've been doing.  The forum has given me a
> couple of workarounds,
> but I was hoping for something elegant.  Basically, I'd like to be able to
> activate the ambitus engraver
> at a specified time in the current context.
>
> \paper {
>  #(set-paper-size "letter")
>  %ragged-last-bottom = ##f
>  line-width = 6.5\in
>  left-margin = 1.0\in
>  bottom-margin = 0.5\in
>  top-margin = 0.5\in
> }
>
> \header{
>   title = \markup \center-column {
>     "Melodia Tertii Toni" }
>   composer = \markup { \small "Thomas Stoltzer" }
>   poet = "Handschrift 106,5 der Ratsschulbibliothek Zwickau"
>   \tagline = ##f
> }
>
> global = {
>
>   \version "2.14.2-1"
>   \set Score.skipBars = ##t
>
>
>   % incipit
>   %\once \override Score.SystemStartBracket #'transparent = ##t
>   \override Score.SpacingSpanner #'spacing-increment = #0.1 % tight spacing
>   \key c \major
>   \time 2/2
>   \once \override Staff.TimeSignature #'style = #'neomensural
>   \override Voice.NoteHead #'style = #'neomensural
>   \override Voice.Rest #'style = #'neomensural
>   \set Staff.printKeyCancellation = ##f
>   \cadenzaOn % turn off bar lines
>   \skip \longa
>   \once \override Staff.BarLine #'transparent = ##f
>   \bar "||"
>   \skip 1*1 % need this extra \skip such that clef change comes
>             % after bar line
>   \bar ""
>
>   % main
>   \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
>   \cadenzaOff % turn bar lines on again
>   \once \override Staff.Clef #'full-size-change = ##t
>   \set Staff.forceClef = ##t
>   \key c \major
>   \time 2/2
>   \override Voice.NoteHead #'style = #'default
>   \override Voice.Rest #'style = #'default
>
>   % FIXME: setting printKeyCancellation back to #t must not
>   % occur in the first bar after the incipit.  Dto. for forceClef.
>   % Therefore, we need an extra \skip.
>   \skip 1*1
>   \set Staff.printKeyCancellation = ##t
>   \set Staff.forceClef = ##f
>
> }
>
> discantusNotes = {
>     \set Staff.instrumentName = #"Discantus  "
>     \set Staff.midiInstrument = #"recorder"
>
>     % incipit
>     \clef "petrucci-c1"
>     c'\breve \skip \breve
>     % Skip to non-incipit music.
>     \skip 1*1 % one bar
>
>     % main
>     \clef "treble"
>     \relative c'{
>     c1 c'1
>
>       % let finis bar go through all staves
>       \override Staff.BarLine #'transparent = ##f
>
>       % finis bar
>       \bar "|."
>
>     }
> }
>
>
> vagansNotes = {
>     \set Staff.instrumentName = #"Vagans  "
>     \set Staff.midiInstrument = #"recorder"
>
>     % incipit
>     \clef "petrucci-c1"
>     e'\breve \skip \breve
>     \skip 1*1 % one bar
>
>     %main
>     \clef "treble"
>     \relative c' {
>
>       e1 b1
>
>       % let finis bar go through all staves
>       \override Staff.BarLine #'transparent = ##f
>
>       % finis bar
>       \bar "|."
>
>
>   }
>
> }
>
> altusNotes = {
>     \set Staff.instrumentName = #"Altus  "
>     \set Staff.midiInstrument = #"recorder"
>
>     % incipit
>     \clef "petrucci-c4"
>     \[a1. c'1\] \skip 2 \skip1
>     \skip 1*1 % one bar
>
>     %main
>     \clef "treble_8"
>     \relative c' {
>
>       a2. c2 b8 a8 b2
>
>       % let finis bar go through all staves
>       \override Staff.BarLine #'transparent = ##f
>
>       % finis bar
>       \bar "|."
>
>
>     }
> }
>
>
>
> tenorNotes = {
>     \set Staff.instrumentName = #"Tenor  "
>     \set Staff.midiInstrument = #"recorder"
>
>     % incipit
>     \clef "petrucci-c4"
>     c\breve \skip \breve
>     \skip 1*1 % one bar
>
>     % main
>     \clef "treble_8"
>     \relative c {
>
>       c1 c'1
>
>       % let finis bar go through all staves
>       \override Staff.BarLine #'transparent = ##f
>
>       % finis bar
>       \bar "|."
>
>     }
> }
>
> bassusNotes = {
>     \set Staff.instrumentName = #"Bassus  "
>     \set Staff.midiInstrument = #"recorder"
>
>     % incipit
>     \clef "bass"
>     f\breve \skip \breve
>     \skip 1*1 % one bar
>
>     % main
>     \clef "bass"
>     \relative c{
>
>       f1 f'1
>
>       % let finis bar go through all staves
>       \override Staff.BarLine #'transparent = ##f
>
>       % finis bar
>       \bar "|."
>
>     }
> }
>
>
> \score {
>   \new StaffGroup = choirStaff <<
>     \new Voice =
>       "discantusNotes" << \global \discantusNotes >>
>     \new Voice =
>       "vagansNotes" << \global \vagansNotes >>
>     \new Voice =
>       "altusNotes" << \global \altusNotes >>
>     \new Voice =
>       "tenorNotes" << \global \tenorNotes >>
>     \new Voice =
>       "bassusNotes" << \global \bassusNotes >>
>   >>
>   \layout {
>
>     #(layout-set-staff-size 18)
>
>     \context {
>       \Score
>
>       % no bars in staves
>       \override BarLine #'transparent = ##t
>
>       % incipit should not start with a start delimiter
>       \remove "System_start_delimiter_engraver"
>     }
>     \context {
>       \Voice
>       \consists "Ambitus_engraver"
>
>       % no slurs
>       \override Slur #'transparent = ##t
>
>       % Comment in the below "\remove" command to allow line
>       % breaking also at those barlines where a note overlaps
>       % into the next bar.  The command is commented out in this
>       % short example score, but especially for large scores, you
>       % will typically yield better line breaking and thus improve
>       % overall spacing if you comment in the following command.
>       \remove "Forbid_line_break_engraver"
>     }
>   }
>
> }
>
> On Mon, Jul 22, 2013 at 4:08 PM, Thomas Morley <address@hidden>
> wrote:
>>
>> 2013/7/22 Bockett Hunter <address@hidden>:
>> > Can this be used to change where the ambitus appears?
>>
>> Should be possible.
>> Example-code?
>>
>> Cheers,
>>   Harm
>
>

Hi,

please keep the discussion on the list. I tend to ignore private mails
for lily-help.
And the ambitus-problem is worth a new thread.

Anyway.
Below my own approach.
You can print an Ambitus if create a new Voice..
The main problem about putting "Ambitus_engraver" in newly created
Voices is, that I didn't manage to apply
\override BreakAlignment #'break-align-orders = ...
to an Ambitus in the middle of a line.
Additionally
\override Ambitus #'break-visibility = ...
has no effect. As well applying these commands to whatever context.

So here my very kludgy and clumsy workaround. Same attached.
For some cases you'll need to adjust the Ambitus manually via
\adjustMiddleOfLineAmbitus.

Note: You need a newer devel-version.
It will not compile with 2.14.2
With 2.16.2 it compiles, though
\noAmbitusAtLineEnd
will not work.


********************************************************************

\version "2.17.22"

#(define (look-up-for-parent name-symbol axis grob)
"
 Return the parent of @var{grob}, specified by it's @var{name-symbol} in
 axis @var{axis}.
 If not found, look up for the next parent.
"
 (let* ((parent (ly:grob-parent grob axis))
        (grob-name (lambda (x) (assq-ref (ly:grob-property x 'meta) 'name))))
 (cond
   ((not (ly:grob? parent))
    (ly:error
       (_"Perhaps typing error for \"~a\" or \"~a\" is not in the
parent-tree.")
       name-symbol name-symbol))
   ((not (equal? name-symbol (grob-name parent)))
    (look-up-for-parent name-symbol axis parent))
   (else parent))))

adjustMiddleOfLineAmbitus =
#(define-music-function (parser location val)(number?)
#{
  \once \override AmbitusNoteHead #'X-offset  =
   #(lambda (grob)
     (let* ((break-alignment (look-up-for-parent 'BreakAlignment X grob))
            (break-alignment-x-ext
             (interval-length (ly:grob-property break-alignment 'X-extent)))
            (layout (ly:grob-layout grob))
            (staff-space (ly:output-def-lookup layout 'staff-space)))
     (if (and (ly:item? grob) (= (ly:item-break-dir grob) 0))
         (+ break-alignment-x-ext staff-space val)
         0)))
#})

noAmbitusAtLineEnd = {
  \override AmbitusNoteHead #'before-line-breaking =
   #(lambda (grob)
     (if (and (ly:item? grob) (= (ly:item-break-dir grob) -1))
         (ly:grob-suicide! grob)))

  \override AmbitusLine #'before-line-breaking =
   #(lambda (grob)
     (if (and (ly:item? grob) (= (ly:item-break-dir grob) -1))
         (ly:grob-suicide! grob)))

  \override AmbitusAccidental #'before-line-breaking =
   #(lambda (grob)
     (if (and (ly:item? grob) (= (ly:item-break-dir grob) -1))
         (ly:grob-suicide! grob)))
}

ambitusLayout =
\with {
  \noAmbitusAtLineEnd
  \override BreakAlignment #'break-align-orders =
     ##(
       ;; end of line
        (left-edge
         breathing-sign
         clef
         key-cancellation
         key-signature
         staff-bar
         ambitus
         time-signature
         cue-clef
         custos)
       ;; middle of line
         (left-edge
         breathing-sign
         clef
         staff-bar
         key-cancellation
         key-signature
         time-signature
         cue-clef
         custos
         ambitus)
       ;; begin of line
         (left-edge
         breathing-sign
         clef
         key-cancellation
         key-signature
         staff-bar
         ambitus
         time-signature
         cue-clef
         custos))

  \override KeySignature #'space-alist =
    #'((time-signature extra-space . 1.15)
       (staff-bar extra-space . 1.1)
       (cue-clef extra-space . 0.5)
       (ambitus extra-space . 1.0)
       (right-edge extra-space . 0.5)
       (first-note fixed-space . 2.5))

  \override BarLine #'space-alist =
  #'((time-signature extra-space . 0.75)
     (custos minimum-space . 2.0)
     (clef minimum-space . 1.0)
     (key-signature extra-space . 1.0)
     (key-cancellation extra-space . 1.0)
       (first-note fixed-space . 1.3)
       (next-note semi-fixed-space . 0.9)
       (ambitus extra-space . 0.0)
       (right-edge extra-space . 0.0))

  \override Ambitus #'space-alist =
    #'((cue-end-clef extra-space . 0.5)
       (clef extra-space . 0.5)
       (cue-clef extra-space . 0.5)
       (key-signature extra-space . 0.0)
       (staff-bar extra-space . 0.0)
       (right-edge extra-space . 1.0)
       (time-signature extra-space . 0.8)
       (next-note semi-fixed-space . 0.9)
       (first-note fixed-space . 1))

  \override Clef #'space-alist =
    #'((cue-clef extra-space . 2.0)
       (staff-bar extra-space . 0.7)
       (ambitus extra-space . 0.8)
       (key-cancellation minimum-space . 3.5)
       (key-signature minimum-space . 3.5)
       (time-signature minimum-space . 3.2)
       (first-note minimum-fixed-space . 5.0)
       (next-note extra-space . 1.0)
       (right-edge extra-space . 0.5))
}

addAmbitusEngraver =
\with { \consists "Ambitus_engraver" }
        
%%% Examples
% Yours first. Please note: Apart from dealing with the Ambitus, I
improved your other code only occasionally.

\paper {
 #(set-paper-size "letter")
 %ragged-last-bottom = ##f
 line-width = 6.5\in
 left-margin = 1.0\in
 bottom-margin = 0.5\in
 top-margin = 0.5\in
}

\header{
  title = \markup \center-column { "Melodia Tertii Toni" }
  composer = \markup { \small "Thomas Stoltzer" }
  poet = "Handschrift 106,5 der Ratsschulbibliothek Zwickau"
  tagline = ##f
}

global = {
  \set Score.skipBars = ##t

  % incipit
  %\once \override Score.SystemStartBracket #'transparent = ##t
  \override Score.SpacingSpanner #'spacing-increment = #0.1 % tight spacing
  \key c \major
  \time 2/2
  \once \override Staff.TimeSignature #'style = #'neomensural
  \override Voice.NoteHead #'style = #'neomensural
  \override Voice.Rest #'style = #'neomensural
  \set Staff.printKeyCancellation = ##f
  \cadenzaOn % turn off bar lines
  s\longa
  \once \override Staff.BarLine #'transparent = ##f
  \bar "||"
  s1
  \bar ""

  % main

  \revert Score.SpacingSpanner #'spacing-increment % CHECK: no effect?
  \cadenzaOff % turn bar lines on again
  \once \override Staff.Clef #'full-size-change = ##t
  \set Staff.forceClef = ##t
  \key c \major
  \once \override Staff.TimeSignature #'X-extent = #'(-2 . 1)
  \time 2/2
  \revert NoteHead #'style
  \revert Rest #'style

  % FIXME: setting printKeyCancellation back to #t must not
  % occur in the first bar after the incipit.  Dto. for forceClef.
  % Therefore, we need an extra \skip.
  s1
  \set Staff.printKeyCancellation = ##t
  \set Staff.forceClef = ##f

}

discantusNotes = {
    \set Staff.instrumentName = #"Discantus  "
    \set Staff.midiInstrument = #"recorder"

    % incipit
    \clef "petrucci-c1"
    c'\breve %\skip \breve
    s1*3

    % main
    \new Voice \addAmbitusEngraver
    \relative c'{
      \adjustMiddleOfLineAmbitus #-4.2
      \clef "treble"
      c1 c'1

      % let finis bar go through all staves
      \override Staff.BarLine #'transparent = ##f

      % finis bar
      \bar "|."
    }
}


vagansNotes = {
    \set Staff.instrumentName = #"Vagans  "
    \set Staff.midiInstrument = #"recorder"

    % incipit
    \clef "petrucci-c1"
    e'\breve
    s1*3

    %main
    \new Voice \addAmbitusEngraver
    \relative c' {
      \adjustMiddleOfLineAmbitus #-4.2
      \clef "treble"

      e1 b1

      % let finis bar go through all staves
      \override Staff.BarLine #'transparent = ##f

      % finis bar
      \bar "|."
  }
}

altusNotes = {
    \set Staff.instrumentName = #"Altus  "
    \set Staff.midiInstrument = #"recorder"

    % incipit
    \clef "petrucci-c4"
    \[a1. c'1\] s1. s1

    %main
    \new Voice \addAmbitusEngraver
    \relative c' {
      \adjustMiddleOfLineAmbitus #-4.2
      \clef "treble_8"
      a2. c2 b8 a8 b2

      % let finis bar go through all staves
      \override Staff.BarLine #'transparent = ##f

      % finis bar
      \bar "|."
    }
}



tenorNotes = {
    \set Staff.instrumentName = #"Tenor  "
    \set Staff.midiInstrument = #"recorder"

    % incipit
    \clef "petrucci-c4"
    c\breve s1*3

    % main
    \new Voice \addAmbitusEngraver
    \relative c {
      \adjustMiddleOfLineAmbitus #-4.2
    \clef "treble_8"
      c1 c'1

      % let finis bar go through all staves
      \override Staff.BarLine #'transparent = ##f

      % finis bar
      \bar "|."
    }
}

bassusNotes = {
    \set Staff.instrumentName = #"Bassus  "
    \set Staff.midiInstrument = #"recorder"

    % incipit
    \clef "bass"
    f\breve s1*3

    % main
    \new Voice \addAmbitusEngraver
    \relative c {
      \adjustMiddleOfLineAmbitus #-4.2
      \clef "bass"
      f1 f'1

      % let finis bar go through all staves
      \override Staff.BarLine #'transparent = ##f

      % finis bar
      \bar "|."

    }
}

\score {
  \new StaffGroup = choirStaff <<
    \new Voice =
      "discantusNotes" << \global \discantusNotes >>
    \new Voice =
      "vagansNotes" << \global \vagansNotes >>
    \new Voice =
      "altusNotes" << \global \altusNotes >>
    \new Voice =
      "tenorNotes" << \global \tenorNotes >>
    \new Voice =
      "bassusNotes" << \global \bassusNotes >>
  >>
  \layout {

    #(layout-set-staff-size 18)

    \context {
      \Score
      \ambitusLayout

      % no bars in staves
      \override BarLine #'transparent = ##t

      % incipit should not start with a start delimiter
      \remove "System_start_delimiter_engraver"
    }
    \context {
      \Voice
      % no slurs
      \override Slur #'transparent = ##t

      % Comment in the below "\remove" command to allow line
      % breaking also at those barlines where a note overlaps
      % into the next bar.  The command is commented out in this
      % short example score, but especially for large scores, you
      % will typically yield better line breaking and thus improve
      % overall spacing if you comment in the following command.
      \remove "Forbid_line_break_engraver"
    }
  }
}

%% Another example

\score {
  \new Staff {
      \new Voice = "a" \addAmbitusEngraver
      \relative c' {
        \key f\major
        \clef treble
        f4 g a bes
      }
      \break
      \new Voice = "b" \addAmbitusEngraver
      \relative c' {
        \key cis\major
        \time 2/2
        \clef alto
        c d e g'
      }
      \new Voice = "c" \addAmbitusEngraver
      \relative c' {
        \adjustMiddleOfLineAmbitus #2.5
        \time 8/8
        \key c\major
        \clef treble
        fisis4 g a bis
      }
      %\break
      \new Voice = "d" \addAmbitusEngraver
      \relative c' {
        \adjustMiddleOfLineAmbitus #0
        \clef alto
        c d e g'
      }
  }
  \layout {
    \context {
      \Score
      \ambitusLayout
    }
  }
  \header { piece = \markup \fill-line { "Another Demo" } }
}

*********************************************************************


HTH,
  Harm

Attachment: ambitus-02.png
Description: PNG image

Attachment: ambitus-02.ly
Description: Binary data


reply via email to

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