Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Frame smoothing, frame blending, general calming effect

$
0
0
Hi I just picked up processing a week ago and have created a code for a project trying to simulate synesthesia (seeing sounds as color). 

The general idea is there and working in Minim with a freq analyser and colorMode HSB, but the real-time playback is so fast and intense. I have looked into smooth(); and blend() but either have no effect, or won't run.

If anyone has any advice I'm sure this problem is wildely simple! Any input would be greatly appreciated. 

import ddf.minim.analysis.*;
import ddf.minim.*;

Minim minim;  
AudioInput in;
FFT fftLin;
FFT fftLog;
float height3;
float height23;



void setup()
{
  frameRate(60);
  size(600, 600, P3D);

  height3 = height/3;
  height23 = 2*height/3;
  smooth();

  minim = new Minim(this);
  in = minim.getLineIn();

  fftLin = new FFT(in.bufferSize(), in.sampleRate());
  fftLin.linAverages(30);
    rectMode(CORNERS);
}

void draw()
{
  
  background(0);
// blend(i, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST); // HELP WITH BLEND OR FRAME BLEND

  fftLin.forward(in.mix); // Important 
  
  stroke(255);
  for(int i = 0; i < fftLin.specSize(); i++)
  {
    line(i, height3, i, height3 - fftLin.getBand(i)*2);
  }
  
 

  float winner = 0;
  int whichBand = 0; 
  for(int i = 0; i < fftLin.avgSize(); i++)
  {
     if ( fftLin.getBand(i) > winner) {
       winner = fftLin.getBand(i);
       whichBand = i;
     }
  }
  
  println(whichBand + " -- " + winner);
  
  float hue = map(whichBand, 0, 32, 0, 255); 
  println("hue: " + hue); 
  
  noStroke();
  colorMode(HSB); 
  fill(hue, 255, 255); 
  rect(width, height, winner, winner); 
  //blend(winner, 0, 0, 33, 100, 67, 0, 33, 100, LIGHTEST);


  println("FPS: " + frameRate);
}

void stop()
{

  in.close();

  minim.stop();
  
  super.stop();
}

Viewing all articles
Browse latest Browse all 1768

Trending Articles