Hello,

I have figured "it" out - Cakewalk expects Key Signature to be in Track 0 of a 
Midi file and Lilypond puts it in whichever track has it in, which is much more 
sensible. I realized this while compiling the cry for help below, so I've left 
my workings out in the message, but that seems to be the long and short of it.

Thanks for everyone's support.

Best

Giles


Here is an example of my input/output:

I create this by reading output from MIDIDSM which disassembles MIDI files  and 
outputs text which I manipulate into the Lilypond code below.
I can't with certainty provide the original source file, but it is not part of 
the workflow in question - it provided \key d\major \time 6/8
This is not the only way I get data into Lilypond - as previously mentioned, I 
also import using Frescobaldi, but it's what happens on the way out, I am 
trying to figure out.

When I run the snippet ......

\version "2.18.2"


\score {
  { \mark "Boore's Dance" \key d\major \time 6/8 a''4. g''4 d''8 g''8 e''4. 
fis''4 a''4. fis''4 d''8 g''4 e''8 d''4. \bar ".." }


\layout { }
\midi { }
}

I get ....

[cid:82b004c6-1e2c-4107-8b76-af84dd4b4476]
.... and a .MID that looks like this when I open it in Cakewalk without any 
further processing.


[cid:68c9f205-686b-4668-b485-006aaf8495cf]

Interestingly, my new installation (about a week old) on Windows 11, produces a 
file showing the \mark as a marker in Cakewalk, but still without the Key Sig.

... and produces this when processed by MIDIDSM with the options to export 
TIme/Key Sigs ticked ......

[cid:e9904548-372b-4782-9068-8348b490ab60]

MThd | Format=1 | # of Tracks=2 | Division=384

Track #0 ******************************************
    Time       Event
   1: 1:  0 |Time Sig    |  6/8      | MIDI-clocks\click=18 | 32nds\quarter=8
          |End of track|

Track #1 ******************************************
    Time       Event
   1: 1:  0 |Key Sig     |  D Major  |
          |On Note       | chan= 1   | pitch=A 4       | vol=90
      4:  0 |(Off) Note  | chan= 1   | pitch=a 4

followed by lots more Notes On/Off until

                |End of track|

I just noticed this, because I ran David Wright's midi file through MIDIDSM and 
the Key Sigs stand out because there's more than one.

So, Cakewalk expects Key Signatures in Track #0 and Lilypond doesn't put them 
there and how data is brought into Lilypond won't change that.





________________________________
From: David Kastrup <d...@gnu.org>
Sent: 11 May 2024 20:22
To: Giles Boardman <giles.board...@hotmail.co.uk>
Cc: msk...@ansuz.sooke.bc.ca <msk...@ansuz.sooke.bc.ca>; lilypond-user@gnu.org 
<lilypond-user@gnu.org>
Subject: Re: Key signatures in MIDI output

Giles Boardman <giles.board...@hotmail.co.uk> writes:

> You are, of course, right. Your evidence is clear. The position of the \key 
> command seems a strong candidate but I can't get it into the .MID even in the 
> simplest of snippet.
>
> As I mentioned I also have other behaviour I can't explain so it could also 
> be version related. I reinstalled the latest version I could find before the 
> release date of Windows 10, but it hasn't changed anything. I prefer to keep 
> my music-related work on a Windows 8.1 machine but that can  change .
>
> What I am trying to do is this:
>
> I have a big "library" of small, simple tunes that are variables, named for 
> their name and reference.
> I have "compiled" the library and found errors, which I have corrected.
> Now I can create medleys and audition them much more quickly than otherwise 
> possible by referring to the pieces by their variable name.
> Like this .....
>
> \version "2.18.2"
> % \include "C:\[lilify]\+progress\jukeboxpart1v2.ly"
> % \include "C:\[lilify]\+progress\jukeboxpart2v1.ly"
>
> "1K002-1a-_WILLIE_SHAW" = { \mark "1K002-1a-" \time 4/4 \key d\major { \time 
> 1/8 \partial 8  g''8 \time 4/4 fis''16 d''8. b'8. d''16 a'4 fis'4 fis'16 a'8. 
> d''8. fis''16 g''16 e''8. e''8. g''16 fis''16 d''8. b'8. d''16 a'4 fis'4 
> \time 7/8 fis'16 a'8. d''8. e''16 fis''16 d''8. d''8 \bar ":|." } }
> \score {
> {
> \key d\major
> \"1K002-1a-_WILLIE_SHAW"
> }
>
>  \layout { }
>
>   \midi { }
> }

