티스토리 뷰

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import numpy as np
import matplotlib.pyplot as plt
 
 
= 512
= 1.0 / 44100.0
f1 = 697
f2 = 1209
= np.linspace(0.0, N*T, N)
y1 = 1.1 * np.sin(2 * np.pi * f1 * t)
y2 = 0.9 * np.sin(2 * np.pi * f2 * t)
= y1 + y2
 
 
plt.subplot(311)
plt.plot(t, y1)
plt.title(r"$1.1\cdot\sin(2\pi\cdot 697t)$")
plt.subplot(312)
plt.plot(t, y2)
plt.title(r"$0.9\cdot\sin(2\pi\cdot 1209t)$")
plt.subplot(313)
plt.plot(t, y)
plt.title(r"$1.1\cdot\sin(2\pi\cdot 697t) + 0.9\cdot\sin(2\pi\cdot 1209t)$")
plt.tight_layout()
plt.show()
 
 
 
y2 = np.hstack([y,y,y])
plt.plot(y2)
plt.axvspan(N,N*2, alpha = 0.3, color = 'green')
plt.xlim(4003*- 400)
plt.show()
 
 
from scipy.fftpack import fft
 
yf = fft(y, N)
xf = np.linspace(0.01.0/(2.0*T), N//2)
 
plt.subplot(211)
plt.plot(y)
 
plt.subplot(212)
plt.stem(xf, 2.0/* np.abs(yf[0:N//2]))
plt.xticks(xf, rotation=40)
plt.xlim(01989)
 
plt.show()
 
 
 
import scipy as sp
from scipy import signal
 
f, P1 = sp.signal.periodogram(y, 44100, nfft=2**12)
f, P2 = sp.signal.welch(y, 44100, nfft=2**12)
 
plt.subplot(211)
plt.semilogy(f, P1)
plt.xlim(1001900)
plt.ylim(1e-8, 1e-1)
 
plt.subplot(212)
plt.semilogy(f, P2)
plt.xlim(1001900)
plt.ylim(1e-8, 1e-1)
 
plt.tight_layout()
plt.show()
 

 

 

import librosa

import librosa.display

 
 
= np.abs(librosa.stft(y))
librosa.display.specshow(librosa.amplitude_to_db(D, ref=np.max), y_axis='log', x_axis='time')
plt.title('Dual Tone')
plt.show()
 
y_octave, sr = librosa.load("octave.wav")
D_octave = np.abs(librosa.stft(y_octave))
librosa.display.specshow(librosa.amplitude_to_db(D_octave, ref=np.max), sr=sr, y_axis='log', x_axis='time')
plt.title('Octave')
plt.show()
 
S_octave = librosa.feature.melspectrogram(y=y_octave, sr=sr, n_mels=128)
librosa.display.specshow(librosa.power_to_db(S_octave, ref=np.max), sr=sr, y_axis='mel', x_axis='time')
plt.show()
 
cs
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
TAG more
«   2025/02   »
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
글 보관함