Fade effect

Hi there, I'm trying to get my animation to appear smoother, so I thought I'd take the previous frame and paint it with some transparency onto the current frame. I have done this in another animation, and I pretty much copied it onto this one, so I'm doing something wrong and I can't see it. Also, for some reason translate(width/2, height/2); won't work if written in setup(), which I thought was a bit strange. It would make sense to be able to do the translation only once at the beginning, right?

Here's my code so far:

PImage fade;

void setup(){

  size(1280, 720, P3D);
  smooth();


  fade = get(0, 0, width, height);


}

void draw(){  

  background(0);
  tint( 255, 255, 255, 254);
  translate(width/2, height/2);

  image(fade, -width/2, -height/2);
  noTint();


  colorMode(HSB, 100);


  filter.paintCircle(bassDominantFreq, 1);
  filter.paintCircle(midsDominantFreq, 2);
  filter.paintCircle(trebleDominantFreq, 3);

  fade = get(-width/2, -height/2, width/2, height/2);


}

Now, as far as I understand, the coordinates should be correct: top left corner would be -width/2, -height/2, and lower right corner would be width/2, height/2.

Any ideas?

Answers

  • Doesn't run. Error on line 27: Can't find anything named filter.

  • Ok, I tried to clear unrelated things off the code to make it easier to read. This is it exactly how it is when I run it:

    import ddf.minim.analysis.*;
    import ddf.minim.*;
    
    Minim minim;
    AudioInput in;
    FFT fft;
    BeatDetect beat;
    Filter filter;
    FreqAndNote freqAndNote;
    FreqAndColour freqAndColour;
    
    int w;
    int time = 0;
    int radius = 0; 
    
    int bass = 300;
    int mids = 1000;
    int treble = 4000;
    
    float [][] bassArray;
    float [][] bassDominantFreq;
    float [][] midsArray;
    float [][] midsDominantFreq;
    float [][] trebleArray;
    float [][] trebleDominantFreq;
    
    PImage fade;
    
    
    
    
    void setup(){
    
      size(1280, 720, P3D);
      smooth();
    
      minim = new Minim(this);
      in = minim.getLineIn(Minim.STEREO, 512);
      fft = new FFT(in.bufferSize(), in.sampleRate());
      fft.logAverages(60, 7);
    
      w = width/fft.avgSize();
      strokeWeight(w);
      strokeCap(SQUARE);  
    
      filter = new Filter();
      freqAndNote = new FreqAndNote();
      freqAndColour = new FreqAndColour();
    
      fade = get(0, 0, width, height);
      //fade = get(-width/2, -height/2, width/2, height/2); 
    
      // A beat detection object song SOUND_ENERGY mode with a sensitivity of 10 milliseconds
      beat = new BeatDetect();
    
    
    
    
    }
    
    void draw(){  
    
    
      beat.detect(in.mix);
    
      background(0);
      tint( 255, 255, 255, 254);
      translate(width/2, height/2);
    
      image(fade, -width/2, -height/2);
      noTint();
    
    
      fft.forward(in.mix);
    
      filter.run(fft);
    
      colorMode(HSB, 100);
    
      bassArray = filter.filter(0, bass, filter.fftArray);
      bassDominantFreq = filter.dominantFreq(bassArray);
      midsArray = filter.filter(bass, mids, filter.fftArray);
      midsDominantFreq = filter.dominantFreq(midsArray);
      trebleArray = filter.filter(mids, treble, filter.fftArray);
      trebleDominantFreq = filter.dominantFreq(trebleArray);
    
    
      filter.paintCircle(bassDominantFreq, 1);
      filter.paintCircle(midsDominantFreq, 2);
      filter.paintCircle(trebleDominantFreq, 3);
      time--;
    
      fade = get(-width/2, -height/2, width/2, height/2);
    
    
    
    }
    

    I also wrote other classes, example Filter, but I think they are unrelated to the issue.

  • edited May 2015

    Double posted by accident.

Sign In or Register to comment.