Deutsches Lilypond Forum (Archiv)

Allgemein => Fragen zu Funktionen => Thema gestartet von: MUSI am Freitag, 17. Juni 2011, 08:15

Titel: Eine Linie hervorheben
Beitrag von: MUSI am Freitag, 17. Juni 2011, 08:15
Liebe Freunde,

ich möchte gerne eine Linie im Notensystem hervorheben. Es soll ein Arbeitsblatt zum Erlernen der Notenschlüssel sein. Also soll es im ersten Fall die zweite Linie und im zweiten Fall die vierte Linie dicker als Standard sein.

Danke für Eure Antworten.
Titel: Re: Eine Linie hervorheben
Beitrag von: harm6 am Freitag, 17. Juni 2011, 11:35
Hallo Musi,

nach NR 1.6.2 Modifying single staves :

\version "2.14.1"
\relative c' {
  \once\override Staff.StaffSymbol #'line-positions = #'(-4 -2.1 -2 -1.9 0  2 4)
  d'4 e f g
}

\relative c' {
   \override Staff.StaffSymbol #'line-positions = #'(-4 -2 0 1.9 2 2.1 4)
     \clef bass
      d,4 e f g
}

Gruß,
  Harm
Titel: Re: Eine Linie hervorheben
Beitrag von: harm6 am Samstag, 18. Juni 2011, 14:00
Hallo Musi,

da ich gestern kaum Zeit hatte hier noch eine ausgearbeitete Fassung:

\version "2.14.1"

\header {
        title = "Notenschlüsselübung 1"
}

\paper {
        markup-system-spacing =
#'((basic-distance . 12)
   (minimum-distance . 20)
   (padding . 1)
   (stretchability . 12))
        system-system-spacing =
#'((basic-distance . 12)
   (minimum-distance . 20)
   (padding . 1)
   (stretchability . 12))
}

linesOne =
\relative c' {
\mark\markup { "Violin-Schlüssel" }
   \override Staff.StaffSymbol #'line-positions = #'(-4 -2.1 -2 -1.9 0  2 4)
     \clef treble
  s1
  \stopStaff\break
  \startStaff
\mark\markup { "Bass-Schlüssel" }
   \override Staff.StaffSymbol #'line-positions = #'(-4 -2 0 1.9 2 2.1 4)
     \clef bass
      s1
  \stopStaff\break
  \startStaff
\mark\markup { "Alt-Schlüssel" }
   \override Staff.StaffSymbol #'line-positions = #'(-4 -2 -0.1 0 0.1 2 4)
     \clef alto
      s1
}

\score {
  \new Staff  \linesOne
    \layout {
          indent = 0
          \context {
            \Score
            \remove "Bar_number_engraver"
            \override RehearsalMark #'break-align-symbols = #'(time-signature key-signature)
            \override RehearsalMark #'self-alignment-X = #LEFT
            \override RehearsalMark #'Y-offset = #'6
          }
          \context {
             \Staff
             \remove "Clef_engraver"
             \remove "Time_signature_engraver"
             \remove "Bar_engraver"
             \override TimeSignature #'break-align-anchor-alignment = #LEFT
          }
    }
}

Anmerkung: Ich benutze mittlerweile 2.14.1. Falls Du noch auf 2.12.x bist, mußt Du den Paper-Block rausnehmen und einen eigenen entwerfen.

Darüber hinaus könntest Du ja auch überlegen die Linien nicht dicker sondern farbig zu gestalten.

