2016-12-30 6 views
0

私は、連続して再生したいのと同じ長さの2つのサウンドファイルを持っています。具体的には、最初のファイルを3回再生し、2番目のファイルを1回再生します。Pyo - RAMから2つのサウンドファイルを連続して再生する方法は?

SfPlayerTrigFuncでこれを達成できますが、音を切り替えるたびにディスクからサウンドファイルが読み込まれるという印象があります。 SndTablewhich holds the sounds in RAMでこれを達成できる方法はありますか?

ここでは、SfPlayerTrigFunc,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() 

答えて

0

私はちょうどこのように、SndTableappendを呼び出すために必要な、RAMから順次サウンドファイルを再生するには:サウンドファイルのリストを使用して

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

は動作しませんでした。ちょうど最初のサウンドを繰り返し再生しました。

関連する問題