• 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ü

"echte" NoteEvents rausfischen

Begonnen von erich, Mittwoch, 6. April 2016, 11:02

Vorheriges Thema - Nächstes Thema

erich

Hallo allen

Das Script
\version "2.18.2"

note_chord =
#(define-music-function (parser location music)
   (ly:music?)
       
    (music-map
      (lambda (music)     
        (if (eq? (ly:music-property music 'name) 'NoteEvent)
            (begin (display-scheme-music music) music)
            music)
            )
            music
      ) )

\score {
  <<
    \new Voice \note_chord{ e <e>}
  >>
}


protokolliert mir

(make-music
  'NoteEvent
  'pitch
  (ly:make-pitch -1 2 0)
  'duration
  (ly:make-duration 2 0 1))

(make-music
  'NoteEvent
  'duration
  (ly:make-duration 2 0 1)
  'pitch
  (ly:make-pitch -1 2 0))


Die Darstellungen der NoteEvents unterscheiden sich also nur in der Reihenfolge von pitch und duration

Ich möchte gerne nur die echten NoteEvents weiterbehandeln können, also nicht diejenigen, die Teil eines EventChords sind; wie kann man diese rausfischen?

Gruß
Erich

harm6

\version "2.18.2"

note_chord =
#(define-music-function (parser location music)
  (ly:music?)
       
  (for-each
    (lambda (m)     
      (cond ((eq? (ly:music-property m 'name) 'EventChord)
             m)
            ((eq? (ly:music-property m 'name) 'NoteEvent)
             (begin (display-scheme-music m) m))
            (else m)))
          (ly:music-property music 'elements))
  music)

\score {
  <<
    \new Voice \note_chord { e <e> }
  >>
}


HTH,
  Harm

erich

Hallo Harm,

bei der Suche nach der Erklärung was for-each macht, fand ich map-in-order, die mir für mein Anliegen geeigneter schien, da for-each kein Ergebnis abliefert.

Ich bin dann zu folgendem Script gelangt:
\version "2.18.2"
note = {c''}
note_chord =
#(define-music-function (parser location music)
  (ly:music?)
       
  (set! (ly:music-property music 'elements)
      (map-in-order
         (lambda (m)     
            (cond ((eq? (ly:music-property m 'name) 'EventChord)
                      m)
                  ((eq? (ly:music-property m 'name) 'NoteEvent)
                     note)
                 (else m)))
         (ly:music-property music 'elements)
      )
  )
  music)

\score {
  <<
    \new Voice \note_chord{ e' <e'> }
  >>
}


Die Ausgabe der anderen Note c'' dient also nur dazu, die lokale Veränderung der eingegebenen Noten zu demonstrieren.

Danke für Deine Hilfe
Gruß
Erich