0

I am trying to build an application using pyaudio which can amplify sounds at certain frequencies without affecting sounds at other frequencies.

For example. If I was playing a piece of audio with 2 frequencies. 250Hz and 500Hz. How do I only amplify the sound at 250 Hz.

Any guidance on where to start would be very helpful. Whether its code stubs or where I should begin looking.

Or if there are other python libraries that do this I'd be very grateful to know what they are and how they do this.

  • audio can be fed into a Fourier Transform call often called fft which outputs an array of complex numbers ... array element 0 represents frequency 0 which is special ... as you iterate across this array each element is a freq bin with a frequency ... as you iterate across this array you increment the freq ... if you calculate the magnitude of each array element you will see high values for the freq bin(s) which match your source signal freq 250Hz and 500Hz ... to muck about with relative levels just edit the freq bin ... then send into an inverse fft call to get back new edited audio – Scott Stensland May 21 '20 at 10:53
  • Thank you @ScottStensland would I edit the frequency bins just by multiplying them by a factor? For example *1.5 if I want the amplitude to increase by 50%? Also if I want to plot the change in amplitude of that frequency on a graph do I do so before the inverse fft call? – cosinie May 23 '20 at 10:53
  • yes just multiply the real portion of the complex number of the freq bin array element of the desired frequency ( element position in array ) ... to plot the amplitude you need to calculate the magnitude of each freq bin ... `curr_mag = 2.0 * math.Sqrt(curr_real*curr_real+curr_imag*curr_imag) / number_of_samples` – Scott Stensland May 23 '20 at 11:06
  • be aware of the mercurial nature of audio ... changing the magnitude of freq X will have bleed over into its harmonic freqs as well as its neighbor freqs so audio has subtleties – Scott Stensland May 23 '20 at 11:29

0 Answers0