ddf.minim.ugens
Class WaveShaper

java.lang.Object
  extended by ddf.minim.ugens.UGen
      extended by ddf.minim.ugens.WaveShaper

public class WaveShaper
extends UGen

A UGen which provides waveshaping distortion. The incoming "audio" signal is used as an index to a Wavetable containing a "mapping" function and the output of the waveshaper is the value in the Wavetable given by the index. The incoming wave is expected to have values between -1 and 1 although exceeding this range can be used expressively. The input signal is then normalized so that -1 to 1 becomes 0 and 1 to provide the index value. The output waveshape is then multiplied by an output amplitude. A library of shapes is defined, that the user can call. The shapes are Wavetables, which can be used in a creative way (using waveforms from the Waves library for example).

Author:
Nicolas Brix, Anderson Mills

Nested Class Summary
 
Nested classes/interfaces inherited from class ddf.minim.ugens.UGen
UGen.InputType, UGen.UGenInput
 
Field Summary
 UGen.UGenInput audio
          The default input is "audio."
 UGen.UGenInput mapAmplitude
          The mapping amplitude of the input signal
 UGen.UGenInput outAmplitude
          The output amplitude
 
Constructor Summary
WaveShaper(float outAmp, float mapAmp, Wavetable mapShape)
          Constructor for WaveShaper.
WaveShaper(float outAmp, float mapAmp, Wavetable mapShape, boolean wrapMap)
          Constructor for WaveShaper.
 
Method Summary
protected  void uGenerate(float[] channels)
          Implement this method when you extend UGen.
 
Methods inherited from class ddf.minim.ugens.UGen
addInput, getLastValues, patch, patch, patch, printInputs, removeInput, sampleRate, sampleRateChanged, setSampleRate, tick, unpatch, unpatch
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

audio

public UGen.UGenInput audio
The default input is "audio."


outAmplitude

public UGen.UGenInput outAmplitude
The output amplitude


mapAmplitude

public UGen.UGenInput mapAmplitude
The mapping amplitude of the input signal

Constructor Detail

WaveShaper

public WaveShaper(float outAmp,
                  float mapAmp,
                  Wavetable mapShape)
Constructor for WaveShaper. mapWrap, a boolean flag to wrap the map around the ends instead of hitting the edge, defaults to false.

Parameters:
outAmp - the output amplitude multiplier of the shaped wave
mapAmp - amplitude over which to map the incoming signal
mapShape - waveshape over which to map the incoming signal

WaveShaper

public WaveShaper(float outAmp,
                  float mapAmp,
                  Wavetable mapShape,
                  boolean wrapMap)
Constructor for WaveShaper.

Parameters:
outAmp - the output amplitude multiplier of the shaped wave
mapAmp - amplitude over which to map the incoming signal
mapShape - waveshape over which to map the incoming signal
wrapMap - boolean flag to wrap the map instead of hit the edge and stick
Method Detail

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.