PG Music Home
Posted By: jonel Key detection of a loaded midi file - 09/27/19 05:53 AM
I just love the help provided by RealBand in detecting and displaying the chords of a midi song when it is loaded. I thought how nice it would be if it also displayed the likely key of the song as well.
The information does give me a fantastic steer but are there any tips in getting the key quickly?

Thanks
Posted By: Mike Head Re: Key detection of a loaded midi file - 09/27/19 10:47 AM
Hi Jonel

If I simply OPEN a midi file in Realband.
It ask to split to separate tracks if type 0, this of course I do,
Both the key and meter and tempo are displayed at the top of the page, both in chord sheet view and track view .
As a mater of interest you will normally find the first chord in the song is the key.
And the last chord, if it has not been taken up a semitone to give a lift for the repeat.
Just my thoughts. See pics.
Mike


Attached picture key track.jpg
Attached picture key_chord.jpg
Posted By: rharv Re: Key detection of a loaded midi file - 09/27/19 07:54 PM
Mike,
In your first image, what does the line between the key and measure 4 indicate?
That one lost me.
If the line were between the key and measure 3 it would make more sense to me. The chords/key match this way and that's the first measure of the song (as you referenced).
But the image is connecting the key to measure 4 .. confused me.
Posted By: jonel Re: Key detection of a loaded midi file - 09/27/19 08:44 PM
Hi Mike,
I appreciate what you say and I did think that this was meant happen. However, a couple of things tend to mess up the detection process and that is when there is a modulation in the song (and this is quite often) and so it is not really possible to come up with an actual key. The couple of times that I did get the key reported back correctly was when there was no modulation. With a modulated song the key was simply reported as 'C'.

The beginning chord is often not the key of a song though, especially with an intro but I understand the last chord. But you have definitely clarified a few things for me here.

When I came across a modulated song I pushed it across to Ableton where In could use the 'fold' feature and determine where the key changed.

Thank you very much.
Posted By: Mike Head Re: Key detection of a loaded midi file - 09/27/19 09:21 PM
HI rharv

Sorry bad mouse it should have been just an ARROW to indicate the key box. Now sorted.
Mike
Posted By: rharv Re: Key detection of a loaded midi file - 09/28/19 10:14 AM
wink Now I get it
Posted By: jonel Re: Key detection of a loaded midi file - 09/28/19 12:40 PM
Mike,
I'm not sure that RealBand realy can detect the key properly from pure midi information. Following on from what you said about this feature I tried a wide range of midi files, but the majority simply showed up with a key of 'C' which was clearly incorrect. I thought it may have to do with the modulation in the channels that were being used for detection and this really would have been a problem as I mentioned in previous reply.

In desperation I cut the midi down to just 3 bars with a key that is clearly G. The chord view and the track view are shown below, but the key still resolves to C.

There were occasions when a key other than C was shown but, for the life of me, I can't see any connection here.

Pedrhaps you might advise on the pics below please?


Posted By: Mike Head Re: Key detection of a loaded midi file - 09/28/19 02:39 PM
HI

I have just research this a bit on Google ,

It seems as Midi notes are in fact just note number that corresponds to a note
eg midi note 60 middle C midi note 69 concert pitch A (440 Hz)
so therefore would have no way of telling whether the note would be the first or 5th or any other interval of a scale.

However there is a key signature" meta-event but this is optional and may not be present in all midi files,

Quote from Google search composite:

“My understanding is that MIDI files use fixed numbers/names for all notes, as shown e.g. in this chart. At the same time, MIDI has a "key signature" meta-event. What's the purpose of the key signature information?

It won't go out the midi port to your keyboard, but the midi sequencer programs that display notation need it if they're going to show the music in standard notation. It's also helpful if you're a composer and want to know what the key is. Without it, a C4 might be the I, or might be the fifth or somewhere else in the key. You could generally guess based on the notes you have assuming it's western music, but the key signature makes it concrete.

Many DAWs can also take MIDI data and display it not only as event lists or piano-roll notation but also as standard music notation. But in order to do that accurately, it's helpful if the Standard MIDI File indicates key signatures, so the DAW can figure out whether pitches should be labelled as flat notes or sharp notes in the display.