Dazu habe ich LSR-snippet 700 (http://lsr.dsi.unimi.it/LSR/Item?id=700) benutzt und mit Anleitung eines Beitrags auf Old Nabble (http://old.nabble.com/LSR-item-id%3D700-td30602412.html#a30602412) für 2.14.1 nutzbar gemacht. (Es sollte so aber auch mit 2.12.x funktionieren, falls nicht so melde Dich). Für den Paper-Block gilt dasselbe wie oben:

\version "2.14.1"

%LSR This snippet was contributed by Neil Puttock
       
#(define-public ((color-staff-lines . rest) grob)

   (define (index-cell cell dir)
     (if (equal? dir RIGHT)
         (cdr cell)
         (car cell)))
         
   (define (interval-translate iv amount)
     (cons (+ amount (car iv))
           (+ amount (cdr iv))))

   (define (index-set-cell! x dir val)
     (case dir
       ((-1) (set-car! x val))
       ((1) (set-cdr! x val))))

   (let* ((common (ly:grob-system grob))
          (span-points '(0 . 0))
          (thickness (* (ly:grob-property grob 'thickness 1.0)
                        (ly:output-def-lookup (ly:grob-layout grob) 'line-thickness)))
          (width (ly:grob-property grob 'width))
          (line-positions (ly:grob-property grob 'line-positions))
          (staff-space (ly:grob-property grob 'staff-space 1))
          (line-stencil #f)
          (total-lines empty-stencil)
          ;; use a local copy of colors list, since
          ;; stencil creation mutates list
          (colors rest))

     (for-each
      (lambda (dir)
        (if (and (= dir RIGHT)
                 (number? width))
            (set-cdr! span-points width)
            (let* ((bound (ly:spanner-bound grob dir))
                   (bound-ext (ly:grob-extent bound bound X)))
             
              (index-set-cell! span-points dir
                               (ly:grob-relative-coordinate bound common X))
              (if (and (not (ly:item-break-dir bound))
                       (not (interval-empty? bound-ext)))
                  (index-set-cell! span-points dir
                                   (+ (index-cell span-points dir)
                                      (index-cell bound-ext dir))))))
        (index-set-cell! span-points dir (- (index-cell span-points dir)
                                            (* dir thickness 0.5))))
      (list LEFT RIGHT))

      (set! span-points
           (interval-translate span-points
                            (- (ly:grob-relative-coordinate grob common X))))
     (set! line-stencil
           (make-line-stencil thickness (car span-points) 0 (cdr span-points) 0))

     (if (pair? line-positions)
         (for-each (lambda (position)
                     (let ((color (if (pair? colors)
                                      (car colors)
                                      #f)))
                       (set! total-lines
                             (ly:stencil-add
                              total-lines
                              (ly:stencil-translate-axis
                               (if (color? color)
                                   (ly:stencil-in-color line-stencil
                                                        (first color)
                                                        (second color)
                                                        (third color))
                                   
                                   line-stencil)
                                   ;(ly:stencil-extent  line-stancil 2)
                               (* position staff-space 0.5) Y)))
                       (and (pair? colors)
                            (set! colors (cdr colors)))))
                   line-positions)       
         (let* ((line-count (ly:grob-property grob 'line-count 5))
                (height (* (1- line-count) (/ staff-space 2))))
           (do ((i 0 (1+ i)))                     
               ((= i line-count))
             (let ((color (if (and (pair? colors)
                                   (> (length colors) i))
                              (list-ref colors i)
                              #f)))
               (set! total-lines (ly:stencil-add
                                  total-lines
                                  (ly:stencil-translate-axis
                                   (if (color? color)
                                       (ly:stencil-in-color line-stencil
                                                            (first color)
                                                            (second color)
                                                            (third color))
                                       line-stencil)
                                   (- height (* i staff-space)) Y)))))))
     total-lines))

\header {
        title = "Notenschlüsselübung 2"
}

\paper {
        markup-system-spacing =
#'((basic-distance . 12)
   (minimum-distance . 20)
   (padding . 1)
   (stretchability . 12))
        system-system-spacing =
#'((basic-distance . 12)
   (minimum-distance . 20)
   (padding . 1)
   (stretchability . 12))
}

linesTwo =
\relative c' {
\mark\markup { "Violin-Schlüssel" }
          \clef treble
        \override Staff.StaffSymbol #'stencil = #(color-staff-lines #f #f #f red)
        s1
           \stopStaff
           \break
           \revert Staff.StaffSymbol #'stencil
           \startStaff
\mark\markup { "Bass-Schlüssel" }
          \clef bass
        \override Staff.StaffSymbol #'stencil = #(color-staff-lines #f red)
        s1
           \stopStaff
           \break
           \revert Staff.StaffSymbol #'stencil
           \startStaff
\mark\markup { "Alt-Schlüssel" }
          \clef alto
        \override Staff.StaffSymbol #'stencil = #(color-staff-lines #f #f red)
        s1
}

\score {
  \new Staff  \linesTwo
    \layout {
          indent = 0
          \context {
            \Score
            \remove "Bar_number_engraver"
            \override RehearsalMark #'break-align-symbols = #'(time-signature key-signature)
            \override RehearsalMark #'self-alignment-X = #LEFT
            \override RehearsalMark #'Y-offset = #'6
          }
          \context {
             \Staff
             \remove "Clef_engraver"
             \remove "Time_signature_engraver"
             \remove "Bar_engraver"
             \override TimeSignature #'break-align-anchor-alignment = #LEFT
          }
    }
}

Gruß,
  Harm



Nachtrag:

Die Änderungen der Linien sollten pro Zeile erfolgen, da sonst beim ändern des Schlüssels ein Bug sichtbar wird den ich nicht wegbekommen habe.

\relative c' {
   \override Staff.StaffSymbol #'line-positions = #'(-4 -2.1 -2 -1.9 0  2 4)
  c4 d e f
  \stopStaff
  \revert Staff.StaffSymbol #'line-positions
  \startStaff
   \override Staff.StaffSymbol #'line-positions = #'(-4 -2 0 1.9 2 2.1 4)
     \clef bass
      c d e f
}

Entsprechendes kann man auch im LSR-snippet provozieren.
Titel: Re: Eine Linie hervorheben
Beitrag von: MUSI am Sonntag, 31. Juli 2011, 09:38
Hallo Harm,

hatte ganz vergessen, dass ich eine Frage gestellt habe, da ich das Basteln von Übungsblatt für eine Weile auf die Seite gelegt habe. Heute wollte ich da weiter machen und habe so auch Deine Antwort entdeckt. Vielen herzlichen Dank. Unglaublich, es hat gleich funktioniert. Innerhalb von 2 Minuten. Ich bin begeistert.
  :)
Danke vielmals!!!