• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to measure the Frequency/Pitch/Note of a Midi File?

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi guys,

I am new in this forum, actually this is my first post. I am also a relatively new java programmer, i just learned to use the language weeks ago. So forgive if i say something totally nonsense. ^^

Well, here is my problem:

i've created a midi player program. And i need to measure (any units of measurement will do) the notes being played in the midi file.. does anyone know how to do this?

thanks a lot, in advance!
 
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


It's a MIDI file: there's nothing to "measure."

http://tomscarff.110mb.com/midi_analyser/midi_note_frequency.htm
 
Sj Balatan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi david,

im not really sure what you mean by there's nothing to measure in a midi.

well, can i have a sample code, where i can get the value of the midi notes from the file.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I mean the note value is contained in the note messages, it's not like you have to run a fourier analysis to figure out what notes are playing.

Have you looked through the Java MIDI tutorials, where you'd find things like javax.sound.midi.spi.MidiFileReader, javax.sound.midi.Sequence, javax.sound.midi.Track, and javax.sound.midi.MidiEvent?

I'd probably also search around to see if someone else has already written utilities to wrap all this up--I don't know what you're actually trying to do, but it seems pretty common.
 
Sj Balatan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here is what i'm trying to do. I am a college student, and I need to finish this program in order for me to graduate.

My program should be able to:
a. have basic functionality of a midi player (play, pause, stop, file open, volume etc)
b. measure the pitch (frequency) of a singer using a mic in real time.
c. adjust the song(midi) pitch, and align it to the pitch of the singer.

I've already finished A, B. Im just having a hard time figuring out C. I need to know the pitch of the song in real time, and adjust accordingly. I getting confused on how to use note messages (maybe because of lack of sleep ).

thanks david, I appreciate that someone is actually talking to a newbie like me.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You probably mean the key of a song, then, not the pitch--a song doesn't have a pitch, a note does. I question what this would actually mean, however, since changing the key of a song throughout the song would make it really, really suck. A lot. That's why there are autotuners, that correct the pitch of the *singer*, and try to align it to the expected notes of the song.

Doing it the other way around seems... like something used as a torture device on anyone that can hear tones.
 
Sj Balatan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i can't do it the other way around, because i already passed a proposal to my adviser(and i cant change it now, whether the results will be good or bad)

im planning to use pitchBend() on each channel of the Midi in changing the pitch..

can you teach me how to use midi notes, or just how to get the pitch of each notes of the midi song..?
 
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Sj Balatan wrote:b. measure the pitch (frequency) of a singer using a mic in real time.


This part suggests that yes, you do really mean pitch rather than key. But it's important to note that this part would have nothing to do with a midi file, at this point. You're talking about looking at the raw wave output and determining the dominant frequency associated with it. This would probably involve a Fourier transform and finding a maximum. But I share David's skepticism here - this sounds like a bad idea. If a singer is out of tune, is it better to fix the orchestra, or fix the singer? Maybe if the singer is consitently out of tune, the latter might work, sort of. But I think most out-of-tune singers will probably be out-of-tune by an inconsistent amount. So if you "fix" the orchestra to match them, the end result will just... how should I say this?... suck. Badly.
 
Sj Balatan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi mike,

I already done with B. part. I can now actually measure the frequency of the singer using a mic. and yes, it has nothing to with midi.

i agree with you both guys, that It is indeed a bad idea, and it is better if i do it the other way around. But this is what my adviser suggested me to do, it doesn't matter much if it will turn out good or bad. I only need a conclusion with this study, i need to stick with it till the end..
 
Mike Simmons
Master Rancher
Posts: 4806
72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
OK. So you've got a singer, and you know how to determine the frequency they are singing at, at any particular point in time. And you've got a MIDI file of music intended to accompany them. And you want to make these match up, by altering the accompanying music, rather than altering the singer. OK.

Important questions: does the MIDI file also contain the notes that the singer is trying to sing? And can these notes be identified and distinguished from the other notes?
 
Sj Balatan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

OK. So you've got a singer, and you know how to determine the frequency they are singing at, at any particular point in time. And you've got a MIDI file of music intended to accompany them. And you want to make these match up, by altering the accompanying music, rather than altering the singer. OK.



yes, exactly.

Important questions: does the MIDI file also contain the notes that the singer is trying to sing? And can these notes be identified and distinguished from the other notes?



that's one of my main problem, i can't get the notes of the midi file.
 
David Newton
Author
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
What code do you have so far? The classes I listed above are the classes you need, although you'll also need to track song position in real-time in order to insert the MIDI messages.
 
Sj Balatan
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


basically, this the backbone of my midi player.. hope this will get you a glimpse of my project.
reply
    Bookmark Topic Watch Topic
  • New Topic