首页 > 其他 > 详细

数字信号处理(playthattune.py)

时间:2017-08-04 01:05:40      阅读:367      评论:0      收藏:0      [点我收藏+]
 1 import stdarray
 2 import math
 3 import stddraw
 4 import stdaudio
 5 import stdio
 6 SPS = 44100
 7 CONCERT_A = 440.0
 8 while not stdio.isEmpty():
 9     pitch = stdio.readInt()
10     duration = stdio.readFloat()
11     hz = CONCERT_A * (2 ** (pitch/12.0))
12     n = int(SPS * duration)
13     samples = stdarray.create1D(n+1, 0.0)
14     for i in range(n+1):
15         samples[i] = math.sin(2.0 * math.pi * i * hz / SPS)
16     stdaudio.playSamples(samples)
17 stdaudio.wait()

 

数字信号处理(playthattune.py)

原文:http://www.cnblogs.com/cdf4745/p/7282749.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!