I'd like to engrave music with quarter-tones in Lilypond, and generate
MIDI that will sound correct when played.  Lilypond is supposed to support
that but I've run into some issues with actually doing it.

First:  quarter tones are implemented by emitting the nearest 12-ET note
and a quarter-tone pitch bend if applicable, so that for instance cih'
(quarter tone sharper than Middle C) is MIDI note 60 (c') with a +50 cent
pitch bend.  And MIDI pitch bends affect the entire channel; so if there
are two notes that require different bend amounts, then they have to be in
different MIDI channels.

I can basically resolve this issue using code posted to the list by Jean
Abou Samra, which uses a "performer" to allow querying out single lines
from simultaneous notes into separate channels:
   https://lists.gnu.org/archive/html/lilypond-user/2023-05/msg00324.html

A disadvantage of this approach is that it requires a separate channel for
each simultaneous note, when it would seem that two channels (one for no
bend, one for a quarter-tone bend) should be enough.

However, other issues remain.  The second one is that Lilypond sometimes
emits a message cancelling the pitch bend at the same moment as the Note
Off message - which is not actually the end of the note, only the start of
the "release" of the note.  So the MIDI renderer obeys the pitch bend
message at that moment, and the note ends up with its release bent to the
wrong pitch.

I've not been able to determine exactly when Lilypond does or doesn't do
this.  It happens on some notes and not others.  I also am not sure
whether the note-splitting code used for the first issue may be having
some effect on it.  And in the case of legato playing, even if Lilypond
never "cancelled" the pitch bend at the Note Off message, it might still
need to apply a different pitch bend for the next note before the release
of the previous note has completed, so just eliminating "cancel pitch
bend" at Note Off would not be enough to resolve it anyway.

Ideally, one would split notes not according to simultaneity but according
to amount of pitch bend.  There could be one channel permanently set with
no pitch bend, and a second channel (only two channels total) permanently
set to a quarter tone pitch bend, and notes somehow filtered or routed to
those channels according to their pitch.  This might not work for every
"microtonal" scale, because there could be many distinct pitch bend values
in play, but my particular case of 24-ET is easy because there are really
only two pitch bend values ever needed.

That raises the third issue:  Lilypond doesn't actually use just two pitch
bend values for quarter tones.  For a note that is not a straight 12-ET
MIDI note, Lilypond either uses the next lower 12-ET note, plus 50 cents;
or the next higher 12-ET note minus 50 cents.  I have not been able to
determine how it decides this.  At first I thought it was note spelling
(cih' becoming note 60 plus 50 cents, deseh' becoming note 61 minus 50
cents) but in further testing, that doesn't seem to be the case.  I
haven't been able to rule out that it may be some consistent function of
the pitch (that is, I haven't found examples of the same pitch resulting
in two different pitch bends, from two different starting note numbers)
but it's definitely the case that over the whole scale the set of pitch
bends used is not minimal.  It uses all three of 0, -50, and +50 even
though it would be possible to express all 24-ET pitches using only two of
those.

I'd like to be able to enter music in Lilypond so that it engraves right,
and then filter it (either in Lilypond or some postprocessing step) so
that notes end up in two MIDI channels, one of which has permanently no
pitch bend and the other of which has permanently +50 cent pitch bend.
There should be no change in a channel's pitch bend during the music
(thus, not during decay tails of notes), and every note should play at its
correct pitch without being bent to a different pitch during release.  It
would be preferable that this end up involving only two output channels:
not three, not one per simultaneous note, and not extra channels even
beyond that.

Any thoughts on how to achieve this?  It seems like I could get most of
the way by tagging and filtering on note names and quarter-tone
accidentals, to get all notes that are 12-ET notes into one channel for
"no bends" and all notes that aren't 12-ET notes into a another,
permanently-bent channel.  Then I can easily enough filter out any
spurious "cancel bend" messages because I know each channel will always
have a fixed bend amount.  But even if I'm willing to use three output
channels instead of two, I need to know what actually causes Lilypond to
choose +50 or -50 bends, to decide into which channel a given note should
go so that the bend amount for each channel will be the same for all
notes in that channel.

-- 
Matthew Skala
msk...@ansuz.sooke.bc.ca                 People before tribes.
https://ansuz.sooke.bc.ca/

Reply via email to