Creating an array of audio in beads.

edited July 2016 in Kinect

Hi, I'm trying to create an array of audios in beads so that they play independently when each SMT zone is touched. The problem I am having is how to initialize and link a different audio file to each zone.

The hope is to be able to use a kinect to play audio files independently within zones. Please let me know if you have any ideas on improving code, or how to use arrays to reduce the footwork of the code.

Thanks

    //Set for 6' height from ground 15'6" distance

    import vialab.SMT.*;

    import beads.*;

    //Array of Zones
    int arrayNum = 56;
    TouchtouchZone[] touchZone = new TouchtouchZone[arrayNum];
    boolean isEven;
    boolean isOdd;

    //Array of Sounds
    int soundsNum = 23;
    Sound[] sounds = new Sound[soundsNum];
    AudioContext ac;

    //Playback Variables
    int playDelay = 0;
    boolean canPlay = true;

    //Grid Line Variables 
    int x, y;
    float areaW, areaH;
    int num, num2;
    float spacing, spacing2;
    float xVal, yVal;

    //Aspect Ratio Variables
    Float aspectX, aspectY;
    int buttonSize;
    float edgeSpace;
    int gridStartX, gridStartY;

    //Setup Display INFO
    boolean window_fullscreen = false;
    int window_width = 1200;
    int window_height = 800;
    int window_halfWidth;
    int window_halfHeight;
    int fps_limit = 60;

    void setup() {

      //Display setup
      if ( window_fullscreen) {
        window_width = displayWidth;
        window_height = displayHeight;
      }
      window_halfWidth = window_width / 2;
      window_halfHeight = window_height / 2;
      //processing window setup
      frameRate( fps_limit);
      size( window_width, window_height, SMT.RENDERER);
      SMT.init( this, TouchSource.AUTOMATIC);

      //Audio Setup
      ac = new AudioContext(); 

      //Aspect Ratio Variables
      edgeSpace = 20.0;
      //  aspectX = 640.0;
      //  aspectY = 480.0;
      aspectX = (float)width;
      aspectY = (float)height - edgeSpace*2;

      //  THIS IS NOT PERFECT YET
      gridStartX = (int)(aspectX-aspectY)/2;
      gridStartY = (int)edgeSpace;

      //Grid Line Variables 
      //  X
      num = 8;
      areaW=aspectY;
      //  Y
      num2 = 7;
      areaH=aspectY;
      buttonSize = (int)(aspectY/num2);

      //  ARRAY MAKES BUTTONS IN CHECKERBOARD STYLE
      for (int i=0; i<arrayNum; i++) {
        if ((i<=7)&&(i % 2 == 0)) {
          x = gridStartX+(i*buttonSize);
          y = gridStartY;
        }
        if (((i>7)&&(i<=15))&&(i % 2 != 0)) {
          x = gridStartX+((i-8)*buttonSize);
          y = gridStartY+buttonSize;
        }
        if (((i>15)&&(i<=23))&&(i % 2 == 0)) {
          x = gridStartX+((i-16)*buttonSize);
          y = gridStartY+(2*buttonSize);
        }
        if (((i>23)&&(i<=31))&&(i % 2 != 0)) {
          x = gridStartX+((i-24)*buttonSize);
          y = gridStartY+(3*buttonSize);
        }
        if (((i>31)&&(i<=39))&&(i % 2 == 0)) {
          x = gridStartX+((i-32)*buttonSize);
          y = gridStartY+(4*buttonSize);
        }
        if (((i>39)&&(i<=47))&&(i % 2 != 0)) {
          x = gridStartX+((i-40)*buttonSize);
          y = gridStartY+(5*buttonSize);
        }
        if (((i>47)&&(i<=56))&&(i % 2 == 0)) {
          x = gridStartX+((i-48)*buttonSize);
          y = gridStartY+(6*buttonSize);
        }
        touchZone[i] = new TouchtouchZone(x, y, buttonSize, buttonSize, 100, 100, 150, 200);
        SMT.add(touchZone[i]);
      }

      //  ARRAY INITIALIZES AUDIO SETUP  
      for (int i=0; i<soundsNum; i++) {
        sounds[i] = new Sound(0, 0);
        sounds[i].audioSetup();
      }
      ac.start();
    }


    void draw() { 
      background(0);
      fill(30);

      spacing = buttonSize;

      //  fill(255);

      playDelay++;
      if (playDelay >= 15) {
        canPlay = true;
      } else {
        canPlay = false;
      }

      text("Play Delay: "+playDelay, width-100, height-20);

      //FOR GRID DEBUGGING
      //  rect(0, gridStartY, aspectX, aspectY);
      for (int m = 0; m < num; m++) {
        for (int n = 0; n < num2; n++) {
          stroke(125);
          strokeWeight(3);
          x = gridStartX+(m*buttonSize); 
          y = gridStartY+(n*buttonSize);
          rect(x, y, buttonSize, buttonSize);
        }
      }
    }

    public void drawFrameRate() {
      float fps = this.frameRate;
      String fps_text = String.format( "fps: %.0f", fps);
      pushStyle();
      fill( 240, 240, 240, 180);
      textAlign( RIGHT, TOP);
      textMode( MODEL);
      textSize( 32);
      text( fps_text, window_width - 10, 10);
      popStyle();
    }

    private class touchZone extends Zone {
      protected int colour_red;
      protected int colour_green;
      protected int colour_blue;
      protected int colour_alpha;
      public touchZone( int x, int y, int width, int height, 
      int colour_red, int colour_green, int colour_blue, int colour_alpha) {
        super( x, y, width, height);
        this.colour_red = colour_red;
        this.colour_green = colour_green;
        this.colour_blue = colour_blue;
        this.colour_alpha = colour_alpha;
        this.setCaptureTouches( false);
      }
      //draw method
      public void draw() {
        pushStyle();
        noStroke();
        fill( colour_red, colour_green, colour_blue, colour_alpha);
        rect( 0, 0, this.getWidth(), this.getHeight(), 5);
        popStyle();
      }
      public void touch() {
      }
      //we define the press method so that touches will be unassigned when they 'exit' the zone.
      public void press( Touch touch) {
      }
    }

    private class TouchtouchZone extends touchZone {
      public TouchtouchZone( int x, int y, int width, int height, 
      int colour_red, int colour_green, int colour_blue, int colour_alpha) {
        super( x, y, width, height, 
        colour_red, colour_green, colour_blue, colour_alpha);
      }
      //touch method
      public void touch() {
        Touch touch = getActiveTouch( 0);
        touch.setTint(
        colour_red, colour_green, colour_blue, colour_alpha);

        for (int i=0; i<soundsNum; i++) {
          if (canPlay) {
            sounds[i].audioPlay();
          }
          playDelay=0;
        }
      }
    }

    static final boolean isEven(int n) {
      return (n & 1) == 0;
    }

    static final boolean isOdd(int n) {
      return !isEven(n);
    }

  class Sound {
  //object variables 
  float xPos, yPos;

  String sourceFile1, sourceFile2, sourceFile3, sourceFile4, sourceFile5, sourceFile6, 
  sourceFile7, sourceFile8, sourceFile9, sourceFile10, sourceFile11, sourceFile12, sourceFile13, 
  sourceFile14, sourceFile15, sourceFile16; // this will hold the path to our audio file
  SamplePlayer sp1; 
  SamplePlayer sp2;
  SamplePlayer sp3;
  SamplePlayer sp4;
  SamplePlayer sp5;
  SamplePlayer sp6;
  SamplePlayer sp7;
  SamplePlayer sp8;
  SamplePlayer sp9;
  SamplePlayer sp10;
  SamplePlayer sp11; 
  SamplePlayer sp12;
  SamplePlayer sp13;
  SamplePlayer sp14;
  SamplePlayer sp15;
  SamplePlayer sp16;

  //Gain
  Gain g;
  Glide gainValue;
  //Reverb
  Reverb r; // our Reverberation unit generator

    Sound (float _Xpos, float _Ypos) {
    xPos = _Xpos;
    yPos = _Ypos;
  } 

  void audioSetup() {
    //    sourceFile = dataPath("0.mp3");
    //    sourceFile = dataPath("1.mp3");
    sourceFile1 = dataPath("clap-1.mp3");
    sourceFile2 = dataPath("snare-1.mp3");
    sourceFile3 = dataPath("clap-3.mp3");
    sourceFile4 = dataPath("clap-4.mp3");
    sourceFile5 = dataPath("crash-1.mp3");
    sourceFile6 = dataPath("crash-2.mp3");
    sourceFile7 = dataPath("crash-3.mp3");
    sourceFile8 = dataPath("crash-4.mp3");
    sourceFile9 = dataPath("mid-1.mp3");
    sourceFile10 = dataPath("mid-2.mp3");
    sourceFile11 = dataPath("mid-3.mp3");
    sourceFile12 = dataPath("mid-4.mp3");
    sourceFile13 = dataPath("clap-2.mp3");
    sourceFile14 = dataPath("snare-2.mp3");
    sourceFile15 = dataPath("snare-3.mp3");
    sourceFile16 = dataPath("snare-4.mp3");

    try {  
      sp1 = new SamplePlayer(ac, new Sample(sourceFile1));
      sp2 = new SamplePlayer(ac, new Sample(sourceFile2));
      //      sp3 = new SamplePlayer(ac, new Sample(sourceFile3));
      //      sp4 = new SamplePlayer(ac, new Sample(sourceFile4));
      //      sp5 = new SamplePlayer(ac, new Sample(sourceFile5));
      //      sp6 = new SamplePlayer(ac, new Sample(sourceFile6));
      //      sp7 = new SamplePlayer(ac, new Sample(sourceFile7));
      //      sp8 = new SamplePlayer(ac, new Sample(sourceFile8));
      //      sp9 = new SamplePlayer(ac, new Sample(sourceFile9));
      //      sp10 = new SamplePlayer(ac, new Sample(sourceFile10));
      //      sp12 = new SamplePlayer(ac, new Sample(sourceFile11));
      //      sp12 = new SamplePlayer(ac, new Sample(sourceFile12));
      //      sp13 = new SamplePlayer(ac, new Sample(sourceFile13));
      //      sp14 = new SamplePlayer(ac, new Sample(sourceFile14));
      //      sp15 = new SamplePlayer(ac, new Sample(sourceFile15));
      //      sp16 = new SamplePlayer(ac, new Sample(sourceFile16));
    }
    catch(Exception e)
    {
      println("Exception while at_ting to load sample!");
      e.printStackTrace(); 
      exit();
    }
    sp1.setKillOnEnd(false);
    sp2.setKillOnEnd(false);
    //    sp3.setKillOnEnd(false);
    //    sp4.setKillOnEnd(false);
    //    sp5.setKillOnEnd(false);
    //    sp6.setKillOnEnd(false);
    //    sp7.setKillOnEnd(false);
    //    sp8.setKillOnEnd(false);
    //    sp9.setKillOnEnd(false);
    //    sp10.setKillOnEnd(false);
    //    sp11.setKillOnEnd(false);
    //    sp12.setKillOnEnd(false);
    //    sp13.setKillOnEnd(false);
    //    sp14.setKillOnEnd(false);
    //    sp15.setKillOnEnd(false);
    //    sp16.setKillOnEnd(false);

    Gain g = new Gain(ac, 2, 0.2);
    g.addInput(sp1);
    g.addInput(sp2);
    //    g.addInput(sp3);
    //    g.addInput(sp4);
    //    g.addInput(sp5);
    //    g.addInput(sp6);
    //    g.addInput(sp7);
    //    g.addInput(sp8);
    //    g.addInput(sp9);
    //    g.addInput(sp10);
    //    g.addInput(sp11);
    //    g.addInput(sp12);
    //    g.addInput(sp13);
    //    g.addInput(sp14);
    //    g.addInput(sp15);
    //    g.addInput(sp16);

    ac.out.addInput(g);
  }

  void audioPlay() {

    for (int i=0; i<soundsNum; i++) {
      if (i == 1) {
        sp1.start(); // ply the audio file
        sp1.setToLoopStart();
      }
      if (i == 2) {
        sp2.start(); // ply the audio file
        sp2.setToLoopStart();
      }
    }
  }

  void textDisplay() {
  }
}

