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

Re : Do you know whether it is possible or not to put minim and video together in one sketch?

$
0
0
Thank you very much!!

Someday I really want to help you if there is any chance  kk

With your adapted code, I made this

- applying the First code to pixels on the (P)Image-

It is...



  1. import ddf.minim.*;
  2. import ddf.minim.analysis.*;

  3.  
  4. int numBalloons = 160*120;
  5. Balloon[] balloons = new Balloon[numBalloons];


  6. Minim minim;
  7. AudioInput voice;
  8. FFT fft;


  9. float dampedVolume;
  10. float damping = 0.1;
  11. float filtering = 100;


  12. PImage pic2;


  13. void setup() {
  14.   size(640, 480);
  15.   smooth();
  16.   
  17.   minim = new Minim(this);
  18.   voice = minim.getLineIn(Minim.STEREO, 2048);
  19.   fft = new FFT(voice.bufferSize(), voice.sampleRate());


  20.   for (int i=0; i<numBalloons; i++) {
  21.     balloons[i] = new Balloon( i , i  );
  22.   }

  23.   pic2 = loadImage("pic2.JPG");
  24.   
  25. }



  26. void draw() {
  27.   
  28.   background(255);
  29.   analyseSound(); // done once, end result = new dampedVolume value
  30.   for (int i=0; i<balloons.length; i++) {
  31.     balloons[i].display();
  32.   }
  33. }

  34.  
  35.  
  36. void analyseSound() {
  37.   
  38.   fft.forward(voice.mix);
  39.   float volume = 0;
  40.   for (int i=0; i<filtering; i++) {
  41.     volume += fft.getBand(i);
  42.   }
  43.   
  44.   volume *= 0.25;
  45.   dampedVolume = dampedVolume + (volume - dampedVolume)*damping;

  46. }

  47.  

  48. void stop() {
  49.   
  50.   voice.close();
  51.   minim.stop();
  52.   super.stop();
  53.   
  54. }

  55.  

  56. class Balloon {

  57.   float x, y;
  58.   color c;
  59.   float scaler;

  60.   
  61.   Balloon(float x, float y) {
  62.     this.x = x;
  63.     this.y = y;

  64.     scaler = random(0.5, 2);
  65.   }

  66.   

  67.   void display() {
  68.  
  69.     noStroke();
  70.     
  71.     for (int x=1; x<160; x++) {
  72.     for (int y=1; y<120; y++) {
  73.       noStroke();
  74.       int imageColor = pic2.width*y+x;
  75.       fill(pic2.pixels[imageColor],30);
  76.       ellipse(x*4, y*4, dampedVolume*scaler, dampedVolume*scaler);
  77.       
  78.     }
  79.   }
  80.     
  81.   }
  82. }








from your adapted code, I just changed and added some things to
match the color and to array to be shown as picture. 
however, It doesn't work too.. -d-
please would you help me for last chance...;;?







Viewing all articles
Browse latest Browse all 1768

Trending Articles