lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Text listing output in .txt file


From: Thomas Morley
Subject: Re: Text listing output in .txt file
Date: Wed, 2 Aug 2017 19:11:29 +0200

2017-08-02 19:02 GMT+02:00 Kieren MacMillan <address@hidden>:
> Hi Daniel,
>
>> For example, if I change a g-sharp to a g-natural, I would
>> like to write on a line of code "g-sharp changed to g-natural" that then
>> would be listed on a text file that I can copy to my critical commentary.
>
> Have you looked at the edition engraver? That kind of edition control is 
> *precisely* its fundamental purpose — and I wouldn't think it would take much 
> to transform a list of editionMod-s (i.e., tweaks) into a text file in any 
> format you desired.
>
> (Note: I use the EE extensively, in every score I engrave, but only for 
> aesthetic/tweak purposes, not to track changes as you are suggesting.)
>
> Hope that helps,
> Kieren.



I thought of the edition-engraver as well. Has a plethora of features
and is used by people doing large real world type-setting.

Nevertheless here some coding, returning at least a little tracking info.
Though, it's a crude coding and expensive, use at own risk ;)

\version "2.19.64"

remark =
#(define-music-function (strg)(string?)
#{
  \withMusicProperty #'remark #strg <>
#})

%% writes remarks to <your-file-name>-remarks.txt
writeRemark =
#(define-void-function (mus)(ly:music?)
  (music-map
    (lambda (m)
      (if (and (music-is-of-type? m 'event-chord)
               (ly:music-property m 'remark #f))
          (let* ((log-file
                  (format #f "~a-remarks.txt" (ly:parser-output-name)))
                 (port (open-file  log-file "a"))
                 (origin (ly:music-property m 'origin)))
            (format #t "\nRemark from ~a written to: ~a" origin log-file)
            (format port "\n~a:\t~a" origin (ly:music-property m 'remark))
            (close port)
            m)
          m))
     mus)
  mus)

\writeRemark
  {
      \remark text
    c4 d e f
    \remark more-text
    g a b c
    \remark "further text: pitch is d, length 4"
    d e f g
  }


Cheers,
  Harm



reply via email to

[Prev in Thread] Current Thread [Next in Thread]