lilypond-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Key signatures in MIDI output


From: Hans Åberg
Subject: Re: Key signatures in MIDI output
Date: Fri, 10 May 2024 22:15:55 +0200

> On 10 May 2024, at 21:50, mskala@ansuz.sooke.bc.ca wrote:
> 
> On Fri, 10 May 2024, Hans Åberg wrote:
> 
>> Programs like ABC work so that one writes the music without accidentals,
>> and then apply a key signature to get them. It was my reading that the
>> OP asked for that.
> 
> Okay.  I didn't read it that way because the OP said he was getting
> correct output in the PDF, and if he'd misunderstood the input format in
> the way you describe, then the PDF would be wrong too.
> 
> But something else that occurred to me is that there may be a further
> misunderstanding of MIDI format in play here:  MIDI never contains
> "accidentals" at all.  It only contains note numbers.

MIDI is based on E12, the 12-equal tone system. The staff notation, as used in 
LilyPond, is originally based on Pythagorean tuning, without enharmonic 
equivalences, which must be applied for the MIDI output.

>  In my example code:
> 
> \score {
>  \new Voice {
>    \key c \major
>    c'4 d'4 e'4 f'4 |
>    \key d \minor
>    bes4 a4 g4 f4 |
>  }
>  \layout { }
>  \midi { }
> }
> 
> The MIDI output will contain roughly this information:
> 
> key change, C major
> note 60
> note 62
> note 64
> note 65
> key change, D minor
> note 58
> note 57
> note 55
> note 53
> 
> If some other software, reading the MIDI file, displays these as notes
> with or without accidentals, and does or doesn't make the key-change
> events visible, then that has very little to do with Lilypond, which only
> generates the above data.  Note 60, for instance, might be a C or a
> B-sharp.  Even if it is B-sharp, it might be displayed with or without a
> sharp sign depending on whether there is one in the displayed key
> signature.  The MIDI file does not contain that information; it is up to
> whatever software reads the MIDI file, to display it appropriately.

So to go back to staff notation from MIDI, one must know what enharmonic 
equivalences that have been applied.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]