Screen Shot 2016-07-14 at 11.20.12 AM

Tagged:

Answers

  • edited July 2016

    Ok, so here is the thing is its huge long glory without any arrays... (class of sounds to follow in next post).

        //Set for 6' height from ground 15'6" distance
    
        import vialab.SMT.*;
    
        import beads.*;
    
        //Array of Zones
        int arrayNum = 56;
    
        color col = color(255,255,255);
    
        //Array of Sounds
        int soundsNum = 23;
        Sound[] sounds = new Sound[soundsNum];
        AudioContext ac;
    
        //Playback Variables
        int playDelay = 0;
        int waitTime = 10;
    
        boolean canPlay = true;
    
        boolean play1 = false;
        boolean play2 = false;
        boolean play3 = false;
        boolean play4 = false;
        boolean play5 = false;
        boolean play6 = false;
        boolean play7 = false;
        boolean play8 = false;
        boolean play9 = false;
        boolean play10 = false;
        boolean play11 = false;
        boolean play12 = false;
        boolean play13 = false;
        boolean play14 = false;
        boolean play15 = false;
        boolean play16 = false;
        boolean play17 = false;
        boolean play18 = false;
        boolean play19 = false;
        boolean play20 = false;
        boolean play21 = false;
        boolean play22 = false;
        boolean play23 = false;
        boolean play24 = false;
        boolean play25 = false;
        boolean play26 = false;
        boolean play27 = false;
        boolean play28 = false;
    
        //Grid Line Variables 
        int x, y;
        float areaW, areaH;
        int num, num2;
        float spacing, spacing2;
        float xVal, yVal;
    
        //Aspect Ratio Variables
        Float aspectX, aspectY;
        int buttonSize;
        float edgeSpace;
        int gridStartX, gridStartY;
    
        //Setup Display INFO
        boolean window_fullscreen = false;
        int window_width = 1200;
        int window_height = 800;
        int window_halfWidth;
        int window_halfHeight;
        int fps_limit = 60;
    
        void setup() {
    
          //Display setup
          if ( window_fullscreen) {
            window_width = displayWidth;
            window_height = displayHeight;
          }
          window_halfWidth = window_width / 2;
          window_halfHeight = window_height / 2;
          //processing window setup
          frameRate( fps_limit);
          size( window_width, window_height, SMT.RENDERER);
          SMT.init( this, TouchSource.AUTOMATIC);
    
          //Audio Setup
          ac = new AudioContext(); 
    
          //Aspect Ratio Variables
          edgeSpace = 40.0;
          //  aspectX = 640.0;
          //  aspectY = 480.0;
          aspectX = (float)width;
          aspectY = (float)height - edgeSpace*2;
    
          //  THIS IS NOT PERFECT YET
          gridStartX = (int)(aspectX-aspectY)/2;
          gridStartY = (int)edgeSpace;
    
          //Grid Line Variables 
          //  X
          num = 8;
          areaW=aspectY;
          //  Y
          num2 = 7;
          areaH=aspectY;
          buttonSize = (int)(aspectY/num2);
    
          //  ZONES FOR CHECKERBOARD STYLE
          Zone z = new Zone("TouchZone1", gridStartX, gridStartY, buttonSize, buttonSize);
          Zone z2 = new Zone("touchZone2", gridStartX+(2*buttonSize), gridStartY, buttonSize, buttonSize);
          Zone z3 = new Zone("TouchZone3", gridStartX+(4*buttonSize), gridStartY, buttonSize, buttonSize);
          Zone z4 = new Zone("touchZone4", gridStartX+(6*buttonSize), gridStartY, buttonSize, buttonSize);
          /////////
          Zone z5 = new Zone("TouchZone5", gridStartX+buttonSize, gridStartY+buttonSize, buttonSize, buttonSize);
          Zone z6 = new Zone("touchZone6", gridStartX+(3*buttonSize), gridStartY+buttonSize, buttonSize, buttonSize);
          Zone z7 = new Zone("TouchZone7", gridStartX+(5*buttonSize), gridStartY+buttonSize, buttonSize, buttonSize);
          Zone z8 = new Zone("touchZone8", gridStartX+(7*buttonSize), gridStartY+buttonSize, buttonSize, buttonSize);
          /////////
          Zone z9 = new Zone("TouchZone9", gridStartX, gridStartY+(2*buttonSize), buttonSize, buttonSize);
          Zone z10 = new Zone("touchZone10", gridStartX+(2*buttonSize), gridStartY+(2*buttonSize), buttonSize, buttonSize);
          Zone z11 = new Zone("touchZone11", gridStartX+(4*buttonSize), gridStartY+(2*buttonSize), buttonSize, buttonSize);
          Zone z12 = new Zone("touchZone12", gridStartX+(6*buttonSize), gridStartY+(2*buttonSize), buttonSize, buttonSize);
          /////////
          Zone z13 = new Zone("TouchZone13", gridStartX+buttonSize, gridStartY+(3*buttonSize), buttonSize, buttonSize);
          Zone z14 = new Zone("touchZone14", gridStartX+(3*buttonSize), gridStartY+(3*buttonSize), buttonSize, buttonSize);
          Zone z15 = new Zone("TouchZone15", gridStartX+(5*buttonSize), gridStartY+(3*buttonSize), buttonSize, buttonSize);
          Zone z16 = new Zone("touchZone16", gridStartX+(7*buttonSize), gridStartY+(3*buttonSize), buttonSize, buttonSize);
          /////////
          Zone z17 = new Zone("TouchZone17", gridStartX, gridStartY+(4*buttonSize), buttonSize, buttonSize);
          Zone z18 = new Zone("touchZone18", gridStartX+(2*buttonSize), gridStartY+(4*buttonSize), buttonSize, buttonSize);
          Zone z19 = new Zone("TouchZone19", gridStartX+(4*buttonSize), gridStartY+(4*buttonSize), buttonSize, buttonSize);
          Zone z20 = new Zone("touchZone20", gridStartX+(6*buttonSize), gridStartY+(4*buttonSize), buttonSize, buttonSize);
          /////////
          Zone z21 = new Zone("TouchZone21", gridStartX+buttonSize, gridStartY+(5*buttonSize), buttonSize, buttonSize);
          Zone z22 = new Zone("touchZone22", gridStartX+(3*buttonSize), gridStartY+(5*buttonSize), buttonSize, buttonSize);
          Zone z23 = new Zone("TouchZone23", gridStartX+(5*buttonSize), gridStartY+(5*buttonSize), buttonSize, buttonSize);
          Zone z24 = new Zone("touchZone24", gridStartX+(7*buttonSize), gridStartY+(5*buttonSize), buttonSize, buttonSize);
          /////////
          Zone z25 = new Zone("TouchZone25", gridStartX, gridStartY+(6*buttonSize), buttonSize, buttonSize);
          Zone z26 = new Zone("touchZone26", gridStartX+(2*buttonSize), gridStartY+(6*buttonSize), buttonSize, buttonSize);
          Zone z27 = new Zone("TouchZone27", gridStartX+(4*buttonSize), gridStartY+(6*buttonSize), buttonSize, buttonSize);
          Zone z28 = new Zone("touchZone28", gridStartX+(6*buttonSize), gridStartY+(6*buttonSize), buttonSize, buttonSize);
    
    
          SMT.add(z);
          SMT.add(z2);
          SMT.add(z3);
          SMT.add(z4);
          SMT.add(z5);
          SMT.add(z6);
          SMT.add(z7);
          SMT.add(z8);
          SMT.add(z9);
          SMT.add(z10);
          SMT.add(z11);
          SMT.add(z12);
          SMT.add(z13);
          SMT.add(z14);
          SMT.add(z15);
          SMT.add(z16);
          SMT.add(z17);
          SMT.add(z18);
          SMT.add(z19);
          SMT.add(z20);
          SMT.add(z21);
          SMT.add(z22);
          SMT.add(z23);
          SMT.add(z24);
          SMT.add(z25);
          SMT.add(z26);
          SMT.add(z27);
          SMT.add(z28);
    
          //  ARRAY INITIALIZES AUDIO SETUP  
          for (int i=0; i<soundsNum; i++) {
            sounds[i] = new Sound(0, 0, "");
            sounds[i].audioSetup();
          }
          ac.start();
        }
    
    
        void draw() { 
          background(0);
          fill(30);
    
          spacing = buttonSize;
    
          playDelay++;
          if (playDelay >= waitTime) {
            canPlay = true;
          } else {
            canPlay = false;
          }
          fill(255);
          text("Play Delay: "+playDelay, width-100, height-20);
          fill(0);
    
        /*
          //FOR GRID DEBUGGING
          //  rect(0, gridStartY, aspectX, aspectY);
          for (int m = 0; m < num; m++) {
            for (int n = 0; n < num2; n++) {
              stroke(125);
              strokeWeight(3);
              x = gridStartX+(m*buttonSize); 
              y = gridStartY+(n*buttonSize);
              rect(x, y, buttonSize, buttonSize);
            }
          }
          */
        }
    
        void drawFrameRate() {
          float fps = this.frameRate;
          String fps_text = String.format( "fps: %.0f", fps);
          pushStyle();
          fill( 240, 240, 240, 180);
          textAlign( RIGHT, TOP);
          textMode( MODEL);
          textSize( 32);
          text( fps_text, window_width - 10, 10);
          popStyle();
        }
    
        /////////////// ZONES 1-4 ///////////////
    
        void drawTouchZone1(Zone z) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone1(Zone z) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play1 = true;
          }
          playDelay=0;
        }
        void touchTouchZone1() {
        }
        void pressTouchZone1( Touch touch) {
        }
    
        void drawTouchZone2(Zone z2) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone2(Zone z2) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play2 = true;
          }
          playDelay=0;
        }
        void touchTouchZone2() {
        }
        void pressTouchZone2( Touch touch) {
        }
    
        void drawTouchZone3(Zone z3) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone3(Zone z3) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play3 = true;
          }
          playDelay=0;
        }
        void touchTouchZone3() {
        }
        void pressTouchZone3( Touch touch) {
        }
    
        void drawTouchZone4(Zone z4) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone4(Zone z4) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play4 = true;
          }
          playDelay=0;
        }
        void touchTouchZone4() {
        }
        void pressTouchZone4( Touch touch) {
        }
    
        /////////////// ZONES 5-8 ///////////////
    
        void drawTouchZone5(Zone z5) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone5(Zone z5) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play5 = true;
          }
          playDelay=0;
        }
        void touchTouchZone5() {
        }
        void pressTouchZone5( Touch touch) {
        }
    
        void drawTouchZone6(Zone z6) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone6(Zone z6) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play6 = true;
          }
          playDelay=0;
        }
        void touchTouchZone6() {
        }
        void pressTouchZone6( Touch touch) {
        }
    
        void drawTouchZone7(Zone z7) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone7(Zone z7) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play7 = true;
          }
          playDelay=0;
        }
        void touchTouchZone7() {
        }
        void pressTouchZone7( Touch touch) {
        }
    
        void drawTouchZone8(Zone z8) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone8(Zone z8) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play4 = true;
          }
          playDelay=0;
        }
        void touchTouchZone8() {
        }
        void pressTouchZone8( Touch touch) {
        }
    
        /////////////// ZONES 9-12 ///////////////
    
        void drawTouchZone9(Zone z9) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone9(Zone z9) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play9 = true;
          }
          playDelay=0;
        }
        void touchTouchZone9() {
        }
        void pressTouchZone9( Touch touch) {
        }
    
        void drawTouchZone10(Zone z10) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone10(Zone z10) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play10 = true;
          }
          playDelay=0;
        }
        void touchTouchZone10() {
        }
        void pressTouchZone10( Touch touch) {
        }
    
        void drawTouchZone11(Zone z11) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone11(Zone z11) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play11 = true;
          }
          playDelay=0;
        }
        void touchTouchZone11() {
        }
        void pressTouchZone11( Touch touch) {
        }
    
        void drawTouchZone12(Zone z12) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone12(Zone z12) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play12 = true;
          }
          playDelay=0;
        }
        void touchTouchZone12() {
        }
        void pressTouchZone12( Touch touch) {
        }
    
        /////////////// ZONES 13-16 ///////////////
    
        void drawTouchZone13(Zone z13) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone13(Zone z13) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play13 = true;
          }
          playDelay=0;
        }
        void touchTouchZone13() {
        }
        void pressTouchZone13( Touch touch) {
        }
    
        void drawTouchZone14(Zone z14) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone14(Zone z14) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play14 = true;
          }
          playDelay=0;
        }
        void touchTouchZone14() {
        }
        void pressTouchZone14( Touch touch) {
        }
    
        void drawTouchZone15(Zone z15) {
          fill(col);
          rect(0, 0, buttonSize, buttonSize);
        }
        void touchTouchZone15(Zone z15) {
          sounds[0].audioPlay();
    
          if (canPlay) {
            play15 = true;
          }
          playDelay=0;
        }
        void touchTouchZone15() {
        }
        void pressTouchZone15( Touch touch) {
        }
    

    and on through zones 16-28... } void pressTouchZone16( Touch touch) { }

  • Then the sounds class...

    class Sound {
      //object variables 
      float xPos, yPos;
      String soundName;
    
    
      //Audio Files
      int numSamples = 0;
      int sampleWith = 0;
      String [] sourceFile;
    
    
      String sourceFile1, sourceFile2, sourceFile3, sourceFile4, sourceFile5, sourceFile6, 
      sourceFile7, sourceFile8, sourceFile9, sourceFile10, sourceFile11, sourceFile12, sourceFile13, 
      sourceFile14, sourceFile15, sourceFile16; // this will hold the path to our audio file
    
      SamplePlayer sp1; 
      SamplePlayer sp2;
      SamplePlayer sp3;
      SamplePlayer sp4;
      SamplePlayer sp5;
      SamplePlayer sp6;
      SamplePlayer sp7;
      SamplePlayer sp8;
      SamplePlayer sp9;
      SamplePlayer sp10;
      SamplePlayer sp11; 
      SamplePlayer sp12;
      SamplePlayer sp13;
      SamplePlayer sp14;
      SamplePlayer sp15;
      SamplePlayer sp16;
    
    
      //Gain
      Gain g;
      Glide gainValue;
      //Reverb
      Reverb r; // our Reverberation unit generator
    
    
        Sound (float _Xpos, float _Ypos, String _SoundName) {
        xPos = _Xpos;
        yPos = _Ypos;
        soundName = "";
      }
    
    
    
      void audioSetup() {
        sourceFile1 = dataPath("clap-1.mp3");
        sourceFile2 = dataPath("snare-1.mp3");
        sourceFile3 = dataPath("mid-2.mp3");
        sourceFile4 = dataPath("crash-4.mp3");
        sourceFile5 = dataPath("crash-1.mp3");
        sourceFile6 = dataPath("clap-2.mp3");
        sourceFile7 = dataPath("mid-1.mp3");
        sourceFile8 = dataPath("clap-4.mp3");
        sourceFile9 = dataPath("crash-3.mp3");
        sourceFile10 = dataPath("clap-3.mp3");
        sourceFile11 = dataPath("mid-3.mp3");
        sourceFile12 = dataPath("mid-4.mp3");
        sourceFile13 = dataPath("crash-2.mp3");
        sourceFile14 = dataPath("snare-2.mp3");
        sourceFile15 = dataPath("snare-3.mp3");
        sourceFile16 = dataPath("snare-4.mp3");
    
        try {  
          sp1 = new SamplePlayer(ac, new Sample(sourceFile1));
          sp2 = new SamplePlayer(ac, new Sample(sourceFile2));
          sp3 = new SamplePlayer(ac, new Sample(sourceFile3));
          sp4 = new SamplePlayer(ac, new Sample(sourceFile4));
          sp5 = new SamplePlayer(ac, new Sample(sourceFile5));
          sp6 = new SamplePlayer(ac, new Sample(sourceFile6));
          sp7 = new SamplePlayer(ac, new Sample(sourceFile7));
          sp8 = new SamplePlayer(ac, new Sample(sourceFile8));
          sp9 = new SamplePlayer(ac, new Sample(sourceFile9));
          sp10 = new SamplePlayer(ac, new Sample(sourceFile10));
          sp11 = new SamplePlayer(ac, new Sample(sourceFile11));
          sp12 = new SamplePlayer(ac, new Sample(sourceFile12));
          sp13 = new SamplePlayer(ac, new Sample(sourceFile13));
          sp14 = new SamplePlayer(ac, new Sample(sourceFile14));
          sp15 = new SamplePlayer(ac, new Sample(sourceFile15));
          sp16 = new SamplePlayer(ac, new Sample(sourceFile16));
        }
        catch(Exception e)
        {
          println("Exception while at_ting to load sample!");
          e.printStackTrace(); 
          exit();
        }
        sp1.setKillOnEnd(false);
        sp2.setKillOnEnd(false);
        sp3.setKillOnEnd(false);
        sp4.setKillOnEnd(false);
        sp5.setKillOnEnd(false);
        sp6.setKillOnEnd(false);
        sp7.setKillOnEnd(false);
        sp8.setKillOnEnd(false);
        sp9.setKillOnEnd(false);
        sp10.setKillOnEnd(false);
        sp11.setKillOnEnd(false);
        sp12.setKillOnEnd(false);
        sp13.setKillOnEnd(false);
        sp14.setKillOnEnd(false);
        sp15.setKillOnEnd(false);
        sp16.setKillOnEnd(false);
    
        Gain g = new Gain(ac, 2, 0.2);
        g.addInput(sp1);
        g.addInput(sp2);
        g.addInput(sp3);
        g.addInput(sp4);
        g.addInput(sp5);
        g.addInput(sp6);
        g.addInput(sp7);
        g.addInput(sp8);
        g.addInput(sp9);
        g.addInput(sp10);
        g.addInput(sp11);
        g.addInput(sp12);
        g.addInput(sp13);
        g.addInput(sp14);
        g.addInput(sp15);
        g.addInput(sp16);
    
        ac.out.addInput(g);
      }
    
      void audioPlay() {
    
        if (play1) {
          sp1.start(); // ply the audio file
          sp1.setToLoopStart();
          play1 = false;
        }
        if (play2) {
          sp2.start(); // ply the audio file
          sp2.setToLoopStart();
          play2 = false;
        }
        if (play3) {
          sp3.start(); // ply the audio file
          sp3.setToLoopStart();
          play3 = false;
        }
        if (play4) {
          sp4.start(); // ply the audio file
          sp4.setToLoopStart();
          play4 = false;
        }
        if (play5) {
          sp5.start(); // ply the audio file
          sp5.setToLoopStart();
          play5 = false;
        }
        if (play6) {
          sp6.start(); // ply the audio file
          sp6.setToLoopStart();
          play6 = false;
        }
        if (play7) {
          sp7.start(); // ply the audio file
          sp7.setToLoopStart();
          play7 = false;
        }
        if (play8) {
          sp8.start(); // ply the audio file
          sp8.setToLoopStart();
          play8 = false;
        }
        if (play9) {
          sp9.start(); // ply the audio file
          sp9.setToLoopStart();
          play9 = false;
        }
        if (play10) {
          sp10.start(); // ply the audio file
          sp10.setToLoopStart();
          play10 = false;
        }
        if (play11) {
          sp11.start(); // ply the audio file
          sp11.setToLoopStart();
          play11 = false;
        }
        if (play12) {
          sp12.start(); // ply the audio file
          sp12.setToLoopStart();
          play12 = false;
        }
        if (play13) {
          sp13.start(); // ply the audio file
          sp13.setToLoopStart();
          play13 = false;
        }
        if (play14) {
          sp14.start(); // ply the audio file
          sp14.setToLoopStart();
          play14 = false;
        }
        if (play15) {
          sp15.start(); // ply the audio file
          sp15.setToLoopStart();
          play15 = false;
        }
        if (play16) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play16 = false;
        }
        if (play17) {
          sp13.start(); // ply the audio file
          sp13.setToLoopStart();
          play17 = false;
        }
        if (play18) {
          sp14.start(); // ply the audio file
          sp14.setToLoopStart();
          play18 = false;
        }
        if (play19) {
          sp15.start(); // ply the audio file
          sp15.setToLoopStart();
          play19 = false;
        }
        if (play20) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play20 = false;
        }
        if (play21) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play21 = false;
        }
        if (play22) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play22 = false;
        }
        if (play23) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play23 = false;
        }
        if (play24) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play24 = false;
        }
        if (play25) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play25 = false;
        }
        if (play26) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play26 = false;
        }
        if (play27) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play27 = false;
        }
        if (play28) {
          sp16.start(); // ply the audio file
          sp16.setToLoopStart();
          play28 = false;
        }
      }
    }
    
  • i'd have a square class, holding the position, colour of the square, the smt zone and the sound associated with it. keep all the things associated with one thing on one object.

    Your code looks, sorry, terrible. If you find yourself writing the same thing over and over again then you're usually doing something wrong.

  • edited July 2016

    Hey Koogs, I agree it is terrible, it just came down to not knowing how to do it efficiently and having to have in done in a certain time. I understand the concepts of arrays and classes, but I'm sure you understand with certain libraries they can get quite confusing without extensive experience or a history in CS. Any further help is appreciated and as I'm able to condense it down I will post to try and help others in the future with the same issues.

    Thanks for the link to read GoToLoop. Will check it out, although the problem I had before wasn't with constructing arrays and classes, but more specifically the tactics of it for this application. To ensure each SMT touch source produced a separate sound.

  • Here it is mega cut down..

    Still need help with forLoop for the draw/touchZone.

        //Set for 6' height from ground 15'6" distance
    
            import vialab.SMT.*;
    
            import beads.*;
    
            //Array of Zones
            int soundsNum = 28;
            Cell[][] grid;
            Zone[] z = new Zone[soundsNum];
            boolean isEven;
            boolean isOdd;
            int x, y;
    
            //To Define if people are in space
            int people;
            boolean peopleIn = false;
    
            //PLAYHEAD for screensaver
            int playX;
            int playY;
            int grow;
            //Controlling Playhead Speed 
            float rate = 5;
            int passCount=1;
    
            //Color Definitions
            color col = color(255, 255, 255, 100);
            color col2 = color(255, 0, 0, 100);
    
            //Array of Sounds
            Sound[] sounds = new Sound[soundsNum];
            AudioContext ac;
            //Audio Files
            int numSamples = 0;
            int sampleWith = 0;
            String [] sourceFile;
            Gain [] gain;
            Glide [] gainAmt;
            SamplePlayer [] samplePlayer;
    
            //Playback Variables
            int playDelay = 0;
            int waitTime = 10;
    
            //Touch
            boolean isTouched = false;
    
            //Booleans For Playing Audio
            boolean canPlay = true;
            boolean [] play = new boolean[soundsNum];
    
            //Grid Line Variables 
            int numCols, numRows;
            //Width Variables
            int col1n8, col2n7, col3n6, col4n5;
            int xCol1, xCol2, xCol3, xCol4, xCol5, xCol6, xCol7, xCol8;
            int rowAnG, rowBnF, rowCnE, rowD;
            int yRowA, yRowB, yRowC, yRowD, yRowE, yRowF, yRowG;
    
            //Aspect Ratio Variables
            Float aspectX, aspectY;
            int buttonSize;
            float edgeSpace;
            int gridStartX, gridStartY;
    
            //Setup Display INFO
            boolean window_fullscreen = false;
            int window_width = 1200;
            int window_height = 800;
            int window_halfWidth;
            int window_halfHeight;
            int fps_limit = 60;
    
            //Removes frame from window
            //void init()
            //{
            //  frame.removeNotify();
            //  frame.setUndecorated(true);
            //  frame.addNotify();
            //  super.init();
            //}
    
            void setup() {
    
              //Sets Frameless window to Location
              frame.setLocation(0, 0);
    
              //Display setup
              if ( window_fullscreen) {
                window_width = displayWidth;
                window_height = displayHeight;
              }
              window_halfWidth = window_width / 2;
              window_halfHeight = window_height / 2;
              //processing window setup
              frameRate(fps_limit);
              size( window_width, window_height, SMT.RENDERER);
    
              //  size( 1000, 700, SMT.RENDERER);
              SMT.init( this, TouchSource.AUTOMATIC);
    
              //Audio Setup
              ac = new AudioContext(); 
              File folder = new File(sketchPath("") + "samples");
              File [] fileList = folder.listFiles();
              for (int i = 0; i < fileList.length; i ++) {
                if (fileList[i].isFile()) {
                  if (fileList[i].getName().endsWith(".mp3")) {
                    numSamples ++;
                  }
                }
              }
              if (numSamples <= 0) {
                println("No samples found in " + sketchPath("") + "samples/");
                println("Exiting...");
                exit();
              }
              sampleWith = 20;
              sourceFile = new String[numSamples];
              int count = 0;
              for (int i = 0; i < fileList.length; i ++) {
                if (fileList[i].isFile()) {
                  if (fileList[i].getName().endsWith(".mp3")) {
                    sourceFile[count] = fileList[i].getName();
                    count ++;
                  }
                }
              }
              gain = new Gain[numSamples];
              gainAmt  = new Glide[numSamples];
              samplePlayer = new SamplePlayer[numSamples];
              try {
                for (count = 0; count < numSamples; count ++) {
                  println("loading" + sketchPath("") + "samples/" + sourceFile[count]);
                  samplePlayer[count] = new SamplePlayer(ac, new Sample(sketchPath("") + "samples/" + sourceFile[count]));
                  samplePlayer[count].setKillOnEnd(false);
                  gainAmt[count] = new Glide(ac, 0.0);
                  gain[count] = new Gain(ac, 2, 0.2);
                  gain[count].addInput(samplePlayer[count]);
                  ac.out.addInput(gain[count]);
                }
              }
              catch (Exception e) {
                println("Error loading samples");
                e.printStackTrace();
                exit();
              }
    
              //Aspect Ratio Variables
              numCols = 8;
              numRows = 7;
    
              edgeSpace = 5.0;
    
              aspectX = (float)width;
              aspectY = (float)(height - edgeSpace*2);
              buttonSize = (int)(aspectY/numRows);
              gridStartX = (int)(((aspectX-aspectY)/2)-(buttonSize/2));
              gridStartY = (int)edgeSpace;
    
              println(gridStartX, " ", buttonSize );
    
              col1n8 = (int)(width*0.03); 
              col2n7 = (int)(width*0.07); 
              col3n6 = (int)(width*0.10);
              col4n5 = (int)(width*0.3);
              xCol1 = 0;
              xCol2 = col1n8;
              xCol3 = col1n8 + col2n7;
              xCol4 = col1n8+col2n7+col3n6;
              xCol5 = col1n8+col2n7+col3n6+col4n5;
              xCol6 = col1n8+col2n7+col3n6+col4n5+col4n5;
              xCol7 = col1n8+col2n7+col3n6+col4n5+col4n5+col3n6;
              xCol8 = col1n8+col2n7+col3n6+col4n5+col4n5+col3n6+col2n7;
    
              rowAnG = (int)(height*0.05);
              rowBnF = (int)(height*0.10);
              rowCnE = (int)(height*0.15);
              rowD = (int)(height*0.4);
              yRowA = 0;
              yRowB = rowAnG;
              yRowC = rowAnG+rowBnF;
              yRowD = rowAnG+rowBnF+rowCnE;
              yRowE = rowAnG+rowBnF+rowCnE+rowD;
              yRowF = rowAnG+rowBnF+rowCnE+rowD+rowCnE;
              yRowG = rowAnG+rowBnF+rowCnE+rowD+rowCnE+rowBnF;
    
              grid = new Cell[numCols][numRows];
              for (int i = 0; i < numCols; i++) {
                for (int j = 0; j < numRows; j++) {
                  // Initialize each object
                  grid[i][j] = new Cell(gridStartX+(i*buttonSize), gridStartY+(j*buttonSize), buttonSize, buttonSize);
                }
              }
    
    
              for (int i=0; i<numSamples; i++) {
                if ((i>=0)&&(i<=3)) {
                  y = gridStartY;
                } 
                if ((i>=4)&&(i<=7)) {
                  y = gridStartY+buttonSize;
                }
                if ((i>=8)&&(i<=11)) {
                  y = gridStartY+(2*buttonSize);
                }
                if ((i>=12)&&(i<=15)) {
                  y = gridStartY+(3*buttonSize);
                }
                if ((i>=16)&&(i<=19)) {
                  y = gridStartY+(4*buttonSize);
                }
                if ((i>=20)&&(i<=23)) {
                  y = gridStartY+(5*buttonSize);
                }
                if ((i>=24)&&(i<=27)) {
                  y = gridStartY+(6*buttonSize);
                }
                if ((i==0)||(i==8)||(i==16)||(i==24)) {
                  x = gridStartX;
                }
                if ((i==1)||(i==9)||(i==17)||(i==25)) {
                  x = gridStartX+(2*buttonSize);
                }
                if ((i==2)||(i==10)||(i==18)||(i==26)) {
                  x = gridStartX+(4*buttonSize);
                }
                if ((i==3)||(i==11)||(i==19)||(i==27)) {
                  x = gridStartX+(6*buttonSize);
                }
                if ((i==4)||(i==12)||(i==20)) {
                  x = gridStartX+(buttonSize);
                }
                if ((i==5)||(i==13)||(i==21)) {
                  x = gridStartX+(3*buttonSize);
                }
                if ((i==6)||(i==14)||(i==22)) {
                  x = gridStartX+(5*buttonSize);
                }
                if ((i==7)||(i==15)||(i==23)) {
                  x = gridStartX+(7*buttonSize);
                }
    
                //    HOW DO I ADD THE NUMERAL AFTER THE TEXT?
                z[i] = new Zone("TouchZone"+i, x, y, buttonSize, buttonSize);
                SMT.add(z[i]);
              }
    
              //  ARRAY INITIALIZES AUDIO SETUP  
              for (int i=0; i<soundsNum; i++) {
                sounds[i] = new Sound(0, 0, "");
                sounds[i].audioSetup();
              }
    
              ac.start();
            }
    
            void draw() { 
              background(0);
              fill(30);
    
              //  for (int i = 0; i < numCols; i++) {
              //    for (int j = 0; j < numRows; j++) {
              //      // Oscillate and display each object
              //      grid[i][j].display();
              //    }
              //  }
    
              sounds[0].delay();
              sounds[0].peopleOn();
              sounds[0].textDisplay();
    
              //Switch off SMT cursors
              //  SMT.setTouchDraw(TouchDraw.NONE);
            }
    
            /////////////// ZONES 0-3 ///////////////
    
            void drawTouchZone0(Zone z0) {
              if (peopleIn) {
                //    ACTUAL TOUCH ZONE
                fill(col);
                rect(0, 0, buttonSize, buttonSize);
              }
            }
            void touchTouchZone0(Zone z0) {
              sounds[0].audioPlay();
              if (canPlay) {
                play[0] = true;
              }    
              playDelay=0;
              isTouched = true;
            }
    
            void touchTouchZone0() {
            }
            void pressTouchZone0( Touch touch) {
            }
    
            void drawTouchZone1(Zone z1) {
              if (peopleIn) {
                fill(col);
                rect(0, 0, buttonSize, buttonSize);
              }
            }
            void touchTouchZone1(Zone z1) {
              sounds[1].audioPlay();
              if (canPlay) {
                play[1] = true;
              }    
              playDelay=0;
              isTouched = true;
            }
            void touchTouchZone1() {
            }
            void pressTouchZone1( Touch touch) {
            }
    
            void drawTouchZone2(Zone z2) {
              if (peopleIn) {
                fill(col);
                rect(0, 0, buttonSize, buttonSize);
              }
            }
            void touchTouchZone2(Zone z2) {
              sounds[2].audioPlay();
              if (canPlay) {
                play[2] = true;
              }    
              playDelay=0;
              isTouched = true;
            }
            void touchTouchZone2() {
            }
            void pressTouchZone2( Touch touch) {
            }
    
            void drawTouchZone3(Zone z3) {
              if (peopleIn) {
                fill(col);
                rect(0, 0, buttonSize, buttonSize);
              }
            }
            void touchTouchZone3(Zone z3) {
              sounds[3].audioPlay();
              if (canPlay) {
                play[3] = true;
              }    
              playDelay=0;
              isTouched = true;
            }
    
            class Sound {
              //object variables 
              float xPos, yPos;
              String soundName;
    
    
              Sound (float _Xpos, float _Ypos, String _SoundName) {
                xPos = _Xpos;
                yPos = _Ypos;
                soundName = "";
              }
    
              void audioSetup() {
              }
    
              void audioPlay() {
                for (int i=0; i<soundsNum; i++) {
    
                  if (play[i]) {
                    samplePlayer[i].start();
                    samplePlayer[i].setToLoopStart();
                    play[i] = false;
                  }
                }
              }
    
              void textDisplay () {
                fill(255);
                text("Play Delay: "+playDelay, width-100, height-20);
                text("People: "+people, width-100, height-40);
              }
    
              void delay () {
                playDelay++;
                if (playDelay >= waitTime) {
                  canPlay = true;
                  isTouched = false;
                } else {
                  canPlay = false;
                }
              }
    
              void peopleOn () {
                people = SMT.getTouchCount();
                if (people<0) {
                  peopleIn=false;
                } else {
                  peopleIn = true;
                }
                if (!peopleIn) {
                  screenSaver();
                }
          }
        }
    
  • Here's what I needed for audio—loads everything in the "samples" folder. Assigns it separate gain and glide. I'll post the rest of the code for SMT soon.

    //Audio Setup
          ac = new AudioContext(); 
          File folder = new File(sketchPath("") + "samples");
          File [] fileList = folder.listFiles();
          for (int i = 0; i < fileList.length; i ++) {
            if (fileList[i].isFile()) {
              if (fileList[i].getName().endsWith(".mp3")) {
                numSamples ++;
              }
            }
          }
          if (numSamples <= 0) {
            println("No samples found in " + sketchPath("") + "samples/");
            println("Exiting...");
            exit();
          }
          sampleWith = 20;
          sourceFile = new String[numSamples];
          int count = 0;
          for (int i = 0; i < fileList.length; i ++) {
            if (fileList[i].isFile()) {
              if (fileList[i].getName().endsWith(".mp3")) {
                sourceFile[count] = fileList[i].getName();
                count ++;
              }
            }
          }
          gain = new Gain[numSamples];
          gainAmt  = new Glide[numSamples];
          samplePlayer = new SamplePlayer[numSamples];
          try {
            for (count = 0; count < numSamples; count ++) {
              println("loading" + sketchPath("") + "samples/" + sourceFile[count]);
              samplePlayer[count] = new SamplePlayer(ac, new Sample(sketchPath("") + "samples/" + sourceFile[count]));
              samplePlayer[count].setKillOnEnd(false);
              gainAmt[count] = new Glide(ac, 0.0);
              gain[count] = new Gain(ac, 2, 0.2);
              gain[count].addInput(samplePlayer[count]);
              ac.out.addInput(gain[count]);
            }
          }
          catch (Exception e) {
            println("Error loading samples");
            e.printStackTrace();
            exit();
          }
    
          ac.start();
    
Sign In or Register to comment.