If somebody who creates a Standard MIDI File wants to label it with a key signature, or wants to label different sections within the song with different key signatures, isn't that a desirable and useful piece of information? The Standard MIDI File specification supports that feature, so musicians use it.

Many DAWs utilize this to automatically transpose the MIDI notes in case you change the key after you composed it. For ex, if you composed a song in C, and you change the key signature in your DAW to D, all the notes will be transposed and played appropriately.”


This would explain your problem.
Mike
Posted By: jazzmammal Re: Key detection of a loaded midi file - 09/28/19 04:35 PM
More downloaded midi files crap. If the original author failed to set the key, every sequencer in the world defaults to C. Same with tempo, it defaults to 120. Many midi files are played live and if the player simply starts playing with no metronome he would not notice the tempo was set to 120, you can play any tempo. And people forget to set the key all the time.

Bob
Posted By: jford Re: Key detection of a loaded midi file - 09/28/19 07:31 PM
RealBand doesn't detect the key of the song; it just uses whatever key signature (which may or may not be the key of the song) was set in the MIDI file, which by default is C.

Of course, you can change it as you wish.
Posted By: jonel Re: Key detection of a loaded midi file - 09/28/19 07:49 PM
Hi Mike,
Not really (explain the problem that is). The midi notes are what they are for the song. No matter what octave a note belongs to, it will still belong to the same chord. The chords themselves are being correctly detected and displayed. It's just the key that isn't correct.

Now the manual doesn't really say the it does actually detect the key - I was just hoping that this might be the case. Also, as I said in an earlier post, if the song contains more than one key (for example through modulation) then it is not possible to arrive at a key for the whole song anyway. I thought the chord wizard might have given me the ability to detect a partial song, but i doesn't. That's why I reduced the the song to just where I knew the key was definitely 'G' and there was no means of picking up notes that would have 'confused' the process. My guess is that it simply doesn't do it.

I do thank you though for the work you have done in trying to resolve the issue. Being able to detect the chords is an enormous benefit anyway and its not too difficult to find the key from there.


John
Posted By: jonel Re: Key detection of a loaded midi file - 09/28/19 07:59 PM
Hi All,
I'm really grateful for the interest and comments on this topic. Before I started looking at this issue I was well aware of how the mid file may contain (or may not) the details of key and tempo etc. What prompted my initial post was that since the auto chord wizard can easily detect all the chords then it might have been possible to at least point to a likely key. The more I thought about it the more I realised that this was not really possible.

John
Posted By: Mike Head Re: Key detection of a loaded midi file - 09/28/19 09:12 PM
Originally Posted By: jonel
Hi All,
I'm really grateful for the interest and comments on this topic. Before I started looking at this issue I was well aware of how the mid file may contain (or may not) the details of key and tempo etc. What prompted my initial post was that since the auto chord wizard can easily detect all the chords then it might have been possible to at least point to a likely key. The more I thought about it the more I realised that this was not really possible.

John

Hi Jonel

Yes that what I meant when I said although it cant tell if the note it detected is the 1st in the scale ( the tonic ) or the 3rd 5th or whatever scale interval. It just a note, E could be the tonic of the E or the third of C
Chord detection is easier because if you have C E G at the same time then it will be C which ever order they are in it be an inversion of C.

This is why any key sig info has to be written as meta data.

Mike

Tip for getting the key and tempo quickly:


Render the midi file to audio and analyze that audio file using the Audio Chord Wizard. It will provide the key signature, tempo and chords usually within 4 measures.
Posted By: Jim Fogle Re: Key detection of a loaded midi file - 09/29/19 09:20 PM
MIDI data is note based. Chord data or chord detection are not part of the MIDI standard.

2019 is a transitional year for the MIDI standard. The MIDI standard is being updated from MIDI 1 to MIDI 2. Presently a preliminary MIDI 2 standard has been published so hardware that supports the standard can be developed and released. However the standard has not been finalized as testing may reveal wording may need to be modified to ensure consistent interpretation of the standard.

There is nothing in the proposed MIDI 2 standard addressing support for MIDI chord data or chord detection.
© PG Music Forums