use of net.beadsproject.beads.events.KillTrigger in project narchy by automenta.
the class UGen method crossfadeInput.
/**
* Performs a crossfade from one UGen (which must already be connected) to another. Only works if you
*
* @param source the UGen to crossfade away from (assumed to already be connected), will be disconnected once cross-fade is over.
* @param destination the UGen to crossfade towards.
* @param crossoverTime the time taken.
*/
public synchronized void crossfadeInput(UGen source, final UGen destination, float crossoverTime) {
removeAllConnections(source);
// fade the old one out
Envelope fadeOut = new Envelope(context, 1f);
Gain gOut = new Gain(context, source.outs, fadeOut);
fadeOut.add(0f, crossoverTime, new KillTrigger(gOut));
gOut.in(source);
in(gOut);
// fade the new one in
Envelope fadeIn = new Envelope(context, 0f);
final Gain gIn = new Gain(context, destination.outs, fadeIn);
fadeIn.add(1f, crossoverTime, new Auvent() {
@Override
public void on(Auvent message) {
removeAllConnections(gIn);
in(destination);
}
});
gIn.in(source);
in(gIn);
}
Aggregations