views:

218

answers:

6

Just wondering if it's possible to go through a flac, mp3, wav, etc file and edit portions, or the entire file by removing sections based on a specific frequency range?

So for example, I have a recording of a friend reciting a poem with a few percussion instruments in the background. Could I write a C program that goes through the entire file and cuts out everything except the vocals (human voice frequency ranges from 85-255 Hz, from what I've been reading)?

Thanks in advance for any ideas!

+1  A: 

SciPy can do all sorts of signal processing.

Ignacio Vazquez-Abrams
Is there anything in Java or C that can do that?
K-RAN
Dunno. I don't go deep enough into those.
Ignacio Vazquez-Abrams
+3  A: 

It is certainly possible, otherwise digital studio mixing software wouldn't exist.

What your'e effectively asking for is to attenuate frequency ranges across an entire file. In analog land, you would apply a low-pass and a high-pass filter (or some other combination of filters) to attenuate the frequencies.

In software, you'd solve this problem by writing a digital filter of sorts that would reduce the output of various frequencies. Frequencies would be identified via an FFT computation.

The fastest thing to do would be to use an audio editing app and apply the changes there.

There is an audio library called PortAudio that may provide some support for editing an audio stream at the numerical level. It is written in C, and has a C API.

sheepsimulator
You don't need FFT to filter based on frequency, though you can make use of it if you want. Low-pass, high-pass and band-pass filters often have extremely simple implementations requiring nothing more than a few adds and multiplies for each sample. Here's a simple [high-pass](http://en.wikipedia.org/wiki/High-pass_filter#Algorithmic_implementation) filter.
+2  A: 

If you want to test out audio processing algorithms I strongly suggest Supercollider. It's free and has many kinds of audio filter built in. But eliminating voice could require considerable tweaking. Supercollider will allow you to write code driven by various parameters and then hook those parameters up to a GUI which you'll be able to tweak while supplying it with live (or recorded) data.

Even if you want to write C code, you'll learn a lot from using Supercollider first. Many of the filters are surprisingly easy to implement in C but you'll need to write a certain amount of framework code before you can get started.

Additionally, I learnt quite a bit about writing digital audio filters from this book. Among other things, it discusses some of the characteristics of human speech, as well as how to build filters to selectively enhance or knock out particular frequencies. It also provides working C code.

+3  A: 

To address the OP's specific example: I think your understanding of human voice frequency is wrong. Perhaps the fundamental frequency of male spoken voice stays in that range (for tenor singing, or female speech or singing, or shouting, even the fundamental will go much higher, maybe 500-1000 Hz). But that doesn't even matter, because even if the fundamental is low, the overtones which create the different vowel sounds will go up to 2000-4000 Hz or higher. And the frequencies which define "noise" consonants like "t" and "s" go all the way to the top of the audio range, say 5000-10000 Hz. Percussion fills this same audio range, so I doubt that you can separate voice and percussion by filtering certain frequencies in or out.

Conrad Albrecht
A: 

You can also use MAX/MSP (but that's paid) or PureData (that's free) for working with music algorithms , they are the basis from which supercollider was created. And are excellent softwares if you want to do that on real-time envirollments.

Nemeth
A: 

I have a different requirement that I wonder someone could answer. Can I programmatically merge a small mp3 into an mp3 track? I clarify this I could give the example of MS word in which one could create a template letter with markers and reading of a database of markers, one could create customize letters to clients. I need something similar but dealing with MP3.

any guidance is highly appreciated. DA

DA9287