views:

125

answers:

6

Is it possible to write a program that can extract a melody/beat/rhythm provided by a specific instument in a wave (or other music format) file made up of multiple instruments?

Which algorithms could be used for this and what programming language would be best suited to it?

+1  A: 

An instrument produces a sound signature, just the same way our voices do. There are algorithms out there that can pick a single voice out of a crowd and identify that voice from its signature in a database which is used in forensics. In the exact same way, the sound signature of a single instrument can be picked out of a soundscape (such as your mixed wave) and be used to pick out a beat, or make a copy of that instrument on its own track.

Obviously if you're thinking about making copies of tracks, i.e. to break down the mixed wave into a single track per instrument you're going to be looking at a lot of work. My understanding is that because of the frequency overlaps of instruments, this isn't going to be straightforward by any means... not impossible though as you've already been told.

There's quite an interesting blog post by Comparisonics about sound matching technologies which might be useful as a start for your quest for information: http://www.comparisonics.com/SearchingForSounds.html

BenAlabaster
Thanks for the encouragement, Ben!"the response however is assuming you know what kinds of instruments are in the trackwhich we don'tinstruments, effects, they all blend togetherTHEORETICALLY, if you are a human working on ONE TRACK and you know what kind of instruments they all are and their "sound signature" it could be donebut an automated process, impossibleIMPOSSIBLE" -a hater
Shane
You only need an area of the track where instruments are clearly distinguishable from each other, you don't need to know what they are. Something like comparisonics will tell you from their sound signature what they are. Even without knowing the instrument, you could use the identified sound signature to extract the rest.
BenAlabaster
To clarify by "extract" I don't mean remove it from the original track, I mean make a copy track containing just that "voice" - except where signatures overlap to the point that they can't be electronically identified from each other. Although, I'd imagine that just like colour, a machine could identify sounds that we absolutely can't distinguish the difference between with our human ears.
BenAlabaster
A: 

Look into Karaoke machine algorithms. If they can remove voice from a song, I'm sure the same principles can be applied to extract a single instrument.

Neil N
A: 

Most instruments make sound within certain frequency ranges.

If you write a tunable bandpass filter - a filter that only lets a certain frequency range through - it'll be about as close as you're likely to get. It will not be anywhere near perfect; you're asking for black magic. The only way to perfectly extract a single instrument from a track is to have an audio sample of the track without that instrument, and do a difference of the two waveforms.

C, C++, Java, C#, Python, Perl should all be able to do all of this with the right libraries. Which one is "best" depends on what you already know.

Dean J
A: 

This is a fascinating area. The basic mathematical tool here is the Fourier Transform. To get an idea of how it works, and how challenging it can be, take a look at the analysis of the opening chord to A Hard Day's Night.

Jason
A: 

To extract the beat or rhythm, you might not need perfect isolation of the instrument you're targeting. A general solution may be hard, but if you're trying to solve it for a particular piece, it may be possible. Try implementing a band-pass filter and see if you can tune it to selects th instrument you're after.

Also, I just found this Mac product called PhotoSounder. They have a blog showing different ways it can be used, including isolating an individual instrument (with manual intervention).

Adrian McCarthy
A: 

It's possible in principle, but very difficult - an open area of research, even. You may be interested in the project paper for Dancing Monkeys, a step generation program for StepMania. It does some fairly sophisticated beat detection and music analysis, which is detailed in the paper (linked near the bottom of that page).

Nick Johnson