Höchste Note in einem Akkord herausfinden

Begonnen von Manuela, Samstag, 21. September 2019, 09:47

« vorheriges - nächstes »

Manuela

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,
Danke für eure Hilfe
viele Grüße
-- Manuela

harm6

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

Manuela

Danke Harm, zumindest kompiliert jetzt der Code.
Danke für eure Hilfe
viele Grüße
-- Manuela

Manuela

Danke für eure Hilfe
viele Grüße
-- Manuela