File: plot.py

package info (click to toggle)
asahi-audio 3.4-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 3,148 kB
  • sloc: makefile: 43; python: 27
file content (31 lines) | stat: -rw-r--r-- 617 bytes parent folder | download | duplicates (3)
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
import sys, numpy, scipy
from scipy import signal
import matplotlib.scale as scale
import matplotlib.pyplot as plt

rate, data = scipy.io.wavfile.read(sys.argv[1])

w, h = signal.freqz(data, worN=65536)

w *= rate / (2 * numpy.pi)

fig, ax1 = plt.subplots(figsize=(10,8))

ax1.plot(w, 20 * numpy.log10(abs(h)), 'b')

plt.ylabel('Amplitude [dB]', color='b')
plt.xlabel('Frequency [Hz]')

ax1.grid()
ax1.set_xscale('log')
plt.xlim([20, 20000])

#ax1.xlim([25, 50])

ax2 = ax1.twinx()
angles = numpy.unwrap(numpy.angle(h))
ax2.plot(w, angles, 'g')
plt.ylabel('Angle (radians)', color='g')
#plt.axis('tight')
plt.show()