読者です 読者をやめる 読者になる 読者になる

Daily Creative Coding

元「30 min. Processing」。毎日、Creative Codingします。

Minimでディレイをかける

f:id:aa_debdeb:20151202091942j:plain
/**
* Minim Delay
*
* @author aa_debdeb
* @date 2015/12/08
*/

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

Minim minim;
AudioOutput out;
Oscil wave;
Delay delay;

void setup(){
  size(512, 200);
  minim = new Minim(this);
  out = minim.getLineOut();
  wave = new Oscil(440, 0.3, Waves.SQUARE);
  delay = new Delay(0.5, 0.5, true, true);
  wave.patch(delay).patch(out);
}

void draw(){
  background(0);

  stroke(255);
  strokeWeight(1);
  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);
  }
  
  fill(255, 0, 0);
  textSize(12);
  text("maxDelayTime: " + delay.delTime.getLastValue(), 10, 15);
  text("amplitudeFactor: " + delay.delAmp.getLastValue(), 10, 30);
}

void mouseMoved(){
  float delayTime = map(mouseX, 0, width, 0, 1.0);
  delay.setDelTime(delayTime);
  float delayAmplitude = map(mouseY, 0, height, 0, 1.0);
  delay.setDelAmp(delayAmplitude);
}