Loading...
Logo
Processing Forum

White noise generator

in General Discussion  •  Other  •  5 months ago  
Hello there!
Very newbie on the world of Processing so please bear with me!

For a video art installation project I need to do the following:

Generate white noise on top of a video (or live webcam feed) based on the number of people in front of the screen/Kinect. The less the people, the more the noise.
So, when 0 people are in front of the Kinect, the video and audio will be unidentifiable/ full of noise. 1 person..less noise. 2 people... even less noise etc. So, only when 5 people are recognized by Kinect will the video and audio be seen and heard properly.

I am way over my head, as the only projects I have done with Processing and Kinect had to do with simple movement recognition and video looping.
So,I am not sure how to start. Do you have any suggestions/tips/code that would help me get going?

Thanks in advance!

Replies(7)

Nothing?? :(
You've show us no attempt at it yourself so far. What do you have working?

Can you display a live feed from your webcam or play a video?
Can you do a static effect?
Can you modify the static effect so it's more and less static-y based on some number?
Can you detect how many people are in your webcam's feed?

We're at a total loss of what you need help with, and we're not about to write the whole thing for you, especially if you have the majority of it working already!
But here is some static:

Copy code
  1. void setup(){
  2.   size(220,220);
  3. }

  4. void draw(){
  5.   loadPixels();
  6.   for( int i=0; i<pixels.length; i++)
  7.     pixels[i] = color( random(255) );
  8.   updatePixels();
  9. }
A little variant of the above code:
Copy code
  1. PImage cam;
  2.  
  3. void setup()
  4. {
  5.   size(640, 480);
  6.   cam = loadImage("H:/Temp/Tree.jpg"); // Use the camera image instead
  7. }
  8.  
  9. void draw()
  10. {
  11.   image(cam, 0, 0);
  12.   int pos = mouseX; // Mouse position is the variable factor
  13.   loadPixels();
  14.   for( int i = 0; i < pixels.length; i++)
  15.   {
  16.     if (random(width) > pos)
  17.     {
  18.       pixels[i] = color(random(256));
  19.     }
  20.   }
  21.   updatePixels();
  22. }

You are right. I should had been more specific.
I have individual codes that do more or less what I need, but I can't combine them:
I know how to load a live feed from my webcam. I know how to create white noise. I know how to detect people.

BUT I can't adjust the noise on the live feed based on the number of people detected.

And where I'm completely at loss is how to do the same with an audio track. The minim library has a whiteNoise class but again, I don't know how to adjust it based on the number of people in front of the webcam.

Thank you very much for your help!
For future generations, this is my code that does (more or less) what I described. 
It is a bit slow and I'm not very happy with the way it produces white noise on the video (it loops a video of static on top of the webcam image and adjusts the transparency based on the number of people), so if you have any suggestions for optimization I would be happy to hear them.
Thanks for you help.

Copy code
  1. import ddf.minim.*;
  2. import ddf.minim.signals.*;
  3. import ddf.minim.ugens.*;
  4. import SimpleOpenNI.*;
  5. import processing.video.*;

  6. Minim minim;
  7. SimpleOpenNI  context;
  8. AudioOutput out;
  9. PinkNoise pn;
  10. Movie mov;

  11. int trackedUserID = 0;
  12. float cur_amp=1;    //the amplitude of the PinkNoise
  13. float opacity=255;  //the opacity of the video


  14. void setup()
  15. {
  16.   context = new SimpleOpenNI(this);
  17.   minim = new Minim (this);
  18.   mov = new Movie(this, "noise.mp4");  //a video with static
  19.   mov.loop();

  20.   // enable depthMap generation 
  21.   context.enableDepth();
  22.   
  23.   // enable camera image generation
  24.   context.enableRGB();
  25.  
  26.   background(200,0,0);
  27.   size(context.rgbWidth(), context.rgbHeight()); 
  28.   context.enableUser(SimpleOpenNI.SKEL_PROFILE_ALL);

  29.     pn = new PinkNoise(cur_amp);
  30.     out = minim.getLineOut();
  31.     out.addSignal(pn);

  32. }

  33. void movieEvent(Movie m) {
  34.   m.read();
  35. }

  36. void draw()
  37. {
  38.   // update the cam
  39.   context.update();
  40.   
  41.   // draw camera
  42.   image(context.rgbImage(),0,0);  //webcam
  43.   image(mov, 0, 0 );      //static movie
  44.   
  45.   tint(255,opacity);
  46.  
  47. }


  48. // -----------------------------------------------------------------
  49. // SimpleOpenNI user events

  50. void onNewUser(int userId)
  51. {
  52.   println("onNewUser - userId: " + userId);

  53.   // if we weren't tracking a user yet, start tracking this one.
  54.   if(trackedUserID == 0) {
  55.     trackedUserID = userId;
  56.   }

  57.   cur_amp= cur_amp - 0.3;  //every time a user is tracked, decrease the amplitude of the PinkNoise
  58.   pn.setAmp(cur_amp);
  59.   out.addSignal(pn);
  60.   opacity=opacity-100;      //every time a user is tracked, decrease the opacity of the video
  61. }

  62. void onLostUser(int userId)
  63. {
  64.   println("onLostUser - userId: " + userId);
  65.    
  66.    //if we lost the user we were tracking, go back to beginning 
  67.   if(userId == trackedUserID) {
  68.     trackedUserID = 0;
  69.    }

  70.     cur_amp= cur_amp + 0.3;   //every time a user is tracked, decrease the amplitude of the PinkNoise
  71.     pn.setAmp(cur_amp);
  72.     out.addSignal(pn);
  73.     opacity=opacity+100;   //every time a user is tracked, decrease the opacity of the video
  74. }
An irritating problem I'm encountering with the above code:

When the opacity drops to 0 (or close to 0) everything gets stuck. Do you know why?