Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/276.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Pyo-如何播放从RAM中顺序读取的两个声音文件?_Python_Pyo - Fatal编程技术网

Python Pyo-如何播放从RAM中顺序读取的两个声音文件?

Python Pyo-如何播放从RAM中顺序读取的两个声音文件?,python,pyo,Python,Pyo,我有两个相同长度的声音文件,我想按顺序播放。具体来说,我希望第一个文件播放三次,第二个文件播放一次 我可以通过SfPlayer和TrigFunc来实现这一点,但我的印象是,每次切换声音时,它都会从磁盘读取声音文件。有没有办法通过SndTable来实现这一点 下面是使用SfPlayer和TrigFunc的解决方案 要按顺序从RAM播放声音文件,我只需要在SndTable上调用append,如下所示: from pyo import * s = Server().boot() DOWNLOADS =

我有两个相同长度的声音文件,我想按顺序播放。具体来说,我希望第一个文件播放三次,第二个文件播放一次

我可以通过
SfPlayer
TrigFunc
来实现这一点,但我的印象是,每次切换声音时,它都会从磁盘读取声音文件。有没有办法通过
SndTable
来实现这一点

下面是使用
SfPlayer
TrigFunc
的解决方案


要按顺序从RAM播放声音文件,我只需要在
SndTable
上调用
append
,如下所示:

from pyo import *
s = Server().boot()
DOWNLOADS = 'C:\\Users\\mmoisen\\Downloads\\'
first = DOWNLOADS + 'first.wav'
second = DOWNLOADS + 'second.wav'

# Using an array like this didn't work; it just played the first clip
# t = SndTable([first,first,first,second])
t = SndTable(first)
t.append(first)
t.append(first)
t.append(second)
a = Osc(table=t, freq=t.getRate(), mul=.4).out()

s.start()
使用声音文件列表不起作用;它只是重复播放第一个声音

from pyo import *
s = Server().boot()
DOWNLOADS = 'C:\\Users\\mmoisen\\Downloads\\'
first = DOWNLOADS + 'first.wav'
second = DOWNLOADS + 'second.wav'

# Using an array like this didn't work; it just played the first clip
# t = SndTable([first,first,first,second])
t = SndTable(first)
t.append(first)
t.append(first)
t.append(second)
a = Osc(table=t, freq=t.getRate(), mul=.4).out()

s.start()