Example #1
0
plt.subplot(3,3,2)
wave1.plot(color='blue')
plt.title('三角波变换前')
plt.subplot(3,3,3)
spectrum1.make_wave().plot(color='blue')
plt.title("三角波变换后")

wave2=SquareSignal(freq=440).make_wave(duration=0.5)
spectrum2 = wave2.make_spectrum()
filter_spectrum(spectrum2)
spectrum2.scale(440)
plt.subplot(3,3,4)
spectrum2.plot(high=10000, color='red')
plt.title("方波")
plt.subplot(3,3,5)
wave2.plot(color='red')
plt.title('方波变换前')
plt.subplot(3,3,6)
spectrum2.make_wave().plot(color='red')
plt.title("方变换后")
spectrum1.make_wave.write(filename='output2-3.wav')


wave3=SawtoothSignal(freq=440).make_wave(duration=0.5)
spectrum3 = wave3.make_spectrum()
filter_spectrum(spectrum3)
spectrum3.scale(440)
plt.subplot(3,3,7)
spectrum3.plot(high=10000, color='green')
plt.title("方波")
plt.subplot(3,3,8)
Example #2
0
    print('Now play ' + file)
    PlaySound(file, flags)
    print('end')


trangle = TriangleSignal(freq=440).make_wave(duration=0.01, framerate=10000)
plt.subplot(231)
plt.title("trangle")

trangle.plot()
trangle.write("三角波声音.wav")
play("三角波声音.wav", flags=1)
square = SquareSignal(freq=440).make_wave(duration=0.01, framerate=10000)
plt.subplot(232)
plt.title("square")
square.plot()
square.write("方波声音.wav")
play("方波声音.wav", flags=1)
sawtooth = SawtoothSignal(freq=440).make_wave(duration=0.01, framerate=10000)
plt.subplot(233)
plt.title("sawtooth")
sawtooth.plot()
sawtooth.write("斜波声音.wav")
play("斜波声音.wav", flags=1)

spectrum_tra = trangle.make_spectrum()
filter_spectrum(spectrum_tra)
plt.subplot(234)
spectrum_tra.plot()

spectrum_squ = square.make_spectrum()