如何在循环中使用 EnvGen,使其不会在循环的每次迭代中重新启动?
我需要它:分段合成。我想要例如第一个和第二个巴生之间 50 毫秒的 xfade,然后是第二个和第三个巴生之间的 50 毫秒 xfade,然后是第三个和第四个巴生之间的 50 毫秒 xfade,依此类推,我希望这个串联作为一个整体被一个包络调制.
不幸的是,EnvGen 似乎在播放连续巴生对的循环的每次迭代中都从头开始重新启动。我想要一个poiiiiinnnnnnnnnng,但无论我尝试什么,我得到的都是popopopopopopopopopo。
2019年编辑:
好的,既然没有人会回答“如何实现目标”的问题,我现在将这个问题降级为“为什么这种特殊方法不起作用”,也改变了标题。
在我粘贴一些代码之前,先解释一下:这是一个非常简化的示例。虽然我最初的愿望是使用包络调制复杂的分段生成的声音,但这个简化的示例仅从 SinOsc 的输出中“剪裁”了 100ms 段,只是为了人为地创建“分段生成”情况。
在这个程序中发生的情况是,EnvGen 似乎在每次循环迭代时重新启动:包络从 t=0 重新开始。我希望得到一个 1 秒长的呈指数衰减的声音,就像拨弦一样。由于信封在每次循环迭代开始时重新启动,我得到的是一系列 100 毫秒的“ping”。
我该如何防止这种情况发生?
这是代码:
//Exponential decay over 1 second
var envelope = {EnvGen.kr(Env.new([1,0.001],[1],curve: 'exp'), timeScale: 1, doneAction: 2)};
var myTask = Task({
//A simple tone
var oscillator = {SinOsc.ar(880,0,1);};
var scissor;
//Prepare a scissor that will cut 100ms of the oscillator signal
scissor = {EnvGen.kr(Env.new([1,0],[1],'hold'),timeScale: 0.1)};
10.do({
var scissored,modulated;
//Cut the signal with the scisor
scissored = oscillator*scissor;
//Try modulating with the envelope. The goal is to get a single 1s exponentially decaying ping.
modulated = {scissored*envelope};
//NASTY SURPRISE: envelope seems to restart here every iteration!!!
//How do I prevent this and allow the envelope to live its whole
//one-second life while the loop and the Task dance around it in 100ms steps?
modulated.play;
0.1.wait;
});
});
myTask.play;
(这个问题,我最初挣扎了几个月但没有成功,实际上导致我把学习 SuperCollider 的努力搁置了两年,现在我要从上次中断的地方继续。)