Minim core
ugens
analysis
Name Summer
Description A Summer allows you to sum the outputs of multiple UGens to be sent further down the chain. Unlike most UGen effects, you can patch more than one UGen to a Summer.
Examples
/**
  * This sketch demonstrates how to patch more than one UGen
  * to a Summer. It works just like patching any other two 
  * UGens together, the difference being that a Summer 
  * can have more than one UGen patched to it and will 
  * output the sum of all signals, whereas most other UGens
  * allow only one input.
  * 
  * For many more examples of UGens included with Minim, 
  * have a look in the Synthesis folder of the Minim examples.
  * <p>
  * For more information about Minim and additional features, 
  * visit http://code.compartmental.net/minim/
  */

import ddf.minim.*;
import ddf.minim.ugens.*;

Minim       minim;
AudioOutput out;

void setup()
{
  size(512, 200, P3D);
  
  minim = new Minim(this);
  
  // use the getLineOut method of the Minim object to get an AudioOutput object
  out = minim.getLineOut();
  
  Summer sum = new Summer();
  
  // create some Oscils to patch to the Summer
  Oscil wave = new Oscil( Frequency.ofPitch("A4"), 0.3f, Waves.SINE );
  // patch the Oscil to the Summer
  wave.patch( sum );
  
  wave = new Oscil( Frequency.ofPitch("C#5"), 0.3f, Waves.SINE );
  wave.patch( sum );
  
  wave = new Oscil( Frequency.ofPitch("E5"), 0.3f, Waves.SINE );
  wave.patch( sum );
  
  // and the Summer to the output and you should hear a major chord
  sum.patch( out );
}

void draw()
{
  background(0);
  stroke(255);
  strokeWeight(1);
  
  // draw the waveform of the output
  for(int i = 0; i < out.bufferSize() - 1; i++)
  {
    line( i, 50  - out.left.get(i)*50,  i+1, 50  - out.left.get(i+1)*50 );
    line( i, 150 - out.right.get(i)*50, i+1, 150 - out.right.get(i+1)*50 );
  }
}
Constructors
Summer();
Methods
channelCount ( )   Returns the number of channels this UGen has been configured to generate.

generate ( )   Generates a buffer of samples by ticking this UGen mono.length times. Like the tick method, this will result in all of the

getLastValues ( )   Return the last values generated by this UGen. This will most often be used by sub-classes when pulling data from their inputs.

patch ( )   Send the output of this UGen to another UGen, UGenInput, or AudioOutput.

printInputs ( )   Prints all inputs connected to this UGen (for debugging)

sampleRate ( )   Returns the sample rate of this UGen.

setChannelCount ( )   Let this UGen know how many channels of audio you will be asking it for.

setSampleRate ( )   Set the sample rate for this UGen.

tick ( )   Generates one sample frame for this UGen.

unpatch ( )   Unpatch this UGen from an AudioOutput or other UGen.

Usage Web & Application
Related