mp3 wav midi conversion

Hi,

I am trying to write a program that will convert mp3 or wav file to midi. I know that the result will be approximate but I think it will be a good experience since i am quite new in java.From the information I have gathered so far I know that I need to perform a fft algorithm on the mp3/wav file in order to get the midi one. Can anyone give me a helping hand on how can i do that? or give me like a rough idea of the steps have I have to follow in order to achieve that.

Thanks

[502 byte] By [relmoa] at [2007-10-2 11:47:57]
# 1
May I suggest mastering the basics first? http://java.sun.com/docs/books/tutorial/
prometheuzza at 2007-7-13 6:05:27 > top of Java-index,Other Topics,Algorithms...
# 2
Thanks, however I know the basics java functions. I have already created the Gui, and the classes that read the mp3 file. I need tips about how to do the conversion. Which algorith should i use?if any code could you please provide.Thanks for your help
relmoa at 2007-7-13 6:05:27 > top of Java-index,Other Topics,Algorithms...
# 3

> Thanks, however I know the basics java functions. I

> have already created the Gui, and the classes that

> read the mp3 file. I need tips about how to do the

> conversion. Which algorith should i use?if any code

> could you please provide.

> Thanks for your help

Well, you said you were new to Java. That's why I suggested the basic tutorials.

I'm curious how you're reading the MP3 files.

But I doubt that you need an FFT algortihm for your task. I even doubt that converting WAV (or MP3) to MIDI is possible. MIDI is just a series of instructions to musical instruments while WAV is a digitized version of an audio signal.

prometheuzza at 2007-7-13 6:05:27 > top of Java-index,Other Topics,Algorithms...
# 4
I am using Javazoom Jlayer and BasicPlayer to do the the reading. Which algorithm you think should be used to perform the conversion. There are doftwares onthe market that do the conversion although is not really perfect.Thanks
relmoa at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 5

> Which algorithm you think should be used

> to perform the conversion.

Like I said: I don't think you can convert from WAV to MIDI. How will you recognise which instruments are played in the WAV file. I get the impression you don't fully understand what MIDI is.

> There are doftwares onthe market that do the

> conversion although is not really perfect.

From MIDI to WAV maybe. I've never used such software, and I'm only guessing, but I think the conversion is done by simply playing (on a higher speed) the MIDI file and recording a WAV from it.

prometheuzza at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 6
I would not be surprised if it were possible to write really clever sound analysis code that could translate from WAV to MIDI with a reasonable degree of accuracy, but I really, really doubt there is a library for it in Java.Drake
Drake_Duna at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 7
softwares like intelliscore does the conversion from wav to midi. Does anyone know the procedure it uses?Thanks
relmoa at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 8

> softwares like intelliscore does the conversion from

> wav to midi. Does anyone know the procedure it uses?

> Thanks

From intelliscore website:

If you wanted polyphonic WAVE, MP3, or CD files to be converted to MIDI, you simply had no alternative but to succumb to the often tedious and time-consuming task of picking out the notes yourself, time that could be better spent on more creative endeavors.

Finally, the result of a spark of a dream and six years of research, Innovative Music Systems, Inc. is offering its patented technology for polyphonic WAVE to MIDI and MP3 to MIDI conversion to musicians like you.

They've had some time to develop it. And I don't think they did it in Java.

There is no specific magic thing, or set of rules to perform, to make such a conversion.

But good luck anyway.

prometheuzza at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 9
Basically, the conversion would not be accurate. Thats why I reckon they gave the opportunity of picking the notes.I am still wondering what algorihtm they use to make the conversion.Thanks
relmoa at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 10
This is like the person who asked us to help her write an algorythm to determine whether English words matched based on their spelling.You bet. How much do you pay per year?Drake
Drake_Duna at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 11
I don't get what you sayin. I just need some clarifications about the algorithms i need to use in order to do such conversion not to write the whole program for me.Thanks
relmoa at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 12
What we are trying to tell you is that the complexity of the task would probably justify a library with a higher number of classes than the number of lines of code you were expecting to write.Drake
Drake_Duna at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 13
I see, however do you have any hints about the algorithms that should be used or do any other information that can get me going.Thanks
relmoa at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 14

MIDI files contain pitch, duration and volume information for each of the notes. FFT will give pitch and volume almost directly. Duration is a little more difficult. I would think you would want to take a series of FFTs on your data, and watch for when certain pitches come in and out. Maybe use a HashSet to keep track of which pitches are "active" at any given time.

The problem gets more difficult if you want to recognize drums. I bet a simplified speech recognition algorithm would work well for that.

Good luck.

