24 lines
531 B
Python
24 lines
531 B
Python
import soundbox
|
|
import numpy as np
|
|
import matplotlib
|
|
import matplotlib.pyplot as plt
|
|
|
|
signal = soundbox.load_signal('out.wav')
|
|
freqs = np.fft.fft(signal)
|
|
scale = soundbox.samp_rate / len(signal)
|
|
|
|
fig, ax = plt.subplots()
|
|
ax.plot(np.absolute(freqs))
|
|
|
|
|
|
def freq_format(value, pos):
|
|
return f'{value * scale:.0f} Hz'
|
|
|
|
|
|
ax.set_xlabel('Fréquence')
|
|
ax.set_xlim(0 / scale, 800 / scale)
|
|
ax.xaxis.set_major_formatter(matplotlib.ticker.FuncFormatter(freq_format))
|
|
ax.xaxis.set_major_locator(plt.MultipleLocator(100 / scale))
|
|
|
|
plt.show()
|