views:

309

answers:

5

I want to learn how to program a music application that will analyze songs.

How would I get started in this and is there a library for analyzing soundwaves?

I know C, C++, Java, Python, some assembly, and some Perl.

Related question: Algorithm for music imitation

A: 

You may like to start by looking at the MIDI format, it's reasonable simple compared to the compressed formats, and you can generate some nice things in it.

Depends what you want to do really.

Noon Silk
I want to analyze pop songs and see if there are commonalities between the popular ones. This has probably been done, but it's more of a programming exercise for me.
Mylo
Then you'll need to break it down. Take an MP3, bring it back to it's native format, and analyse it as you wish. You could try searching sourceforge, if you wish, for libraries to do this.
Noon Silk
Yes - 3 chords ;) E, Am and Dm. This is all you need for 90% of pop songs. Add C and G and you've just covered 5% more
DmitryK
Hahaha. Yea. That's pretty much it. But I also want to look at certain commonalities between time signatures and what exactly does make a song popular. I want to know HOW I would go about analyzing it also.
Mylo
+3  A: 

To analyze soundwaves you need some sort of fourier transformation (fft), so you can split the song up into it's frequencies and how they change over time. There exists fft support in numpy, I haven't used it, so I don't know if it's any good. But it would be a great place to start.

After that you then need to make some sort of statistical analysis on frequencies and patterns, and then I no longer have any clue what I'm talking about.

Cool stuff though, go for it!

Lennart Regebro
+6  A: 

Once you get past the FFT stuff that Lennart mentioned, you might want to have a look at Markov chains for analyzing intervals between notes, and aggregated patterns.

This is kind of treaded ground, but Markov chains have been used in the past to build a kind of statistical model of melodies from various songs which can be used to generate new melodies. Markov chains can do the same with written english sentences. For an example of how that looks, have a play with the megahal chatterbot to see how markov chains can produce mangled output that statistically looks like its input (in megahal's case, it looks like english sentences)

You could concievably mash up the top 100, and have a markov chain generator blast out the next big hit.

On the other hand, you may want to consider the possibility that it is not any quality of the music itself that makes a song popular. Or perhaps it is a quality of music issue combined with marketing.

Breton
Yeah, you will never make hits like this. For that you need to understand why a hook is a hook, and statistical analysis of songs is not likely to help with that, as hooks can be so different. But it's still a fun project.
Lennart Regebro
+6  A: 

Composition and analysis of music by computer is a huge field. There are two basic areas in this type of work, which overlap somewhat.

Many, many libraries, tools and specialised programming languages exist which can help with different parts of these problems. Here's a list of music-related programs and libraries for Python. There is a lot of technology available; you should be able to find something that will do the brunt of the work for you. Reimplementing a 'musical parser' through very low-level frequency analysis tools such as Fourier Transforms, as other answers have suggested, while possible, will be quite difficult and is almost certainly unnecessary.

For further advice and specific questions, the International Society for Music Information Retrieval has a mailing list which you would probably find very helpful.

ire_and_curses
Thanks!One more questions. Would it be possible to write a program that transcribes music for you?
Mylo
That's pretty hard. I know that Yann LeCun and his company MuseAmi are working on it http://www.nytimes.com/2010/08/21/arts/music/21taub.html.
A: 

There's the Echo Nest remix API that lets you analyze and manipulate music in Python. Some examples here: Where's the pow and here: You make me quantized miss lizzie. There's a nifty tutorial here: An overview of the Echo Nest API

plamere