简体   繁体   English

有没有办法将多个频率写入 .wav 文件?

[英]Is there a way to write multiple frequencies to a .wav file?

I have an array of numbers我有一个数字数组

a = [440, 320, 650] a = [440, 320, 650]

I am trying to write a.wav file that writes those frequencies in order.我正在尝试编写一个按顺序写入这些频率的.wav 文件。 But I don't know if scipy.io.wavfile is able to write an array of frequencies to a wav file.但我不知道 scipy.io.wavfile 是否能够将频率数组写入 wav 文件。 All I can do right now is something like我现在能做的就是

wavfile.write('Sine.wav', rate, a[0]) wavfile.write('Sine.wav', rate, a[0])

I am thinking to do something like this though.我正在考虑做这样的事情。

for x in range(0, len(a)): #wavfile.addFrequency('Sine.wav', rate, a[x])对于范围内的 x (0, len(a)): #wavfile.addFrequency('Sine.wav', rate, a[x])

"In order" doesn't sound very clear to me. “按顺序”对我来说听起来不是很清楚。 I guess you would like to mix those sine waves.我猜你想混合那些正弦波。 For that you must make a single wave with the 3 sines by summation of their amplitude values.为此,您必须通过对它们的幅度值求和来制作具有 3 个正弦波的单个波。 For each sample, three values must be added (one for each sine) taking care that the result never overflows -1.0 or 1.0 (for float values, for 16 bit integers the range would be -32768 to 32767 instead).对于每个样本,必须添加三个值(每个正弦值一个),注意结果永远不会溢出 -1.0 或 1.0(对于浮点值,对于 16 位整数,范围将是 -32768 到 32767)。

Now if you plane to render the three waves successively instead, you have to determine the duration of each segment and take care that the junction between two waves is done at amplitude zero to prevent numeric clicks.现在,如果您打算连续渲染三个波,则必须确定每个段的持续时间,并注意两个波之间的连接处以零幅度完成,以防止数字点击。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM