title: Loops & Volume increase for audio within processing
body: <p>I am a beginner to all of this. My aim is to create a processing file that when loaded will play a melody for 30 seconds. The melody should change several times through the sequence.</p>
  
  <p>I am looking to loop my <code>outplaynotes</code> for 30 seconds. Also is there a way to increase the volume of these notes?  I want to play audio samples on top of the playnotes but the samples are much louder then the playnotes. What is the best way to level them out, volume wise? </p>
  
  <pre><code>import ddf.minim.*;
  import ddf.minim.ugens.*;
  
  Minim minim;
  AudioOutput out;
  myDelay;
  
  void setup() {
      size(800, 300, P2D);
      minim = new Minim(this);
      out = minim.getLineOut();
      myDelay = new Delay(1.5,0.5, false,false);
  
      out.pauseNotes();
  
      out.setTempo(240);
  
      out.playNote( 0.00, 1.0, new ToneInstrument( 80, 0.5, out ) );
      out.playNote( 2.00, 0.5, new ToneInstrument( 100, 0.5, out ) );
      out.playNote( 3.00, 0.5, new ToneInstrument( 250, 0.5, out ) );
      out.playNote( 4.00, 1.0, new ToneInstrument( 90, 0.5, out ) );
      out.playNote( 5.00, 1.0, new ToneInstrument( 100, 0.5, out ) );
      out.playNote( 6.00, 0.5, new ToneInstrument( 120, 0.5, out ) );
      out.playNote( 7.00, 0.5, new ToneInstrument( 270, 0.5, out ) );
      out.playNote( 8.00, 1.0, new ToneInstrument( 110, 0.5, out ) );
      out.resumeNotes();
  }
  
  class ToneInstrument implements Instrument {
  
      Oscil       wave;
      Damp damp;
  
      ToneInstrument(float frequency, float amplitude, AudioOutput output) {
          out = output;
  
          wave = new Oscil(frequency, amplitude, Waves.TRIANGLE);
          damp = new Damp(0.0001, 1.5);
          wave.patch(damp);
          wave.patch(myDelay);
      }
  
      void noteOn(float dur) {
          damp.setDampTimeFromDuration(dur);
          damp.activate();
          damp.patch(out);
      }
  
      void noteOff() {
          damp.unpatchAfterDamp(out);
      }
  
  }
  
  void draw() {
  }
  </code></pre>