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