互加谐波ipython

2024-05-14 15:57:44 发布

您现在位置:Python中文网/ 问答频道 /正文

我想听到的下一个声音是所有以前的谐波同时播放的组合,但我不能让它工作。对ipython来说还是个新手,所以还在学习如何使用它。你知道吗

t = arange(0, 0.5, 1/44100)
fundamental = 440
mySound = sin(2*pi*t*100)
for k in range(1,6) :
    print "Adding harmonic: ", k 
    mySound = concatenate([mySound,  (mySound+(sin(2*pi*((2*k)-1)*t*100)/((2*k)-1)))/k])
play(mySound)
plot(mySound[1:1000]) # plot first 1000 samples

Tags: in声音forplotipythonpirangesin
1条回答
网友
1楼 · 发布于 2024-05-14 15:57:44

您需要使用加法,而不是串联。也就是说,类似于:

for k in range(1,6) :
    print "Adding harmonic: ", k 
    mySound += sin(2*pi*((2*k)-1)*t*100)/((2*k)-1)))/k
    # or mySound = mySound + sin(2*pi*((2*k)-1)*t*100)/((2*k)-1)))/k  # is close to the same thing (though less efficient) and more similar to what you had

串联将把波形端到端,所以你会听到他们一个接一个,顺序。你知道吗

相关问题 更多 >

    热门问题