ddf.minim.ugens
Class Bypass<T extends UGen>

java.lang.Object
  extended by ddf.minim.ugens.UGen
      extended by ddf.minim.ugens.Bypass<T>
Type Parameters:
T - The type of UGen being wrapped, like GranulateSteady.

public class Bypass<T extends UGen>
extends UGen

The Bypass UGen allows you to wrap another UGen and then insert that UGen into your signal chain using Bypass in its place. You can then dynamically route the audio through the wrapped UGen or simply allow incoming audio to pass through unaffected. Using a Bypass UGen allows you to avoid concurrency issues caused by patching and unpatching during runtime from a Thread other than the audio one.

Your usage of Bypass might look something like this:

 Bypass granulate = new Bypass( new GranulateSteady() );
 filePlayer.patch( granulate ).patch( mainOut );
 

If you needed to patch something else to one of the inputs of the GranulateSteady, you'd use the ugen method of Bypass to retrieve the wrapped UGen and operate on it:

 grainLenLine.patch( granulate.ugen().grainLen );
 

Now, calling the activate method will bypass the granulate effect so that the Bypass object outputs the audio that is coming into it. Calling the deactivate method will route the audio through the wrapped effect. The isActive method indicates whether or not the wrapped effect is currently being bypassed.

Author:
Damien Di Fede

Nested Class Summary
 
Nested classes/interfaces inherited from class ddf.minim.ugens.UGen
UGen.InputType, UGen.UGenInput
 
Constructor Summary
Bypass(T ugen)
          Construct a Bypass UGen that wraps a UGen of type T.
 
Method Summary
 void activate()
          Activate the bypass functionality.
protected  void addInput(UGen input)
          If you want to do something other than the default behavior when your UGen is patched to, you can override this method in your derived class.
 void deactivate()
          Deactivate the bypass functionality.
 boolean isActive()
           
protected  void removeInput(UGen input)
          If you need to do something specific when something is unpatched from your UGen, you can override this method.
protected  void sampleRateChanged()
          Override this method in your derived class to receive a notification when the sample rate of your UGen has changed.
 void setAudioChannelCount(int channelCount)
          Let this UGen know how many channels of audio you will be asking it for.
 T ugen()
           
protected  void uGenerate(float[] channels)
          Implement this method when you extend UGen.
 
Methods inherited from class ddf.minim.ugens.UGen
getLastValues, patch, patch, patch, printInputs, sampleRate, setSampleRate, tick, unpatch, unpatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bypass

public Bypass(T ugen)
Construct a Bypass UGen that wraps a UGen of type T.

Parameters:
ugen -
Method Detail

ugen

public T ugen()
Returns:
the wrapped UGen, cast to the class this Bypass was constructed with.

sampleRateChanged

protected void sampleRateChanged()
Description copied from class: UGen
Override this method in your derived class to receive a notification when the sample rate of your UGen has changed. You might need to do this to recalculate sample rate dependent values, such as the step size for an oscillator.

Overrides:
sampleRateChanged in class UGen

addInput

protected void addInput(UGen input)
Description copied from class: UGen
If you want to do something other than the default behavior when your UGen is patched to, you can override this method in your derived class. Summer, for instance, keeps a list of all the UGens that have been patched to it, so that it can tick them and sum the results when it uGenerates.

Overrides:
addInput in class UGen

removeInput

protected void removeInput(UGen input)
Description copied from class: UGen
If you need to do something specific when something is unpatched from your UGen, you can override this method.

Overrides:
removeInput in class UGen

setAudioChannelCount

public void setAudioChannelCount(int channelCount)
Description copied from class: UGen
Let this UGen know how many channels of audio you will be asking it for. This will be called automatically when a UGen is patched to an AudioOuput and propagated to all UGenInputs of type AUDIO.

Overrides:
setAudioChannelCount in class UGen
Parameters:
channelCount - how many channels of audio you will be generating with this UGen

activate

public void activate()
Activate the bypass functionality. In other words, the wrapped UGen will NOT have an effect on the UGen patched to this Bypass.


deactivate

public void deactivate()
Deactivate the bypass functionality. In other words, the wrapped UGen WILL have an effect on the UGen patched to this Bypass, as if it was in the signal chain in place of this Bypass.


isActive

public boolean isActive()
Returns:
true if the bypass functionality is on.

uGenerate

protected void uGenerate(float[] channels)
Description copied from class: UGen
Implement this method when you extend UGen. It will be called when your UGen needs to generate one sample frame of audio. It is expected that you will assign values to the array and not simply modify the existing values. In the case where you write a UGen that takes audio input and modifies it, the pattern to follow is to have the first UGenInput you create be your audio input and then in uGenerate you will use the getLastValues method of your audio UGenInput to retrieve the audio you want to modify, which you will then modify however you need to, assigning the result to the values in channels.

Specified by:
uGenerate in class UGen
Parameters:
channels - an array representing one sample frame.