Filename:     /tmp/xxx.midi
MIDI format:  1 (one or more simultaneous tracks)
Divisions:    1536 per whole note
#Tracks:      2

Track 1:
    Time 0:
        Text:       creator:
        Text:       LilyPond 2.25.12
        Time signature: 1/8, metronome 1/8
        Marker:     1K002-1a-
        Tempo:      1000000 msec/quarter
    Time 192:
        Time signature: 4/4, metronome 1/4
    Time 4800:
        Time signature: 7/8, metronome 1/8
    Time 6144:
        End of Track

Track 2:
    Time 0:
        Track name: \new:
        Key signature: D major
        Note on: Channel 0, G5(79)@90
    Time 192:
        Note off: Channel 0, G5(79)
        Note on: Channel 0, Fis5(78)@90
    Time 288:
        Note off: Channel 0, Fis5(78)
        Note on: Channel 0, D5(74)@90
    Time 576:
        Note off: Channel 0, D5(74)
        Note on: Channel 0, B4(71)@90
    Time 864:
        Note off: Channel 0, B4(71)
        Note on: Channel 0, D5(74)@90
    Time 960:
        Note off: Channel 0, D5(74)
        Note on: Channel 0, A4(69)@90
    Time 1344:
        Note off: Channel 0, A4(69)
        Note on: Channel 0, Fis4(66)@90
    Time 1728:
        Note off: Channel 0, Fis4(66)
        Note on: Channel 0, Fis4(66)@90
    Time 1824:
        Note off: Channel 0, Fis4(66)
        Note on: Channel 0, A4(69)@90
    Time 2112:
        Note off: Channel 0, A4(69)
        Note on: Channel 0, D5(74)@90
    Time 2400:
        Note off: Channel 0, D5(74)
        Note on: Channel 0, Fis5(78)@90
    Time 2496:
        Note off: Channel 0, Fis5(78)
        Note on: Channel 0, G5(79)@90
    Time 2592:
        Note off: Channel 0, G5(79)
        Note on: Channel 0, E5(76)@90
    Time 2880:
        Note off: Channel 0, E5(76)
        Note on: Channel 0, E5(76)@90
    Time 3168:
        Note off: Channel 0, E5(76)
        Note on: Channel 0, G5(79)@90
    Time 3264:
        Note off: Channel 0, G5(79)
        Note on: Channel 0, Fis5(78)@90
    Time 3360:
        Note off: Channel 0, Fis5(78)
        Note on: Channel 0, D5(74)@90
    Time 3648:
        Note off: Channel 0, D5(74)
        Note on: Channel 0, B4(71)@90
    Time 3936:
        Note off: Channel 0, B4(71)
        Note on: Channel 0, D5(74)@90
    Time 4032:
        Note off: Channel 0, D5(74)
        Note on: Channel 0, A4(69)@90
    Time 4416:
        Note off: Channel 0, A4(69)
        Note on: Channel 0, Fis4(66)@90
    Time 4800:
        Note off: Channel 0, Fis4(66)
        Note on: Channel 0, Fis4(66)@90
    Time 4896:
        Note off: Channel 0, Fis4(66)
        Note on: Channel 0, A4(69)@90
    Time 5184:
        Note off: Channel 0, A4(69)
        Note on: Channel 0, D5(74)@90
    Time 5472:
        Note off: Channel 0, D5(74)
        Note on: Channel 0, E5(76)@90
    Time 5568:
        Note off: Channel 0, E5(76)
        Note on: Channel 0, Fis5(78)@90
    Time 5664:
        Note off: Channel 0, Fis5(78)
        Note on: Channel 0, D5(74)@90
    Time 5952:
        Note off: Channel 0, D5(74)
        Note on: Channel 0, D5(74)@90
    Time 6144:
        Note off: Channel 0, D5(74)
        End of Track

As you can see, the key signature is right with the content track (track
2) and right at the start.

You really need to figure out which part of your processing then loses
it.

--
David Kastrup

Reply via email to