Hallo Leute
Gibt es irgendeine Method, Kommando, mit dem man Karakter- Zeichenzahl der Note (Note-,Pause- Dynamikzeichen etc.) zählen kann?
Besten Dank im Voraus. :)
Hier ist die Lösung:
\version "2.22.2"
printStats =
#(define-music-function (music) (ly:music?)
(let ((notes 0)
(rests 0)
(dynamics 0))
(for-some-music
(lambda (m)
(cond
((music-is-of-type? m 'note-event)
(set! notes (1+ notes)))
((or (music-is-of-type? m 'rest-event )
(music-is-of-type? m 'multi-measure-rest-event))
(set! rests (1+ rests)))
((music-is-of-type? m 'dynamic-event)
(set! dynamics (1+ dynamics))))
#f)
music)
(ly:message "Found ~a notes, ~a rests and ~a absolute dynamics" notes rests dynamics)
music))
\printStats \relative c' { c'4\mf\< e r8 g4 b c1\ff }
Mein scheme ist wieder einmal eingerostet.
Ich habe versucht, die Werte in Form eines Markups auszugeben, ich kriege kein Ergebnis, aber auch keine Fehlermeldung
mus=\relative c' { c'4\mf\< e r8 g4 b c1\ff }
#(define-markup-command (notenzahl layout props music)
(ly:music?)
(interpret-markup
layout
(let ((notes 0)
(rests 0)
(dynamics 0))
(for-some-music
(lambda (m)
(cond
((music-is-of-type? m 'note-event)
(set! notes (1+ notes)))
((or (music-is-of-type? m 'rest-event )
(music-is-of-type? m 'multi-measure-rest-event))
(set! rests (1+ rests)))
((music-is-of-type? m 'dynamic-event)
(set! dynamics (1+ dynamics))))
#f)
music)
(number->string notes)
music)
props))
\markup \notenzahl \mus
Hallo Manuela,
also ich bekomme einen Fehler:
Zitatprogramming error: Object is not a markup.
continuing, cross fingers
This object should be a markup: (((line-width . 108.120472440945) (font-encoding . latin1) (baseline-skip . 3) (replacement-alist) (word-space . 0.6)))
Ursache ist das `props' an der falschen Stelle steht.
`layout' und `props' sind obligatorische Argumente in:
(interpret-markup layout props ...)
Ansonsten willst Du ja nicht die `music' ausgeben, sondern den konstruierten string. Der muß dann natürlich an letzter Stelle stehen. Also:
mus=\relative c' { c'4\mf\< e r8 g4 b c1\ff }
#(define-markup-command (notenzahl layout props music)
(ly:music?)
(interpret-markup
layout
props
(let ((notes 0)
(rests 0)
(dynamics 0))
(for-some-music
(lambda (m)
(cond
((music-is-of-type? m 'note-event)
(set! notes (1+ notes)))
((or (music-is-of-type? m 'rest-event )
(music-is-of-type? m 'multi-measure-rest-event))
(set! rests (1+ rests)))
((music-is-of-type? m 'dynamic-event)
(set! dynamics (1+ dynamics))))
#f)
music)
(number->string notes))))
\markup \notenzahl \mus
HTH,
Harm
Hallo Leute
Ich habe ein neuen Schnipsel bekommen. Diese kann alle Zeichen-Art (Noten, Artikulation, breathe etc.) zählen. :)
\version "2.22.2"
#(use-modules (ice-9 match))
statDefinitions =
#'(
;; notes
("notes" note-event)
;; rests (including multi-measure rests)
("rests" rest-event multi-measure-rest-event)
;; dynamics: absolute dynamics (like \p), dynamic spans (like \cresc)
("dynamics" dynamic-event span-dynamic-event)
;; articulations: \staccato, \prall, \fermata, ...
("articulations" articulation-event)
;; \breathe
("breath marks" breathing-event)
;; basically count everything
("events" event)
)
printStats =
#(define-music-function (music) (ly:music?)
(for-each
(match-lambda
((desc . classes)
(let ((count 0))
(for-some-music
(lambda (m)
(if (any (lambda (c)
(music-is-of-type? m c))
classes)
(set! count (1+ count)))
#f)
music)
(ly:message "| Found ~a ~a" count desc))))
statDefinitions)
music)
\printStats \relative c' { c'4-.\mf\< e-. r8 \breathe g4-. b-. c1\ff\fermata }