Die folgende Funktioon
firstNote =
#(define-music-function (music )
(ly:music?)
(event-chord-reduce music))
extrahiert aus jedem Akkord die erste Note. Ich bräuchte ein Funktion, die die höchste auftretende Note extrahiert.
Ich habe folgenden Code aus der music-functions.scm kopiert:
(define-public (event-chord-reduce music)
"Reduces event chords in @var{music} to their first note event,
retaining only the chord articulations. Returns the modified music."
(map-some-music
(lambda (m)
(and (music-is-of-type? m 'event-chord)
(let*-values (((notes arts) (partition
(lambda (mus)
(music-is-of-type? mus 'rhythmic-event))
(ly:music-property m 'elements)))
((dur) (ly:music-property m 'duration))
((full-arts) (append arts
(ly:music-property m 'articulations)))
((first-note) (and (pair? notes) (car notes))))
(cond (first-note
(set! (ly:music-property first-note 'articulations)
full-arts)
first-note)
((ly:duration? dur)
;; A repeat chord. Produce an unpitched note.
(make-music 'NoteEvent
'duration dur
'articulations full-arts))
(else
;; This is an empty chord. Ugh. We cannot really
;; reduce this in any manner, so we just keep it.
m)))))
music))
umbenannt
#(define (high-note-chord music)
"Reduces event chords in @var{music} to their first note event,
retaining only the chord articulations. Returns the modified music."
(map-some-music
(lambda (m)
(and (music-is-of-type? m 'event-chord)
(let*-values (((notes arts) (partition
(lambda (mus)
(music-is-of-type? mus 'rhythmic-event))
(ly:music-property m 'elements)))
((dur) (ly:music-property m 'duration))
((full-arts) (append arts
(ly:music-property m 'articulations)))
((first-note) (and (pair? notes) (car notes))))
(cond (first-note
(set! (ly:music-property first-note 'articulations)
full-arts)
first-note)
((ly:duration? dur)
;; A repeat chord. Produce an unpitched note.
(make-music 'NoteEvent
'duration dur
'articulations full-arts))
(else
;; This is an empty chord. Ugh. We cannot really
;; reduce this in any manner, so we just keep it.
m)))))
music))
und wollte herausfinden, an welcher Stelle des Codes ich nach der Tonhöhe sortieren kann.
Leider kompiliert der Code nicht, ich erhalte folgende Fehlermeldung:
In expression (let*-values (# # # ...) (cond # # ...)):
ly:74:12: Unbound variable: let*-value
Bitte um Hilfe,
Zitat
Leider kompiliert der Code nicht, ich erhalte folgende Fehlermeldung:
In expression (let*-values (# # # ...) (cond # # ...)):
ly:74:12: Unbound variable: let*-value
Wenn Du aus den scm-files was kopierst, so achte darauf welche guile-module benötigt werden
Sie sind in der Regel am Anfang des scm-files aufgeführt, allerdings stehen dort alle, die für irgendwas gebraucht werden.
Also hilft der Blick ins guile-manual:
let*-values stammt aus srfi-11
#(use-modules (srfi srfi-11)) ins ly-file zu setzen sollte genügen.
Gruß,
Harm
Danke Harm, zumindest kompiliert jetzt der Code.
Ich hab's geschafft, nochmals danke, Harm.