-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathb_edit1.py
59 lines (33 loc) · 923 Bytes
/
b_edit1.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
from scipy.io import wavfile
#from scipy.fft import fft
import matplotlib.pyplot as plt
import numpy as np
path=input("Enter directory : ")
l=[]
def fft_plot(Input):
fs, data= wavfile.read(Input)
print(fs, data)
a= data.T
b= [(ele/2**16.)*2-1 for ele in a ]
c=np.fft.fft(b)
d= len(c)//2
return c,d
for i in range(2):
plt.subplot(2, 1,1)
plt.legend(bbox_to_anchor=(0., 1.02, 1., .102), loc=3, borderaxespad=0.)
Input_file= "./"+ path+"/file"+str(i)+".wav"
A, B= fft_plot(Input_file)
plt.plot(A , label='test'+str(i))
plt.title('Fourier Tranform')
plt.ylabel('Frequencies together')
l.append(A)
plt.plot(abs(A[:(B-1)]))
print(l)
plt.subplot(2, 1,2)
l2=np.append(l[0], [0]*9727)
#print(len(l[0]) , len(l2), len(l[1]))
plt.plot(l2-l[1][:(B-1)], 'g')
plt.plot()
plt.xlabel('time')
plt.ylabel('Seperated')
plt.show()