Re: Output to single PDF and multiple MIDI files
2017-07-20 23:40 GMT+02:00 Jérôme Plût: > I am typesetting a multi-movement work. I want the paper output to be > in a single file (say work.pdf) and the MIDI output to be in separate > files (work-1.pdf, work-2.pdf). Is there a simple and local way to do > this? Hi Jérôme, you've got some nice code already. Here my own approach, trying to automate it even more: \version "2.19.64" #(define (string-list? x) (and (list? x) (every string? x))) putOut = #(define-void-function (restrict-ls suffixes scores) ((number-list? '()) (string-list? '()) list?) "Puts out a book with all scores from @var{scores} and seperate midis for each score of @var{scores}. @var{restrict-ls} and @var{suffixes} are optional arguments. If @var{restrict-ls} is set, a subset of @var{scores} is processed, the naming of the midis will be consistent, i.e. if first and third score are processed, midis are named filename-1.midi and filename-3.midi If @var{suffixes} is set, use it for midi-naming, otherwise midis are named: filename-1.midi, filename-2.midi, etc. Note, if @var{suffixes} is set, @var{restrict-ls} needs to be set as well. " (let* ((file-name (ly:parser-output-name)) ;; Provides defaults if 'suffixes'-variable is not set. (suffixes (if (null? suffixes) (map number->string (iota (length scores) -1 -1)) suffixes)) ;; cherry-pick the desired scores or choose all if ;; 'restrict-ls'-variable is not set. (restrist-list-proc (lambda (lst) (if (null? restrict-ls) lst (map (lambda (arg) (if (> (1+ arg) (length lst)) (ly:error "You tried to get a not existing score or suffix.") (list-ref lst arg))) restrict-ls) ;; put out a book (usually a pdf) with all scores returned by ;; 'restrist-list-proc' (ly:book-process (apply ly:make-book $defaultpaper $defaultheader (restrist-list-proc (reverse scores))) $defaultpaper $defaultlayout file-name) ;; put out midis in separate files. (for-each (lambda (bk bookSuffix) (ly:book-process bk $defaultpaper $defaultmidi (format #f "~a~a" (ly:parser-output-name) bookSuffix))) (map (lambda (score) (ly:make-book $defaultpaper $defaultheader score)) (restrist-list-proc scores)) (restrist-list-proc suffixes %% %% EXAMPLES %% %% Define variables one = \relative { c'4 c c c } two = \relative { c'4 d e f } three = \relative { d'4 d' d' d' } %% Define of scores scoreI = \score { \one \header { opus = "opus 1" } } scoreII = \score { \two \header { piece = "2. piece" } } scoreIII = \score { \three \header { piece = "3. piece" } } %% Put them in a list scoreList = #(list scoreI scoreII scoreIII ) %% Create the output %% Examples %% book-header, example \header { title = "TITLE" } %% book-layout, example \layout { \context { \Voice \override NoteHead.color = #grey } } %% book-paper, example \paper { indent = 0 } %% book-midi, example \midi { \tempo 4=200 } %% Ofcourse different settings for layout/midi could be done while defining %% scores above %% 1 %{ %% Put out all, midis are named starting with filename-1.midi \putOut \scoreList %} %% 2 %%{ %% Put out first and third score and the relevant midis %% NB list-ref needs number 0 to catch the first argument of a list, etc %% midis are named: filename-1.midi, filename-3.midi \putOut #'(0 2) \scoreList %} %% 3 %{ %% Put out second and third score and the relevant midis %% midis are named: filename-bar.midi, filename-buzz.midi \putOut #'(1 2) #'("-foo" "-bar" "-buzz") \scoreList %} Cheers, Harm ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Re: Output to single PDF and multiple MIDI files
I did just that a while ago. Here's the script I used (I had a few additional parameters, though): ``` #(define (movement title suffix music) (list #{\bookpart { \header { title = #title } \score { \removeWithTag midi $music \layout {} } }#} #{\book { \header { title = #title } \bookOutputSuffix #suffix \score { \removeWithTag midi $music \layout {} } \score { \unfoldRepeats \removeWithTag nomidi $music \midi {} } }#} )) $@(movement "Part 1" "part_1" partOne) $@(movement "Part 2" "part_2" partTwo) $@(movement "Part 3" "part_3" partThree) ``` This places each part on a new page, though, due to using \bookparts. If you don't want that, you could add each \score to a list and then insert each of them into a \book at the end. On 07/20/2017 11:40 PM, Jérôme Plût wrote: I am typesetting a multi-movement work. I want the paper output to be in a single file (say work.pdf) and the MIDI output to be in separate files (work-1.pdf, work-2.pdf). Is there a simple and local way to do this? I can do it in a not-simple-enough way: first = \relative { c'4 c c c } second = \relative { c'4 d e f } \book { \score { \new Staff << \first >> } \score { \new Staff << \second >> } % here } \book { \bookOutputSuffix "1" \score { \new Staff << \first >> \midi { } } } \book { \bookOutputSuffix "2" \score { \new Staff << \second >> \midi { } } } % and here However, this is not *local*. What I mean is that if I want to comment out, say, the second movement (for a test run), I need to comment two places at once (marked “here” “and here” in the source above). For consistency and efficiency, I want all lines relating to a single movement to be grouped together. Besides, I also have some reasons to want to group the source of the music with the \score commands; my preferred file structure would be: % first movement music = \relative { ... } \score { ... } % paper output to work.pdf \score { ... } % MIDI output to work-1.midi % second movement music = \relative { ... } \score { ... } % paper output appended to work.pdf \score { ... } % MIDI output to work-2.midi I also tried a variant, resetting the name of the book: \book { \bookOutputName "work" \score { \new Staff << \first >> } } \book { \bookOutputName "work" \score { \new Staff << \second >> } } There would be two consistent ways to act here: the second score could either overwrite the first one or add some extra pages. (Concatenation would be more useful, obviously). However lilypond chooses a bizarre third option: the code above produces two files named work.pdf and work-1.pdf . Does this problem have any solution? Thanks, -- Jérôme Plût ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user
Output to single PDF and multiple MIDI files
I am typesetting a multi-movement work. I want the paper output to be in a single file (say work.pdf) and the MIDI output to be in separate files (work-1.pdf, work-2.pdf). Is there a simple and local way to do this? I can do it in a not-simple-enough way: first = \relative { c'4 c c c } second = \relative { c'4 d e f } \book { \score { \new Staff << \first >> } \score { \new Staff << \second >> } % here } \book { \bookOutputSuffix "1" \score { \new Staff << \first >> \midi { } } } \book { \bookOutputSuffix "2" \score { \new Staff << \second >> \midi { } } } % and here However, this is not *local*. What I mean is that if I want to comment out, say, the second movement (for a test run), I need to comment two places at once (marked “here” “and here” in the source above). For consistency and efficiency, I want all lines relating to a single movement to be grouped together. Besides, I also have some reasons to want to group the source of the music with the \score commands; my preferred file structure would be: % first movement music = \relative { ... } \score { ... } % paper output to work.pdf \score { ... } % MIDI output to work-1.midi % second movement music = \relative { ... } \score { ... } % paper output appended to work.pdf \score { ... } % MIDI output to work-2.midi I also tried a variant, resetting the name of the book: \book { \bookOutputName "work" \score { \new Staff << \first >> } } \book { \bookOutputName "work" \score { \new Staff << \second >> } } There would be two consistent ways to act here: the second score could either overwrite the first one or add some extra pages. (Concatenation would be more useful, obviously). However lilypond chooses a bizarre third option: the code above produces two files named work.pdf and work-1.pdf . Does this problem have any solution? Thanks, -- Jérôme Plût ___ lilypond-user mailing list lilypond-user@gnu.org https://lists.gnu.org/mailman/listinfo/lilypond-user