Minim core
ugens
analysis
Name LiveInput
Description LiveInput is a way to wrap an input stream with the UGen interface so that you can easily route incoming audio through a UGen graph. You can get an AudioStream that is reading audio input from Minim by calling Minim.getInputStream.
Examples
/* liveInputExample<br/>
   is an example of using the LiveInput UGen to patch 
   the audio input from your computer (usually the microphone) to the output.
   <p>
   For more information about Minim and additional features, 
   visit http://code.compartmental.net/minim/
   <p>
   author: Damien Di Fede
*/

import ddf.minim.*;
import ddf.minim.ugens.*;
import ddf.minim.spi.*; // for AudioStream

Minim minim;
AudioOutput out;
LiveInput in;

void setup()
{
  // initialize the drawing window
  size(512, 200);
  
  // initialize the minim and out objects
  minim = new Minim(this);
  out = minim.getLineOut();
  
  // we ask for an input with the same audio properties as the output.
  AudioStream inputStream = minim.getInputStream( out.getFormat().getChannels(), 
                                                  out.bufferSize(), 
                                                  out.sampleRate(), 
                                                  out.getFormat().getSampleSizeInBits());
                                                 
  // construct a LiveInput by giving it an InputStream from minim.                                                  
  in = new LiveInput( inputStream );
  
  // create granulate UGen so we can hear the input being modfied before it goes to the output
  GranulateSteady grain = new GranulateSteady();
  
  // patch the input through the grain effect to the output
  in.patch(grain).patch(out);
}

// draw is run many times
void draw()
{
  // erase the window to black
  background( 0 );
  // draw using a white stroke
  stroke( 255 );
  // draw the waveforms
  for( int i = 0; i < out.bufferSize() - 1; i++ )
  {
    // find the x position of each buffer value
    float x1  =  map( i, 0, out.bufferSize(), 0, width );
    float x2  =  map( i+1, 0, out.bufferSize(), 0, width );
    // draw a line from one buffer position to the next for both channels
    line( x1, 50 + out.left.get(i)*50, x2, 50 + out.left.get(i+1)*50);
    line( x1, 150 + out.right.get(i)*50, x2, 150 + out.right.get(i+1)*50);
  }  
}
Constructors
LiveInput(inputStream);
Parameters
inputStream   AudioStream: the audio stream this LiveInput will read from
Methods
channelCount ( )   Returns the number of channels this UGen has been configured to generate.

close ( )   Calling close will close the AudioStream that this wraps, which is proper cleanup for using the stream.

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 UGen
Minim