Inheritance of MIDI settings into embedded contexts?

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Inheritance of MIDI settings into embedded contexts?

Thomas Tensi
Dear all,


I am using lilypond as the frontend for audio production and now I have
a problem where I do not understand lilypond's internal logic for
transferring MIDI settings into embedded contexts.

The file
-----
\version "2.19.82"

\score {
     <<
        \new Staff = piano \with { midiInstrument = "acoustic grand" } {
            { \key c \major \time 4/4
              \relative c' { c4\ff << {e f} \\ {c d}>> g } }
        }
     >>
     \layout {}
     \midi {}
}
-----

produces a MIDI file with the following track data:

-----
MTrk
0 Meta TrkName "piano:"
0 PrCh ch=1 p=0
0 PrCh ch=1 p=0
0 Meta InstrName "acoustic grand"
0 KeySig 0 major
0 On ch=1 n=60 v=101
384 On ch=1 n=60 v=0
384 On ch=1 n=64 v=89
384 On ch=1 n=60 v=89
768 On ch=1 n=64 v=0
768 On ch=1 n=60 v=0
768 On ch=1 n=65 v=89
768 On ch=1 n=62 v=89
1152 On ch=1 n=65 v=0
1152 On ch=1 n=62 v=0
1152 On ch=1 n=67 v=101
1536 On ch=1 n=67 v=0
1536 Meta TrkEnd
TrkEnd
-----

This means that the embedded voices are in the MIDI default volume while
the surrounding notes are in fortissimo (as specified and expected).

My naive assumption is that any setting (also the dynamics for MIDI) is
inherited by embedded contexts. But this does not seem to be the case.

Personally I find this very impractical, because this leads to loudness
jumps in the MIDI output when I have some multiple-voice context
embedded in some macro with the dynamics specified on an outer section
level. It is simply not modular.

Any ideas on how to cope with that?


          Best regards,

                    Thomas





Reply | Threaded
Open this post in threaded view
|

Re: Inheritance of MIDI settings into embedded contexts?

Aaron Hill
On 2020-08-22 8:52 am, Dr. Thomas Tensi wrote:

> I am using lilypond as the frontend for audio production and now I have
> a problem where I do not understand lilypond's internal logic for
> transferring MIDI settings into embedded contexts.
>
> [ . . . ]
>
> This means that the embedded voices are in the MIDI default volume
> while
> the surrounding notes are in fortissimo (as specified and expected).
>
> My naive assumption is that any setting (also the dynamics for MIDI) is
> inherited by embedded contexts. But this does not seem to be the case.

The Dynamic_performer is part of the Voice context; and the construct <<
... \\ ... >> implicitly creates new Voice contexts.  As such, dynamics
of notes from different Voices would be expected to be distinct,
regardless of whether they might occupy the same Staff.


> Personally I find this very impractical, because this leads to loudness
> jumps in the MIDI output when I have some multiple-voice context
> embedded in some macro with the dynamics specified on an outer section
> level. It is simply not modular.
>
> Any ideas on how to cope with that?

\consisting the Dynamic_performer to the Staff (and \removing it from
the Voice) should apply the current logic to the wider scope:

%%%%
\version "2.19.82"

\score {
     <<
     \new Staff = piano \with { midiInstrument = "acoustic grand" } {
         { \key c \major \time 4/4
           \relative c' { c4\ff << {e f} \\ {c d}>> g } }
     }
     >>
     \layout {}
     \midi {
       \context {
         \Staff
         \consists "Dynamic_performer"
       }
       \context {
         \Voice
         \remove "Dynamic_performer"
       }
     }
}
%%%%

Whether there are any side effects, I do not know.


-- Aaron Hill