python - 我需要转换成波形文件

标签 python audio

这是我的工作。

import matplotlib.pyplot as plot
import numpy as num

def xr(start, stop, step):
    while start < stop:
        yield start
        start = start + step

wavef = lambda x: num.sin(x)/x

t0 = [wavef(x) for x in xr(5.0,200.0,0.1) if x is not 0]

plot.plot(t0)
plot.show()

最佳答案

Python 有一个 模块 wave — Read and write WAV files .

这里给出了如何使用它将函数数据写入 wav 文件的示例,
Create a synthetic 'sine wave' wave fileHow to make a simple .wav file with Python .

您也可以使用 Audiolab .

由于您已经在使用 numpy,您可以使用 numpy.linspacenumpy.arange而不是你的 xr 函数。就像是,

x = num.arange( 5.0, 200.0, 0.1 )
wavef = num.sin(x)/x

关于python - 我需要转换成波形文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6556192/

相关文章:

javascript - 如何使用 Socket.io 实时传输音频?

javascript - Android 播放一次音频

audio - Pydub 混合 2 种不同能量级别的声音

python - 在 powershell 中使用 Tee-Object 时如何保留颜色?

python - Pandas :将数据框插入其他数据框而不保留索引

python - 如何将fig保存为matplotlib.pyplot中的显示?

python - 回归:如何逼近多维函数?

actionscript-3 - 每次播放器达到新水平时,as3都会添加声音

ios - iOS 中可以进行实时音频处理吗?

python - 排序双向链表 Python