Minim core | ugens | analysis |
AudioOutput Fields left mix right Methods addListener ( ) bufferSize ( ) getBalance ( ) getDurationFactor ( ) getFormat ( ) getGain ( ) getNoteOffset ( ) getPan ( ) getTempo ( ) getVolume ( ) isMuted ( ) mute ( ) pauseNotes ( ) playNote ( ) removeListener ( ) resumeNotes ( ) sampleRate ( ) setBalance ( ) setDurationFactor ( ) setGain ( ) setNoteOffset ( ) setPan ( ) setTempo ( ) setVolume ( ) shiftBalance ( ) shiftGain ( ) shiftPan ( ) shiftVolume ( ) type ( ) unmute ( ) | An AudioOutput is a connection to the output of a computer's sound card. Typically the computer speakers are connected to this. You can use an AudioOutput to do real-time sound synthesis by patching UGens to an output object. You can get an AudioOutput object from Minim using one of five methods:
     AudioOutput getLineOut()

     // specifiy either Minim.MONO or Minim.STEREO for type
     AudioOutput getLineOut(int type)

     // bufferSize is the size of the left, right,
     // and mix buffers of the output you get back
     AudioOutput getLineOut(int type, int bufferSize)

     // sampleRate is a request for an output of a certain sample rate
     AudioOutput getLineOut(int type, int bufferSize, float sampleRate)

     // bitDepth is a request for an output with a certain bit depth
     AudioInput getLineOut(int type, int bufferSize, float sampleRate, int bitDepth)
In the event that an output doesn't exist with the requested parameters, Minim will spit out an error and return null. In general, you will want to use one of the first two methods listed above. In addition to directly patching UGens to the output, you can also schedule "notes" to be played by the output at some time in the future. This can be very powerful when writing algorithmic music and sound. See the playNote method for more information. Constructors
Related Minim UGen playNote ( ) Example
    /**
      * This sketch demonstrates how to create synthesized sound with Minim
      * using an AudioOutput and an Oscil. An Oscil is a UGen object,
      * one of many different types included with Minim. By using
      * the numbers 1 thru 5, you can change the waveform being used
      * by the Oscil to make sound. These basic waveforms are the
      * basis of much audio synthesis.
      *
      * 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;
    Oscil       wave;

    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();

      // create a sine wave Oscil, set to 440 Hz, at 0.5 amplitude
      wave = new Oscil( 440, 0.5f, Waves.SINE );
      // patch the Oscil to the output
      wave.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 );
      }

      // draw the waveform we are using in the oscillator
      stroke( 128, 0, 0 );
      strokeWeight(4);
      for( int i = 0; i < width-1; ++i )
      {
        point( i, height/2 - (height*0.49) * wave.getWaveform().value( (float)i / width ) );
      }
    }

    void mouseMoved()
    {
      // usually when setting the amplitude and frequency of an Oscil
      // you will want to patch something to the amplitude and frequency inputs
      // but this is a quick and easy way to turn the screen into
      // an x-y control for them.

      float amp = map( mouseY, 0, height, 1, 0 );
      wave.setAmplitude( amp );

      float freq = map( mouseX, 0, width, 110, 880 );
      wave.setFrequency( freq );
    }

    void keyPressed()
    {
      switch( key )
      {
        case '1':
          wave.setWaveform( Waves.SINE );
          break;

        case '2':
          wave.setWaveform( Waves.TRIANGLE );
          break;

        case '3':
          wave.setWaveform( Waves.SAW );
          break;

        case '4':
          wave.setWaveform( Waves.SQUARE );
          break;

        case '5':
          wave.setWaveform( Waves.QUARTERPULSE );
          break;

        default: break;
      }
    }
Usage Web & Application