public void setup() {

    brek = new AudioSample[4][4];
    // load audio samples

    minim = new Minim(this);

    for (int i = 0; i < 4; i++) {
      println("break-beat-0" + (i + 1) + ".mp3");
      brek[i][0] = minim.loadSample("break-beat-0" + (i + 1) + ".mp3", 512);
      brek[i][1] = minim.loadSample("break-perc-0" + (i + 1) + ".mp3", 512);
      brek[i][2] = minim.loadSample("break-piano-0" + (i + 1) + ".mp3", 512);
      brek[i][3] = minim.loadSample("break-strings-0" + (i + 1) + ".mp3", 512);
    }

    size(cellSize * cols, cellSize * rows);

    //  bytes[0]=0;
    // bytes[1]=1;

    grid = new Cell[cols][rows];
    for (int i = 0; i < cols; i++) {
      for (int j = 0; j < rows; j++) {
        grid[i][j] = new Cell(i * cellSize, j * cellSize, cellSize, cellSize);
      }
    }
    println(Serial.list());

    String portName = Serial.list()[2];
    myPort = new Serial(this, portName, 9600);
  }
  public void setup() {
    int window_height = 220;
    size((int) (window_height * 5.12f), 220);
    canvas = createGraphics((int) (window_height * 5.12f) / 2, 220, JAVA2D);

    textMode(SCREEN);
    textFont(createFont("SanSerif", 12));

    minim = new Minim(this);

    in = minim.getLineIn(Minim.MONO, buffer_size, sample_rate);

    // create an FFT object that has a time-domain buffer
    // the same size as line-in's sample buffer
    fft = new FFT(in.bufferSize(), in.sampleRate());
    // Tapered window important for log-domain display
    fft.window(FFT.HAMMING);

    // initialize peak-hold structures
    peaksize = 1 + Math.round(fft.specSize() / binsperband);
    peaks = new float[peaksize];
    peak_age = new int[peaksize];

    particles = new Particle[fft.specSize()];
    for (int i = 0; i < fft.specSize(); i++) particles[i] = new Particle(i);
  }
 public void stop() {
   in.close();
   minim.stop();
   super.stop();
 }
Example #4
0
 // EVENTUALLY, ASSOCIATE A SOUNDFILE FROM THE CONSTRUCTOR AS WELL!!!
 public Dialog(String sFile, int time, Minim m) {
   timeStamp = time;
   type = DIA_TIME;
   ap = m.loadFile(sFile, 2048);
 }