On Thu 17 Feb 2022 at 21:43:09 (+1100), Mark Probert wrote:
> [ ] wrote:
> >> It’s not that simple, since in the example all the scores are in the 
> >> same book.
> > 
> > It is that simple.
> > Put the score in one book and the midis separate books and done.
> > 
> My understanding is a \midi{} block is contained within a \score{} 
> block.
> 
> The structure I have is
> 
> \book foo
>  \bookpart bar
>   \score
>    \midi => foo.mid
>  \bookpart baz
>   \score
>    \midi => foo-1.mid
> 
> How do I separate the \midi from the \score putting the score into a 
> \book and the \midi into separate books?

To some extent, it depends what you're using the midis for.
My two uses are proof-reading by ear, and teach-tapes.

I always set the score and midis separately, placing all the
notes into variables. Thus:

\header { …
miditempo = { …
\paper { …
global = { …
soprano = \relative { …
alto = \relative { …
tenor = \relative { …
bass = \relative { …
\include "Midi-satb.ily" % midis made here
sopranotext = \lyricmode { …
altotext = \lyricmode { …
tenortext = \lyricmode { …
basstext = \lyricmode { …
\score { % typesettng here
  \new ChoirStaff <<
    \new Staff <<
      \clef treble \global
      \new Voice { \soprano }
      \addlyrics { \sopranotext }
    >>
 …
  >>
  \layout { }
}

I've attached Midi-sab.ily (as it's smaller), and I have versions
for any arrangement I've set, from "cs" (click and single voice)
to "satbsatbp" (skeleton piano accompaniment). They call in turn
trivial files like:

Midi-hi-soprano.ily:
\new Staff { \midihighlight { \soprano } }

Midi-back-alto.ily:
\new Staff { \midibacking { \alto } }

and the definitions are in Midi-bits.ily (attached).

In a multi-section work, the midi filenames don't collate well,
so my lilypond shell script calls _Midirename_ to read through
the run's log file and renumber all the midi files for each
section with a 2-digit sequence number (bash function).

Typical teach-tape for one voice of an opening section attached.

Cheers,
David.
\version "2.19.49" % 2017-12-21

\book {
  \bookOutputSuffix "tutti__"
  \score {
    \unfoldRepeats
    <<
      \global
      \include "Midi-hi-soprano.ily"
      \include "Midi-hi-alto.ily"
      \include "Midi-hi-bass.ily"
    >>
    \midi {
      \miditempo
    }
  }
}

\book {
  \bookOutputSuffix "soprano_"
  \score {
    \unfoldRepeats
    <<
      \global
      \include "Midi-hi-soprano.ily"
      \include "Midi-back-alto.ily"
      \include "Midi-back-bass.ily"
    >>
    \midi {
      \midinodyn
      \miditempo
    }
  }
}

\book {
  \bookOutputSuffix "alto_"
  \score {
    \unfoldRepeats
    <<
      \global
      \include "Midi-back-soprano.ily"
      \include "Midi-hi-alto.ily"
      \include "Midi-back-bass.ily"
    >>
    \midi {
      \midinodyn
      \miditempo
    }
  }
}

\book {
  \bookOutputSuffix "bass_"
  \score {
    \unfoldRepeats
    <<
      \global
      \include "Midi-back-soprano.ily"
      \include "Midi-back-alto.ily"
      \include "Midi-hi-bass.ily"
    >>
    \midi {
      \midinodyn
      \miditempo
    }
  }
}
\version "2.19.49" % 2018-12-23

miditempo = "" % default in case it's missing

miditutti = {
  \set Staff.midiInstrument = #"oboe"
  \set Staff.midiMinimumVolume = #0.0
  \set Staff.midiMaximumVolume = #1.0
} % with dynamics

midihighlight = {
  \set Staff.midiInstrument = #"clarinet"
  \set Staff.midiInstrument = #"oboe"
  \set Staff.midiMinimumVolume = #0.9
  \set Staff.midiMaximumVolume = #1.0
  \set Staff.midiPanPosition = #LEFT
}

midibacking = {
  \set Staff.midiInstrument = #"bassoon"
  \set Staff.midiMinimumVolume = #0.2
  \set Staff.midiMaximumVolume = #0.4
  \set Staff.midiPanPosition = #RIGHT
}

midiclick = {
  \set Staff.midiInstrument = #"woodblock"
  \set Staff.midiMinimumVolume = #1.0
  \set Staff.midiMaximumVolume = #1.0
  \set Staff.midiPanPosition = #RIGHT
}

midiaccomp = {
  \set Staff.midiInstrument = #"acoustic grand"
  \set Staff.midiMinimumVolume = #1.0
  \set Staff.midiMaximumVolume = #1.0
  \set Staff.midiPanPosition = #RIGHT
}

midinodyn = \midi {
  \context {
    \Staff
    \remove Dynamic_performer
  }
}
function _Midirename_ {
    [ -z "$1" ] && printf '%s\n' "Usage:        ${FUNCNAME[0]} 
file-of-midi-filenames
        for internal use only, it renames the midi files generated by lilypond
        whose names are in the file, making them all sort in the correct order.
        The first midi generated in each score should contain __, which 
increments
        the sequence number, starting at 00. The score's other midis get that 
number.
        Note that the Perl rename command (file-rename) must be available." >&2 
&& return 1
    [ ! -r "$1" ] && printf '%s\n' "$1 not found!" >&2 && return 1
    [ ! -r /usr/bin/file-rename ] && printf '%s\n' "Perl's rename command 
(file-rename) not found!" >&2 && return 1
    local Unique="$(mktemp "${Uniquetrash:-/tmp}"/"${FUNCNAME[0]}"-"$(date 
+%s)"-XXXX)"
    grep -e '^MIDI output to `' "$1" | sed -e 's/^[^`]*.//;s/.\.\.\.$//' >> 
"$Unique"
    if ! grep -q -e '_.midi$' "$Unique"; then
        return 0
    fi
    if ! grep -q -e '__-1.midi$' "$Unique"; then
        file-rename -f 's/[_]+\.midi$/.midi/' < "$Unique"
        return 0
    fi
    local Thecount=-1
    exec 3<"$Unique"
    while :; do
        read -u 3 Nextitem
        [ -z "$Nextitem" ] && return 0
        grep -q -e '__' <<<"$Nextitem" && Thecount=$((Thecount+1))
        file-rename -f s/[_]+.*\.midi$/-"$(printf '%02d' $Thecount)".midi/ 
"$Nextitem"
    done
}

Attachment: requiem6-alto-00.midi
Description: MIDI audio

Reply via email to