2016-10-01 2:22 GMT+02:00 Thomas Morley <thomasmorle...@gmail.com>: > 2016-09-29 20:19 GMT+02:00 bart deruyter <bart.deruy...@gmail.com>: >> Hi all, >> >> I've got a collection of etudes for my students here, included in one file, >> to create one pdf. >> I've enabled midi, but now I've got a bunch of midi files which all have the >> name of the lilypond document, like this: >> >> The .ly file with the collection is called "Study collection.ly" >> The midi files then are named: >> Study collection.midi >> Study collection-1.midi >> Study collection-2.midi, >> etc.. (up to 30 for now). >> >> When I render one etude separately, the midi file gets the name of that >> separate file (e.g. andante.ly gives andante.midi), but when rendered in the >> collection file it would be named "Study collection-25.midi" because it is >> the 25th included file. >> >> All etudes are in separate lilypond files with a "\score", so I was >> wondering if there is a way to define a custom filename for the midi-file, >> for each score, which gets passed through to the collection file. >> >> Is this possible? >> >> thx, >> >> Bart > > > > You could try the below. > > Please note: > - it heavily messes with well hidden internals > - it's not tested apart from the included example > - there may be bleed over, while compiling multiple files (not tested) > - the default behaviour is not longer available as long as these > definitions are applied > > > \version "2.19.48" > > %% c/p from midi.scm > #(define (performance-name-from-header header) > (define (metadata-lookup-output overridevar fallbackvar) > (let* ((overrideval (ly:modules-lookup (list header) overridevar)) > (fallbackval (ly:modules-lookup (list header) fallbackvar)) > (val (if overrideval overrideval fallbackval))) > (if val (ly:encode-string-for-pdf (markup->string val)) ""))) > (if (null? header) > "" > (metadata-lookup-output 'midititle 'title))) > %% safer to use: %% taken from midi.scm and changed #(define-public (write-performances-midis-alt performances basename . rest) (let ((midi-ext (ly:get-option 'midi-extension))) (let loop ((perfs performances) (count (if (null? rest) 0 (car rest)))) (if (pair? perfs) (let ((perf (car perfs))) (ly:performance-write perf (if (string-null? (performance-name-from-header (ly:performance-header perf))) (if (> count 0) (format #f "~a-~a.~a" basename count midi-ext) (format #f "~a.~a" basename midi-ext)) (format #f "~a.~a" (performance-name-from-header (ly:performance-header perf)) midi-ext)) (performance-name-from-header (ly:performance-header perf))) (loop (cdr perfs) (1+ count)))))))
> %% tell lily to use the changed definition > #(module-set! > (resolve-module '(lily)) > 'write-performances-midis > write-performances-midis-alt) > > > \book { > \score { > { \repeat unfold 10 c'4 } > \header { midititle = "my-c-midi-name" } > \layout {} > \midi {} > } > > \score { > { \repeat unfold 10 d'4 } > \header { midititle = "my-d-midi-name" } > \layout {} > \midi {} > } > > \score { > { \repeat unfold 10 e'4 } > \header { midititle = "my-e-midi-name" } > \layout {} > \midi {} > } > } > Cheers, Harm _______________________________________________ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user