Le 23/01/2022 à 00:14, Jean Abou Samra a écrit :
Le 22/01/2022 à 22:51, Kieren MacMillan a écrit :
Hi all!

Given multiple Lilypond sources, I'm hoping to find a way to output a "diff file" describing the musical differences *as would be perceived by a human reading the score*. For example, given

     Score #1 = \score { \new Staff << { c'1 c' } >> }

     Score # 2 = \score { \new Staff \new Voice << { c'1*1/2 s2 c''1 } >> }

diff ( Score1 , Score2 ) would say [in effect] "m2: Score #1 has c'1 while Score #2 has c''1."

Because coding style, "hacks" (like c'1*1/2 s2), variable/context separation, and other code-based differences aren't [directly] relevant, I can't just use standard text/diff tools. Is there a way two "music streams" (oof, I'm definitely talking out my butt right now!) can be compared in Lilypond and some/most/all of the human-perceivable musical differences be automatically detected?

Thanks for any brainstorms, ideas, or (dare I dream!?) snippets!
Kieren.


You could actually output the music stream using
\include "event-listener.ly", and do a textual diff.
I guess that provides a start?


I remember now that the \displayLilyMusic machinery can output a
much more readable representation. You could try

\version "2.22.1"

\layout {
  \context {
    \Voice
    \consists
      #(lambda (context)
         (let ((id (ly:context-id context))
               (timing (ly:context-find context 'Score)))
           (make-engraver
            (listeners
             ((music-event engraver ev)
                (ly:message "~a\tmes ~a\tmom ~a\t~a"
                            id
                            (ly:context-property timing 'internalBarNumber)
                            (ly:moment-main
                             (ly:context-property timing 'measurePosition))
                            ((@@ (lily) music->lily-string)
                              (ly:event-property ev 'music-cause))))))))
  }
}

<<
  \new Voice = "voice1" \relative {
    c'8 d e f g16 f e d c8 f16 d
    R1
    \breathe
  }
  \new Voice = "voice2" \relative {
    <fis' g>4. r8 <f g>4 <ees g>
  }
>>


Minimal, but perhaps already usable?

That being said, if you use version control in all
its capability, you just have to commit frequently
(Git terminology, but it would work with any system)
and particularly before and after doing any change
that you want to remember. That might turn out to
be the easiest option in the end.

Best,
Jean


Reply via email to