Hi,

You need the angle to restore the sound. Otherwise you don't get the
phase information.
Just store the angle information and apply it?

Cheers,

Matthieu

Le dim. 24 janv. 2021 à 14:27, <klark--k...@yandex.ru> a écrit :
>
> Hello friends!
> Maybe that's not directly a Numpy question but I think it can be solved by 
> Numpy.
> I do RFFT of microphone sound and find its absolute value np.abs(). Than I 
> need to do IRFFT but I don't know how to restore sinusoida after np.abs(). I 
> can't not to use 'abs'. I need it in my code. Is there any rough way to 
> restore sound sinusoidal signal from its absolute values. Thank you for your 
> attention!
>
> import numpy as np
> import scipy
> import matplotlib.pyplot as plt
> from scipy.fft import rfft
> from scipy.fft import irfft
>
> amplituda = 200
> width = 20
> CHUNK = 1024
> x1 = np.arange(CHUNK)
> x2 = np.arange(CHUNK//2)
> y = []
> for i in range(len(x1)):
>     y.append(np.sin(x1[i]/width)*amplituda)
>
> fig = plt.figure()
> ax1 = fig.add_subplot(2,2,1)
> ax3 = fig.add_subplot(2,2,2)
> ax2 = fig.add_subplot(2,2,3)
> ax4 = fig.add_subplot(2,2,4)
>
> # RFFT
> y_rfft = rfft(y)
>
> # IRFFT without abs
> y_irfft = irfft(y_rfft)
>
> # IRFFT with abs
> y_irfft_abs = irfft(np.abs(y_rfft))
>
> a = ax1.plot(x1, y, color='green')
> a = ax2.plot(x2, y_rfft[1:513], color='green')
> a = ax3.plot(x1, y_irfft, color='green')
> a = ax4.plot(x1, y_irfft_abs, color='green')
>
> a = ax1.set_title('Raw signal', fontsize = 8)
> a = ax2.set_title('Spectrum (rfft)', fontsize = 8)
> a = ax3.set_title('(irfft) without abs', fontsize = 8)
> a = ax4.set_title('(irfft) with abs "np.abs(y_rfft)"', fontsize = 8)
>
> a = plt.show()
>
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion@python.org
> https://mail.python.org/mailman/listinfo/numpy-discussion



-- 
Quantitative researcher, Ph.D.
Blog: http://blog.audio-tk.com/
LinkedIn: http://www.linkedin.com/in/matthieubrucher
_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@python.org
https://mail.python.org/mailman/listinfo/numpy-discussion

Reply via email to