• Willkommen im Forum „Archiviertes Lilypond Forum (2017)“.
 

Dies ist das Archiv des alten Forums (bis März 2017). Das aktuelle Forum ist unter lilypondforum.de zu finden.
This is the archive of the old forum (until March 2017). You can find the current forum at lilypondforum.de.

Hauptmenü

parenthesize+tweak - geht das auch eleganter?

Begonnen von Manuela, Dienstag, 9. August 2016, 21:53

Vorheriges Thema - Nächstes Thema

Manuela

Hi,

ich will ziemlich viele Noten in Akkorden einklammern und ein wenig kleiner machen.
\parenthesize \tweak font-size #-2 bläht den Code ziemlich auf, daher habe ich nach eine Kombinationsmöglichkeit gesucht und bin auf folgendes gekommen:

twpa=
#(define-music-function (music)
   (ly:music?)
   (let* ((prop 'font-size)
          (value -2)
          (p (check-grob-path prop (*location*)
               #:start 1
               #:default #t
               #:min 2)))
     (cond ((not p))
       ;; p now contains at least two elements.  The first
       ;; element is #t when no grob has been explicitly
       ;; specified, otherwise it is a grob name.
       (else
        (set! (ly:music-property music 'tweaks)
              (acons (cond ((pair? (cddr p)) p)
                       ((symbol? (car p))
                        (cons (car p) (cadr p)))
                       (else (cadr p)))
                value
                (ly:music-property music 'tweaks)))))
     (if (memq 'event-chord (ly:music-property music 'types))
         ;; music is an EventChord -> set the parenthesize property
         ;; on all child notes and rests
         (for-each
          (lambda (ev)
            (if (or (memq 'note-event (ly:music-property ev 'types))
                    (memq 'rest-event (ly:music-property ev 'types)))
                (set! (ly:music-property ev 'parenthesize) #t)))
          (ly:music-property arg 'elements))
         ;; No chord, simply set property for this expression:
         (set! (ly:music-property music 'parenthesize) #t))
     music))


Einfach beide Funktionen aneinander gehängt und noch music angehängt. Außerdem habe ich die Fontsize fest eingestellt, da ich natürlich überall im Score die selbe Verkleinerung haben möchte. Das geht sicher eleganter und einfacher, aber wie?

harm6

Für neuere devel-versionen:


\version "2.19.45"

twpa = \tweak font-size -2 \parenthesize \etc

{
<
  c
  \twpa g
  c'
  e'
  g'
  \twpa c''
>
}


HTH,
  Harm

fugenkomponist

Kannst du bitte nächstes Mal ein kompilierbares Beispiel inklusive Anwendung posten? Ich hab erstmal nicht kapiert, wie die Funktion angewendet werden soll. Und nachdem ich beim Überfliegen was von EventChord gelesen hab, hab ich sie außerdem noch auf einen Akkord angewendet und festgestellt, dass sie nen Fehler wirft, weil arg nicht definiert ist ...

Manuela

#3
Danke für die Antworten.

Zitat von: harm6 am Dienstag,  9. August 2016, 23:25
Für neuere devel-versionen:


\version "2.19.45"

twpa = \tweak font-size -2 \parenthesize \etc



Das habe ich als erstes probiert, funktioniert mit 2.37 noch nicht

Zitat von: fugenkomponist am Dienstag,  9. August 2016, 23:46
hab ich sie außerdem noch auf einen Akkord angewendet und festgestellt, dass sie nen Fehler wirft, weil arg nicht definiert ist ...

Sry da muss ich beim Kopieren des Beispiels eine ältere Version erwischt haben. Die Nomenklatur in der Lilypond-Musikfunktionsdefinition ist nicht durchgängig, was in einer Funktion (parenthesize) music heißt, heißt in einer anderen (tweak) arg.

fugenkomponist

Zitat von: Manuela am Mittwoch, 10. August 2016, 06:49
Zitat von: harm6 am Dienstag,  9. August 2016, 23:25

\version "2.19.45"

twpa = \tweak font-size -2 \parenthesize \etc



Das habe ich als erstes probiert, funktioniert mit 2.37 noch nicht
Ich nehm an, du meinst 2.19.37 und muß dir widersprechen, das funktioniert wunderbar :)

Manuela

#5
Zitat von: fugenkomponist am Mittwoch, 10. August 2016, 11:10

Ich nehm an, du meinst 2.19.37 und muß dir widersprechen, das funktioniert wunderbar :)

Natürlich 2.19.37  :-[

Vielleicht habe ich mich vertippt, ich kann es erst in einigen Stunden nochmals ausprobieren.

Zumindest Lilybin  http://lilybin.com/ meldet einen Fehler

twpa=\tweak font-size -2 \parenthesize

\score{
{
c'' < d \twpa c' e >
}
\layout{}
}


Command failed: Processing `input.ly'
Parsing...
input.ly:6:17: error: unknown escaped string: `\twpa'
c'' < d
                \twpa c' e >
input.ly:6:17: error: syntax error, unexpected STRING
c'' < d
                \twpa c' e >
input.ly:6:17: error: unrecognized string, not in text script or \lyricmode
c'' < d
                \twpa c' e >
input.ly:6:28: error: syntax error, unexpected >
c'' < d \twpa c' e
                           >
input.ly:5:9: error: errors found, ignoring music expression


Update: man muss doch tatsächlich \etc dranhängen
ich dachte, dass bedeutet bloß, dass man noch mehr gleichartige Ausdrücke dranhängen kann


fugenkomponist

Zitat von: Manuela am Mittwoch, 10. August 2016, 11:54
Update: man muss doch tatsächlich \etc dranhängen
ich dachte, dass bedeutet bloß, dass man noch mehr gleichartige Ausdrücke dranhängen kann
Ja, \etc erlaubt es, einfache Musik- und Markupfunktionen ohne Verwendung von #(define-music-function ...) und #(define-markup-command ...) zu definieren, bisher leider nur in den Changes und in manchen Sprachen in Abschnitt 5.6.2 der Notationsreferenz (aber nicht auf deutsch) dokumentiert.