0
$\begingroup$

How would I take a song input and output the same song without certain frequency ranges?

Based on my research so far, the song should be broken down into chucks, FFT it, reduce the target frequency ranges, iFFT it, and stitch the chunks back together. However, I am unsure if this is the right approach to take, and if so, how I would convert from the audio to FFT input (what seems to be a vector matrix), how to reduce the target frequency ranges, and how to convert back from the FFT output to audio, and how to restitch.

So far, I've understood the basic premise of fft (through basic 3blue1brown yt videos and the like) and that it is available through scipy/numpi, and figured out how to convert from youtube to 0.25 second chunks in a wav format. I've tried googling the problem, but while many people say it's trivial, I cannot find an explanation with psudocode or actual code.

For background, my grandpa loves music. However, recently he cannot listen to it, as he has become hypersensitive to certain frequency ranges within songs. I'm a high school student who has some background coding, and am just getting into algorithmic work and thus have very little experience using these algorithms. Please excuse me if these are basic questions; any pointers would be helpful.

$\endgroup$
  • $\begingroup$ "without certain frequencies: I hope you mean frequency ranges; otherwise, the difference will be in the mathematical sense of the word be inmeasurable for non-line spectra signals like songs (which are finite and hence can't have line spectra). $\endgroup$ – Marcus Müller Feb 19 at 19:32
  • 2
    $\begingroup$ Does this answer your question? Why is it a bad idea to filter by zeroing out FFT bins? $\endgroup$ – Marcus Müller Feb 19 at 19:33
  • $\begingroup$ However, please read the above answer. Filtering through zeroing or directly scaling single FFT bins is never a good idea. You simply need to use a filter bank. On your good ole Hifi stereo, that thing is called an "equalizer". $\endgroup$ – Marcus Müller Feb 19 at 19:34
  • $\begingroup$ @MarcusMüller Ah, yes. My bad, I meant to say frequency ranges. I have edited the post accordingly $\endgroup$ – vvm32812 Feb 19 at 19:34
  • 1
    $\begingroup$ @vvm32812: It is relevant, since you can apply the filtering in real-time either on the playback device or speaker system. $\endgroup$ – jojek Feb 20 at 11:54
3
$\begingroup$

Zeroing out bins / attenuating them in discrete Fourier domain is universally a bad idea, due to the undesirable time-domain effects of that.

Instead, use a audio processing program to apply an adjustable equalizer to the song of choice. Let's walk you through Free software:

  • Get audacity;
  • load your song in that, open "Effects"->"Equalizer"
  • start with one of the presets to see how things work, and then
  • sit down with your grandpa and figure out what frequency ranges to dampen.
  • Save that preset!
  • You can later apply it to all your music collection using batch processing.

You should also, in that Equalizer dialogue, "manage / export" your freshly designed filter frequency response. With a little work, you could, for example, build a digital equalizer (in music, your granddad probably won't mind the latency that brings, which would be a bad thing in live music) using e.g. a Raspberry Pi and a USB soundcard, which you could put in between you granddad's CD player and his amplifier, or so. (of course, it could also act as media player/server/center/whatevs.)

| improve this answer | |
$\endgroup$
  • $\begingroup$ Another way to skin this cat would be to get a real-time equalizer app for Grandad's computer (and/or phone). You should be able to do pretty much the same thing. However -- I have no direct experience with such things; I just know by word of mouth that they exist. So you'll be doing an experiment. $\endgroup$ – TimWescott Feb 20 at 18:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.