我有两个相同长度的声音文件,我想按顺序播放。具体来说,我希望第一个文件播放三次,第二个文件播放一次。在
我可以通过SfPlayer
和TrigFunc
来实现这一点,但我的印象是,每次切换声音时,它都会从磁盘读取声音文件。我有没有办法通过SndTable
,which holds the sounds in RAM来实现这一点?在
下面是使用SfPlayer
和TrigFunc
,using this example as inspiration的解决方案。在
from pyo import *
s = Server().boot()
DOWNLOADS = 'C:\\Users\\mmoisen\\Downloads\\'
first = DOWNLOADS + 'first.wav'
second = DOWNLOADS + 'second.wav'
sf = SfPlayer(first, speed=100/135.0, loop=True, mul=0.5).out()
count = 0
def foo():
global count
count += 1
print count
if count == 3:
sf.path = second
if count == 4:
sf.path = forst
count = 0
trig = TrigFunc(sf['trig'][0], foo)
s.start()
要从RAM顺序播放声音文件,我只需要在
SndTable
上调用append
,如下所示:使用声音文件列表不起作用;它只是重复播放第一个声音。在
相关问题 更多 >
编程相关推荐