Deutschsprachiges LilyPond-Forum

LilyPond und andere Programme => MIDI => Thema gestartet von: Arnold am Dienstag, 15. Dezember 2020, 09:16

Titel: Lyrics in MIDI-Ausgabe: Bug mit articulate
Beitrag von: Arnold am Dienstag, 15. Dezember 2020, 09:16
Hallo zusammen,

bei der Wandlung vom MIDI in WAV hat mich mein Software-Synthesizer »erinnert«, daß sogar die Liedtexte in der MIDI-Datei enthalten sind.
Als ich dem mit einem Midi-Dump nachging, fehlte aber annähernd die Hälfte der Silben.
   Das erachte ich als Bug in Lilypond.
Eine weitergehende Recherche ergab, daß es mit \articulate zusammenhängt:
Am einfachsten war für mich, eine Kopie von event-chord-wrap! so abzuändern, daß Lyric-Events unangetastet bleiben, und somit von \articulate mangels Chord-Event auch nicht mehr verändert werden.
Allerdings bin ich mir nicht ganz sicher, ob das immer »die« Lösung wäre für alle Anwendungsfälle von event-chord-wrap!.

\version "2.20.0"
%auch 2.21.81

\paper {
  indent = 0 \mm
}

Music = <<
  \new Staff \new Voice = "S" {
    \repeat unfold 4 c''4
  }
  \new Lyrics \lyricsto "S" {
    one two three four
  }
  \new Lyrics \lyricsto "S" {
    se -- ven -- ty -- five
  }
>>

\score {
  \Music
  \header { piece = \markup \typewriter "{ \\Music }" }
}

\include "articulate.ly"

\score {
  \articulate \Music
  \layout {}
  \midi {}
  \header { piece = \markup \typewriter "{ \\articulate \\Music }" }
}


#(define (ac:event-chord-wrap! music)
  "From .../scm/music-functions.scm:
Wrap isolated rhythmic events and non-postevent events in
@var{music} inside of an @code{EventChord}.  Chord repeats @samp{q}
are expanded using the default settings of the parser.
BUT I needed a function which excludes lyrics from being wrapped
into a chord."
  (map-some-music
   (lambda (m)
     (cond ((music-is-of-type? m 'event-chord)
            (if (pair? (ly:music-property m 'articulations))
                (begin
                  (set! (ly:music-property m 'elements)
                        (append (ly:music-property m 'elements)
                                (ly:music-property m 'articulations)))
                  (set! (ly:music-property m 'articulations) '())))
            m)
           ;Next line added: Don't wrap lyrics syllables into a chord
           ((music-is-of-type? m 'lyric-event) m)
           ((music-is-of-type? m 'rhythmic-event)
            (let ((arts (ly:music-property m 'articulations)))
              (if (pair? arts)
                  (set! (ly:music-property m 'articulations) '()))
              (make-event-chord (cons m arts))))
           (else #f)))
   (expand-repeat-notes!
    (expand-repeat-chords!
     (cons 'rhythmic-event
           (ly:parser-lookup '$chord-repeat-events))
     music))))                 

% Use my new version of event-cord-wrap! in articulate:
#(define (ac:startup-replacements music)
   (fold (lambda (f m) (f m))
music
(list
  ac:event-chord-wrap!
  ac:replace-aftergrace
  ac:replace-appoggiatura
  ac:unfoldMusic)))

\score {
  \articulate \Music
  \layout {}
  \midi {}
  \header { piece = \markup { \typewriter "{ \\articulate \\Music }" \italic " but using a replacement of" \bold "»event-chord-wrap!«" } }
}


Da ich bisher keine Anwendung habe für den im MIDI enthaltenen Liedtext, hat dieser Bug für mich persönlich derzeit keine Priorität.
Außerdem zeige ich ja hier einen praktikablen Workaround auf: quasi die beiden SCHEME-Funktions-Definitionen in eine Datei (z. Bsp. »articulate-patch.ly«) kopieren, und dann nach »\include "articulate.ly"« ein »\include "articulate-patch.ly"« aufrufen

Arnold