来自Python中各种输入的实时声音合成器 [英] Realtime sound synthesizer from a varying input in Python
问题描述
我正在尝试制作一种踏板[¹],以使变化的输入声音失真.
从地面开始,我试图在python中产生连续的声音,并在滑动滚动条(或类似的小部件)时改变这种声音的频率.
我尝试使用tkSnack python库生成声音,但是它会在生成的音调之间暂停.除了这种行为,我希望我的脚本即使声音不断变化也可以连续播放声音.
我的arduino通过简单的函数tone()[²]获得了不错的结果.延迟时间可能太短,以至于声音似乎是连续的.可以在Linux上使用python库在我的计算机上做类似的事情吗?
感谢谁会帮助我! :)
[¹] http://en.wikipedia.org/wiki/Effects_pedal >
[²] http://arduino.cc/en/Reference/Tone >
你好,我去年使用此公式制作了踏板
M = 2*D/(1-D);
x = (1+M)*(x)./(1+k*abs(x));
X =输入信号
D =失真测试一些值,例如0.1、0.5、0.9等,然后查看结果.
这可以用于实时输入线+ python + pyaudio,声音看起来像一个Overdrive ...
更新:
用Python实时编写原始踏板失真
#ederwander
import pyaudio
import numpy as np
import wave
chunk = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 8800
K=0
DISTORTION = 0.61
p = pyaudio.PyAudio()
stream = p.open(format = FORMAT,
channels = CHANNELS,
rate = RATE,
input = True,
output = True,
frames_per_buffer = chunk)
print "Eng Eder de Souza - ederwander"
print "Primitive Pedal"
while(True):
data = stream.read(chunk)
data = np.fromstring(data, dtype=np.int16)
M = 2*DISTORTION/(1-DISTORTION);
data = (1+M)*(data)/(1+K*abs(data));
data = np.array(data, dtype='int16')
signal = wave.struct.pack("%dh"%(len(data)), *list(data))
stream.write(signal)
stream.stop_stream()
stream.close()
p.terminate()
更改变量失真"以查看不同的结果:
我稍微改变了我的音源来制作播放的录音样本,做了一些测试,得到了以下音频: http://www.freesound.org/people/eriatarka/sounds/15753/一个> 然后应用此处描述的公式,您可以在此处收听更改的文件: http://www.freesound.org/people/ederwander/sounds/146277/
I'm trying to build a sort of pedal [¹] in order to distort a varying input sound.
As I'm starting from the ground, I'm trying to generate in python a continuous sound and to vary the frequency of this sound as I slide a scrollbar (or a similar widget).
I've tried to use the tkSnack python library for the generation of the sound but it pauses between the generated tones. Instead of this behaviour, I want my script to play continuously the sound even if it is changing.
I've obtained a good result with my arduino thanks to the simple function tone() [²]. Probably the latency times are so low that the sound seems to be continuous. Is it possible to do a similar thing on my computer with python libraries on Linux?
Thanks to who is gonna help me! :)
[¹] http://en.wikipedia.org/wiki/Effects_pedal
[²] http://arduino.cc/en/Reference/Tone
Hello i used this formula last year to build a pedal
M = 2*D/(1-D);
x = (1+M)*(x)./(1+k*abs(x));
X = input Signal
D = distortion test some values like 0.1, 0.5, 0.9, etc and see the results.
This can be used in realtime inputline + python + pyaudio, the sound looks like one Overdrive ...
Update:
Real-Time primitive pedal distortion write in Python
#ederwander
import pyaudio
import numpy as np
import wave
chunk = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 8800
K=0
DISTORTION = 0.61
p = pyaudio.PyAudio()
stream = p.open(format = FORMAT,
channels = CHANNELS,
rate = RATE,
input = True,
output = True,
frames_per_buffer = chunk)
print "Eng Eder de Souza - ederwander"
print "Primitive Pedal"
while(True):
data = stream.read(chunk)
data = np.fromstring(data, dtype=np.int16)
M = 2*DISTORTION/(1-DISTORTION);
data = (1+M)*(data)/(1+K*abs(data));
data = np.array(data, dtype='int16')
signal = wave.struct.pack("%dh"%(len(data)), *list(data))
stream.write(signal)
stream.stop_stream()
stream.close()
p.terminate()
Change de Variable DISTORTION to see diferent results:
i changed a bit my source to make play recorded samples, i did Make some test, i get this audio: http://www.freesound.org/people/eriatarka/sounds/15753/ and then applied the formula described here, you can listen the changed file here: http://www.freesound.org/people/ederwander/sounds/146277/
这篇关于来自Python中各种输入的实时声音合成器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!