0

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.

vvm32812
  • 1
  • 1
  • "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). – Marcus Müller Feb 19 '20 at 19:32
  • 2
  • 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". – Marcus Müller Feb 19 '20 at 19:34
  • @MarcusMüller Ah, yes. My bad, I meant to say frequency ranges. I have edited the post accordingly – vvm32812 Feb 19 '20 at 19:34
  • Don't worry, was just nitpicking on my side :) It's cool you help your granddad, btw. – Marcus Müller Feb 19 '20 at 19:35
  • @MarcusMüller Thank you! I'm feeling a little over my head right now though. It's a lot to take in and learn. I feel like my basic understanding of the algorithm is clear, but the implementation details surrounding it is not. This question seems extremely broad, yet I could not find implementation details for something such as this. Would you know where I could read up on this so that I may come back more informed? – vvm32812 Feb 19 '20 at 19:36
  • it'll totally be OK! Really, get audacity. – Marcus Müller Feb 19 '20 at 19:42
  • It'd be great if you could change your question to not suggest fiddling with coefficients after the FFT; because that's really already answered by the answer I've linked to, and will lead to your question being closed. Your underlying problem isn't per se solved, so I think it's worth asking nevertheless. – Marcus Müller Feb 19 '20 at 20:42
  • @MarcusMüller Does this problem extend to reducing the frequency ranges by a percent rather than just zeroing them out? Regarding audacity, I was hoping to integrate it directly into an application so that I do not have to send him his entire library song by song, rather he can directly input in a youtube url and it will give him the output file that he can listen to. – vvm32812 Feb 20 '20 at 01:32
  • yes, it does extend. Yes, that's possible; read my answer's end to that exact end. – Marcus Müller Feb 20 '20 at 08:40
  • @MarcusMüller I see. While trying to understand fft, I came across many different sources which all listed reducing noise in a recording as an example use case. How does my question differ from this classic example of doing something such as this given when discussing the applications of fft? Furthermore, you mentioned earlier that I should edit my question for clarity. How would you edit it as such - I'm a little confused on that end. – vvm32812 Feb 20 '20 at 08:50
  • On what device does you grandpa listen to music? – jojeck Feb 20 '20 at 10:29
  • @jojek his phone is hooked up to a speaker system I set up for him - but I don't see how that's relevant – vvm32812 Feb 20 '20 at 11:53
  • 1
    @vvm32812: It is relevant, since you can apply the filtering in real-time either on the playback device or speaker system. – jojeck Feb 20 '20 at 11:54
  • Cross-posted: https://stackoverflow.com/q/60295951/781723, https://dsp.stackexchange.com/q/64004/5874. Please do not post the same question on multiple sites. – D.W. Sep 29 '20 at 19:34

1 Answers1

3

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.)

Marcus Müller
  • 30,525
  • 4
  • 34
  • 58
  • 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. – TimWescott Feb 20 '20 at 18:57