0

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

我可以通过 aSfPlayer和 a来实现这一点TrigFunc,但我的印象是每次切换声音时这都会从磁盘读取声音文件。有没有办法我可以通过将声音保存在 RAM 中的SndTable来实现这一点?

这是使用SfPlayerand的解决方案TrigFunc使用此示例作为灵感

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()
4

1 回答 1

0

要从 RAM 中按顺序播放声音文件,我只需要调用appendSndTable如下所示:

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()

使用声音文件列表不起作用;它只是重复播放第一个声音。

于 2016-12-30T21:26:31.583 回答