import os import thinkdsp from winsound import PlaySound import matplotlib.pyplot as plt from thinkdsp import decorate from thinkdsp import SquareSignal def play(file, flags): print('Now play ' + file) PlaySound(file, flags) print('end') square = SquareSignal(1500).make_wave(duration=0.5, framerate=10000) square.make_spectrum().plot() decorate(xlabel='Frequency (Hz)') square.make_audio() square.write("方波声音.wav") play("方波声音.wav", flags=1) plt.show()
from thinkdsp import decorate from thinkdsp import Sinusoid from thinkdsp import normalize, unbias import numpy as np import matplotlib.pyplot as plt from thinkdsp import SquareSignal from thinkdsp import TriangleSignal from thinkdsp import read_wave square = SquareSignal(1100).make_wave(duration=0.5, framerate=10000) square.make_spectrum().plot() decorate(xlabel='Frequency (Hz)') square.write(filename="2.3.wav") plt.show()
from thinkdsp import Sinusoid from thinkdsp import normalize, unbias from thinkdsp import TriangleSignal from thinkdsp import decorate from thinkdsp import SquareSignal import os import numpy as np import matplotlib.pyplot as plt #方波频率1100HZ 采样10000HZ 波长0.5秒 square = SquareSignal(1100).make_wave(duration=0.5, framerate=10000) square.write(filename='output2-3.wav') #显示中文 plt.rcParams['font.sans-serif'] = ['SimHei'] plt.rcParams['axes.unicode_minus'] = False square.make_spectrum().plot() plt.ylabel('幅度(方波频谱)') plt.xlabel('频率(HZ)') plt.show()
from thinkdsp import Sinusoid from thinkdsp import normalize,unbias from thinkdsp import SquareSignal from thinkdsp import TriangleSignal from thinkdsp import decorate import matplotlib.pyplot as plt import numpy as np square=SquareSignal(1100).make_wave(duration=0.5,framerate=10000) square.make_audio() square.write(filename='Square.wav') square.make_spectrum().plot() decorate(xlabel='Frequency (Hz)') plt.show()