Re: midifile output name

2016-09-30 Thread Thomas Morley
2016-10-01 2:22 GMT+02:00 Thomas Morley :
> 2016-09-29 20:19 GMT+02:00 bart deruyter :
>> 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


Re: midifile output name

2016-09-30 Thread Thomas Morley
2016-09-29 20:19 GMT+02:00 bart deruyter :
> 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)))

%% 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
 ;; original:
 ;(if (> count 0)
 ;(format #f "~a-~a.~a" basename count midi-ext)
 ;(format #f "~a.~a" basename midi-ext))
 ;; changed to:
 (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


Re: midifile output name

2016-09-30 Thread David Wright
On Fri 30 Sep 2016 at 10:26:28 (+0200), bart deruyter wrote:
> 2016-09-29 20:28 GMT+02:00 Simon Albrecht :
> > you can try something like
> > \book {
> >   \score {
> > …
> > \midi { … }
> >   }
> >   \bookOutputName "andante"
> > }
> > for each of the etudes, and one \book{} for all the pdf output.
> thanks for the tip, but that won't work I'm afraid :-) . It are short
> etudes, so i can have several scores, two, three or even four on one page.
> If I'd use the  \book - technique, each etude would be separated by a page
> break, which I do  not want. It would be a waste of paper :-).

I post-process the midi files from LP because the default names don't
sort correctly. Simply put, I insert "-00" into the first, then "0"
into the next nine single-digit files. After that, the default filenames
will now sort into the correct position. This process is done on each
bookpart independently, if they exist, by spotting the first file in
each sequence:

MIDI output to `adeste-choir.midi'...
MIDI output to `adeste-organ.midi'...
MIDI output to `adeste-organ-1.midi'...
MIDI output to `adeste-organ-2.midi'...
MIDI output to `adeste.midi'...
MIDI output to `adeste-1.midi'...
MIDI output to `adeste-2.midi'...
MIDI output to `adeste-3.midi'...
MIDI output to `adeste-4.midi'...

gets turned into:

adeste-choir-00.midi
adeste-organ-00.midi
adeste-organ-01.midi
adeste-organ-02.midi
adeste-00.midi
adeste-01.midi
adeste-02.midi
adeste-03.midi
adeste-04.midi

However, if you print a distinguishable string whenever you create
a midi file, it would be a relatively simple matter to rename each
midi filename to each respective string:

New name for MIDI file:Adeste fideles congo.mid
New name for MIDI file:Adeste fideles organ.mid
New name for MIDI file:Adeste fideles right.mid
New name for MIDI file:Adeste fideles left+pedal.mid
New name for MIDI file:Adeste fideles descant.mid
New name for MIDI file:Adeste fideles soprano.mid
New name for MIDI file:Adeste fideles alto.mid
New name for MIDI file:Adeste fideles tenor.mid
New name for MIDI file:Adeste fideles bass.mid

The challenge for my doing this without using bash arrays¹ would be
getting each line in the output: MIDI output to `adeste-choir.midi'...
to be immediately preceded or followed by: New name for MIDI file:Adeste 
fideles congo.mid
because the only methods I know for printing an arbitrary line will
print them all in a heap at the very end, after the last PostScript
file has been converted and deleted.

#(format (current-error-port) "New name for MIDI file:Adeste fideles 
congo.mid\n")
\midi % MIDI-generating command placed before or after as convenient.

is the method I currently use for writing strings. "write-me" is
allegedly another method. "ly:message" might be another, but any
documentation on these things is either opaque or absent. Perhaps
someone else will chip in...

¹or you could pack the filenames in one bash string, delimited with
a forbidden character like / or : between each one.

Cheers,
David.

___
lilypond-user mailing list
lilypond-user@gnu.org
https://lists.gnu.org/mailman/listinfo/lilypond-user


Re: midifile output name

2016-09-30 Thread bart deruyter
Hey,

thanks for the tip, but that won't work I'm afraid :-) . It are short
etudes, so i can have several scores, two, three or even four on one page.
If I'd use the  \book - technique, each etude would be separated by a page
break, which I do  not want. It would be a waste of paper :-).

grtz,
Bart

http://www.bartart3d.be/
On Twitter 
On Identi.ca 
On Google+ 

2016-09-29 20:28 GMT+02:00 Simon Albrecht :

> Hi Bart,
>
> you can try something like
>
> \book {
>   \score {
> …
> \midi { … }
>   }
>   \bookOutputName "andante"
> }
>
> for each of the etudes, and one \book{} for all the pdf output.
>
> HTH, Simon
>
>
> On 29.09.2016 20:19, bart deruyter wrote:
>
>> 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 <
>> http://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
>>
>> http://www.bartart3d.be/
>> On Twitter 
>> On Identi.ca 
>> On Google+ 
>>
>>
>> ___
>> 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


Re: midifile output name

2016-09-29 Thread Simon Albrecht

Hi Bart,

you can try something like

\book {
  \score {
…
\midi { … }
  }
  \bookOutputName "andante"
}

for each of the etudes, and one \book{} for all the pdf output.

HTH, Simon


On 29.09.2016 20:19, bart deruyter wrote:

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

http://www.bartart3d.be/
On Twitter 
On Identi.ca 
On Google+ 


___
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