0

I need to extract musical features (note details->pitch, duration, rhythm, loudness, note start time) from a polyphonic (having 2 scores for treble and bass - bass may also have chords) MIDI file. I'm using the jMusic API to extract these details from a MIDI file. My approach is to go through each score, into parts, then phrases and finally notes and extract the details.

With my approach, it's reading all the treble notes first and then the bass notes - but chords are not captured (i.e. only a single note of the chord is taken), and I cannot identify from which point onwards are the bass notes. So what I tried was to get the note onsets (i.e. the start time of note being played) - since the starting time of both the treble and bass notes at the start of the piece should be same - But I cannot extract the note onset using jMusic API. For each note it shows 0.0.

Is there any way I can identify the voice (treble or bass) of a note? And also all the notes of a chord? How is the voice or note onset for each note stored in MIDI? Is this different for each MIDI file?

Any insight is greatly appreciated. Thanks in advance

Dolphin
  • 375
  • 2
  • 8
  • 16
  • I'm having trouble with your terms. #1: "2 scores for treble...MIDI file". What are "scores"? Do you mean 2 "staves", treble and bass, like piano sheet music? But MIDI doesn't have "scores" or "staves", it has "channels" (each channel is a different instrument), and each channel may be polyphonic (multiple notes playing at once). Explain? – Conrad Albrecht May 28 '10 at 14:26
  • Yes, I was referring to treble and bass. I didn't know that MIDI has no scores. Thanks for clearing my misunderstandings. But then, how do you know that a particular note belongs to the treble or the bass? And are these channels predefined ones or depending on the notes? Can a single channel represent several notes? If so can they be used to represent chords? What I really need is to extract these musical features from the MIDI, so that I can do a comparison over another set of musical features - to serve the purpose of an evaluator for piano playing. Thanks for your concern Conrad. – Dolphin May 28 '10 at 16:02
  • You still haven't explained what "scores" are; because the way you're using the word doesn't seem the same as the "musical score" term I know. – Conrad Albrecht May 28 '10 at 22:31
  • 1
    "how do you know that a particular note belongs to the treble or the bass": you mean, whether a note belongs in the treble or bass *staff*? You can't "know" in the general case, because MIDI doesn't carry this information. If you want to put MIDI notes on treble and bass staves you'll have to decide for yourself which staff they go on; which can be a very advanced problem. – Conrad Albrecht May 28 '10 at 22:40
  • Channels aren't "predefined" and they don't "depend on the notes" either. Channels let you specify notes for several different instruments in a single MIDI stream. For example, you could designate MIDI Channel 1 as "piano", MIDI channel 2 as "flute", MIDI channel 3 as "bass", and MIDI channel 10 as "drums", and then place piano, flute, bass, and drum notes in the same MIDI stream. – Conrad Albrecht May 29 '10 at 00:34
  • Thanks for replying Conrad. Apologies-yes I was referring to stave(staff)-treble/bass. So there's no way to track whether a note belongs to treble/bass stave? Is there a way to track the note's start time-to identify what were the notes played together? What I need is to compare 2 playings->this midi file(to be assessed/evaluated), against the reference playing (in xml-musical content stored in a table). I was hoping to extract musical content from midi, then take it to a table, and finally do the comparison. How can I do this for polyphonic without knowing what notes are played at what time? – Dolphin May 29 '10 at 11:03
  • Is there any other way I can approach this comparison? I have the reference playing (which I have managed to get to xml format, from which I extract musical content and store in a table)-this is what my second playing is evaluated against. The 2nd playing (in MIDI format), needs to be evaluated against the previous ref playing. I'm doing the performance evaluation by comparing musical content (per note) of each. How can I get details from the midi to a proper format at this state - I need to get each note detail for each bar or atleast at each instance. I'm confused. Appreciate any guidance. – Dolphin May 29 '10 at 11:09
  • Certainly you can get notes' start times from MIDI. That has nothing to do with what staff the note is notated on. But your concept of "notes played together" may be unclear. Humans can hardly ever play 2 notes *exactly* together even when they try, so even notes "played together" will have slightly different start times in the MIDI data. – Conrad Albrecht May 29 '10 at 13:37
  • Thanks Conrad. Is it to do with the note onset? Say, if I'm using Java, how can I access this note onset in a midi? Do you have any idea how I may approach it? Will it be possible from the Java Sound API. I tried from jMusic API - I couldn't access note onset. Many thanks for your time. – Dolphin May 30 '10 at 16:35
  • Is *what* "to do with the note onset"? – Conrad Albrecht May 30 '10 at 17:48
  • I don't know any Java API's, I can't tell you about those. If necessary you can read up on the MIDI file format and interpret a MIDI file with your own code. – Conrad Albrecht May 30 '10 at 17:50

1 Answers1

2

You might want to have a look at this question: Actual note duration from MIDI duration

Where a possible approach to extracting notes from a midi file is discussed.

Consider that a MIDI file can be split on multiple tracks (a "type 1" midifile).

Once you have identified notes, identifying chords can still be tricky. Say you have 3 notes: C, E, G happening "at the same time" (i.e. having been identified as being sound at the same point in a measure). When are they to be considered the C major chord?

  • played on the same channel
  • played by the same instrument (even if on different channels)
  • played on the same channel even if they appear on different tracks

Midifile format is very simple (maybe even too simple!!) I suggest you have a look at its description here: http://duskblue.org/proj/toymidi/midiformat.pdf

Community
  • 1
  • 1
Remo.D
  • 16,122
  • 6
  • 43
  • 74
  • Thanks for the insight Remo. I'm going through your links - need a little time to get it all right. I'm doing this only for the piano-so single instrument-same channel. So if 2 notes are played together (in treble and bass), are the 2 notes in the same channel? Then for a chord also-all notes in a chord-are they in the same channel/ track? Is this same for all MIDI files, or does it differ for each MIDI file-depending on how it's written into MIDI? Also what's the difference between track and channel? In the mean time, I'll read up on the MIDI spec. Advance thanks – Dolphin Jun 02 '10 at 00:11
  • 1
    The Midifile has no notion of "treble" or "bass" staves. Note 60 is the middle C (the one between the bass and the treble staves in a score) you place the other notes accordingly. Notes need not to be on the same channel nor in the same track, it depends on how the midifile has been created. It sounds more complicated than it really is. If you don't want to deal directly with bits and bytes, you can use a midi-to-text utility and do your analysis on a textual representation of the midifile. You can find one of such tools here: http://www.midiox.com/ (look for "text to midi" in the page) – Remo.D Jun 02 '10 at 08:31
  • Hi Remo - can you pls suggest a starting point to extracting note onset from midi? What you suggested - can this be approachable from Java Sound API? or do I have to code from scratch? I need to find a way for a start first. Apologies for the delay to comment on and for bothering. Thanks in advance. – Dolphin Jun 10 '10 at 13:27