首页 > 解决方案 > 使用 Pyo Python 进行麦克风输入

问题描述

我目前正在使用 Python 和 pyo 创建一个小程序,它应该使用麦克风输入作为源,然后添加 pyo 提供的几个效果和过滤器。我在文档中找不到任何内容,有没有办法将麦克风输入用作源,是否有任何替代 pyo 的方法?

这是我到目前为止的基本示例:

from pyo import *

s = Server().boot()

s.start()

s.amp = 0.1

# use microphone input here
sf = Sig(1).out()

# Passes the sine wave through an harmonizer.
h1 = Harmonizer(sf).out()

s.gui(locals())

我知道有一个设置输入设备的功能,比如 s.setInputDevice(5),但我不知道如何实际使用它。

谢谢您的帮助!

标签: pythonpyo

解决方案


It looks like you aren't actually creating an input stream. Something like this (no gui) will output your microphone input:

from pyo import *                                                                                                                                                                                                                                                                                    
s = Server().boot() 
s.start()                                                                                                                                 
miccheck = Input().play().out()  

Or, to modify the harmonizer default example:

from pyo import *
s = Server().boot()

mic = Input().play().out()


env = WinTable(8)
wsize = .1
trans = -7

ratio = pow(2., trans/12.)
rate = -(ratio-1) / wsize

ind = Phasor(freq=rate, phase=[0,0.5])
win = Pointer(table=env, index=ind, mul=.7)
snd = Delay(mic, delay=ind*wsize, mul=win).mix(1).out(1)

s.gui(locals())

推荐阅读