0

I am processing an audio file and want to modify the frequencies. What I have done so far is extract the data with scipy, normalize the signal with numpy and flatten it by extracting only the first column.

import numpy as np
from scipy.io.wavfile import read

def modify_friquencies(audio file, x):
  #extract data
  sr, data = read("sound.wav") #read
  #normalize data
  nd = data/np.max(np.abs(data))
  #convert to mono channel
  fd = nd[:,0]

How might one modify the frequencies of fd by adding the number x to it?

I have tried several things. I have transformed the signal to the frequency domain and tried calculating discrete Fourier transform of a Dirac distribution centered in x but I feel like that just shifts the signal and doesn't really modify the frequencies. To be frank I am in over my head with Fourier transformations or dealing with complex analysis in general.

Here is the last code I tried:

result = np.sin(2 * np.pi * (fd + x) * np.arange(len(fd)) / sr)

I just got static with my first test file. As for the second test file, it seems that this also performs a signal shift.

ps: I have denormalized the data after processing and I have also returned it without performing denormalization. Here is the code for the denormalization:

final_result = np.max(np.abs(result)) * result
Reinderien
  • 11,755
  • 5
  • 49
  • 77
Walaalka
  • 13
  • 3
  • Sounds like you want to do [pitch scaling](https://stackoverflow.com/questions/43963982/python-change-pitch-of-wav-file), i.e. changing the pitch of the signal without changing the speed of the signal. Is that right? – Nick ODell Jul 31 '23 at 21:59
  • What do you see as the difference between a "signal shift" and a "frequency shift"? The frequencies are part of the signal. You're going to need to be more specific. – Reinderien Aug 01 '23 at 03:21
  • signal shift effects the time and pitch scaling works with semitones as a unit which allow less precies monupilation. I tried resampling and it seems to be what i am actually looking for. I haven't achieved the desired output yet as i am experiencing some interference. Thank you both for your inputs btw xD – Walaalka Aug 01 '23 at 20:10

0 Answers0