RadcliffePikea at 2007-7-13 6:05:28 > top of Java-index,Other Topics,Algorithms...
# 15
i think you will find this site exciting http://www.jsresources.org/examples/index.htmland also http://members.cruzio.com/~webcab12/cis12_spring03/bobhul/FFTbob/FastFourierTransform.java
ptidmarsha at 2007-7-20 21:16:47 > top of Java-index,Other Topics,Algorithms...
# 16
Is there anybody out there that could help me clarify this topic?Thanks in advance
relmoa at 2007-7-20 21:16:47 > top of Java-index,Other Topics,Algorithms...
# 17
What specifically are you having trouble with?
RadcliffePikea at 2007-7-20 21:16:47 > top of Java-index,Other Topics,Algorithms...
# 18
I have managed to found a fft algorithm which after a series of test gave me the results I was expecting.I am not sure how to extract the midi file from the result after the fft on the mp3.Best Regards
relmoa at 2007-7-20 21:16:47 > top of Java-index,Other Topics,Algorithms...
# 19

Well, start slow and simple. Its probably easiest to start with a nice simple wav file like C:\Windows\Media\chimes.wav

The first task would seem to be to compute several FFT's over short segments of the wav file, derive the power spectrum of each FFT, and see if you can identify the individual notes.

(You weren't thinking this was going to be easy, were you?)

RadcliffePikea at 2007-7-20 21:16:47 > top of Java-index,Other Topics,Algorithms...
# 20
I am having problems identifying the individual notes.I am note sure how this is done.
relmoa at 2007-7-20 21:16:47 > top of Java-index,Other Topics,Algorithms...
# 21

First, you need to get the power spectrum. A cheap way to do this is to multiply each value from your FFT by its complex conjugate (the result won't be scaled properly, but your only interested in the peaks, so it should be ok). The power spectrum tells you the amount of energy for each frequency in your signal. So search the spectrum for peaks and this will tell you where the active frequencies are. Then you can use a lookup table like this:

http://www.phy.mtu.edu/~suits/notefreqs.html

to find the notes. (You don't need the table, you could just as easy calculate it yourself)

RadcliffePikea at 2007-7-20 21:16:47 > top of Java-index,Other Topics,Algorithms...
# 22
thanks, I am working on it.
relmoa at 2007-7-20 21:16:48 > top of Java-index,Other Topics,Algorithms...
# 23
Could you please recommend me an FFT algorithm? I have tried the one posted above but it takes forever for a 10s file.thanks
relmoa at 2007-7-20 21:16:48 > top of Java-index,Other Topics,Algorithms...
# 24

FFTW is the probably the closest thing to a standard FFT: http://www.fftw.org. Its GPL (not LGPL), you have to pay MIT if you want to release your code under anything but the GPL.

About 3/4 of the way down the download page there is a link to some Java wrappers:

http://www.fftw.org/download.html

A bit of a learning curve to using the software, but you're not likely to find anything faster without paying for it.

RadcliffePikea at 2007-7-20 21:16:48 > top of Java-index,Other Topics,Algorithms...
# 25
Thanks, for your help I have managed to extract the notes from simple wave files. Could you please tell me what is the next step? Thanks in advance
relmoa at 2007-7-20 21:16:48 > top of Java-index,Other Topics,Algorithms...
# 26

> Thanks, for your help I have managed to extract the

> notes from simple wave files. Could you please tell

> me what is the next step? Thanks in advance

Well, good work getting the notes out. The next thing is to get the duration of the notes. One possible way to do this would be to perform FFT on a short window of your wave file, say 1/20th of a second. Get the notes that are "active" in that window. Then move the the next 1/20th of a second window and get the notes there and compare them with what you had in the previous window. You will then be able to see where each note begins and ends, and you can use this to build your midi file.

This is the simplest possible recognition algorithm that I could come up with, and if it works at all, it will only work for very simple sound files. Beyond this, I think you're into an open and very difficult research project. There's been a lot of research into speech recognition that you may want to look into.

Good luck!

RadcliffePikea at 2007-7-20 21:16:48 > top of Java-index,Other Topics,Algorithms...
# 27
hi ,thereI am having trouble creating the midi files from an array of notes.I created a sequence as it is adviced and store the notes in a track but the file is not created properly.thanks in advance
relmoa at 2007-7-20 21:16:48 > top of Java-index,Other Topics,Algorithms...
# 28

> hi ,there

> I am having trouble creating the midi files from an

> array of notes.

> I created a sequence as it is adviced and store the

> notes in a track but the file is not created

> properly.

> thanks in advance

:-) Priceless!

sabre150a at 2007-7-20 21:16:48 > top of Java-index,Other Topics,Algorithms...