I am the person who love to have fun in doing stuffs and achieving them, more likely to get succeed. And even if I don’t get succeed, still I have an enjoyable time.
This code is working well in java mode but when I tried uploading it on openprocessing.org it doesn't show any thing other than background color so I tried tested it in javascript mode and but still it is not working.
I am trying to develop a Paint music application. This is how it should work, when you draw any stroke it should play the sound associated with the color and should play continuously. Every time when you make a different color stroke it should play some piece of sound. Currnelty I am only using primary colors but needed to be extend for more colors.
Here, I am not using any external file (any wav or mp3 but this is the idea) and using sine wave sound generator function. I have tried to do the same but it is not working properly
I also wanted to control the volume but it not happening too.
import ddf.minim.*;
import ddf.minim.signals.*;
//----------------------------
ArrayList<Dots> poop;
Minim minim;
AudioOutput out;
SineWave sine;
//----------------------------
color c;
int thickness=1;
float Low = 261;
float High = 523;
//----------------------------
void setup()
{
size(500, 300);
smooth();
poop = new ArrayList();
frameRate(123);
//-------------------------
minim = new Minim(this);
out = minim.getLineOut(Minim.STEREO);// get a line out from Minim, default bufferSize is 1024, default sample rate is 44100, bit depth is 16
//-------------------------
sine = new SineWave(440, 0.0, out.sampleRate());// create a sine wave Oscillator, set to 440 Hz, at 0.5 amplitude, sample rate from line out
sine.portamento(10);// set the portamento speed on the oscillator to 200 milliseconds
out.addSignal(sine); // add the oscillator to the line out
//-------------------------
}
void draw()
{
background(255);
for (int k=0;k<poop.size();k++)
{
Dots dot = (Dots) poop.get(k);
dot.display();
}
loadPixels();
for (int i=0;i<width;i++)
{
for (int j=0;j<height;j++)
{
int index = i + j*width;
color findColor = pixels[index];
float r = red(findColor);
float g = green(findColor);
float b = blue(findColor);
if (r<255) {
color fc1 = get(i, j);
float freq1 = map(hue(fc1), 0, 255, Low, High);
sine.setFreq(freq1);
sine.setAmp(thickness/100);
}
if ( g<255) {
color fc2 = get(i, j);
float freq2 = map(hue(fc2), 0, 255, Low, High);
sine.setFreq(freq2);
sine.setAmp(thickness/100);
}
if ( b<255) {
color fc3 = get(i, j);
float freq3 = map(hue(fc3), 0, 255, Low, High);
sine.setFreq(freq3);
sine.setAmp(thickness/100);
}
else {
sine.setAmp(0.0);
}
}
}
// out.setVolume(0.5);
}
void keyPressed()
{
if (key=='r' || key == 'R') c = color(255, 0, 0);
if (key=='g' || key == 'G') c = color(0, 255, 0);
if (key=='b' || key == 'B') c = color(0, 0, 255);
if (thickness<1) thickness=1;
if (key=='x' || key == 'X') thickness++;
if (key=='z' || key == 'Z') thickness--;
}
void mouseDragged()
{
Dots D = new Dots(mouseX, mouseY, pmouseX, pmouseY, c, thickness);
poop.add(D);
}
class Dots {
int x, y, px, py;
private int thickness;
color col;
Dots(int _x, int _y, int _px, int _py, color _c, int _thickness)
I have wrote this code and of course it is inspired from someone's code. Here, I am facing some of these problems
1. When I increase the speed of movements of the points, they appear as a small line parallel to line of motion.
2. These points get connect via line if they come closer to a certain distance and it should happen like this with all the points but somewhat it is not happening.
please tell me reason or any logic fail. I want to learn these things..... giving or fixing code help me but wont tell me the problem so please try explaining the problem.
Thanks
ArrayList poop;
boolean flag=false;
int distance=50;
void setup()
{
size(600,600);
smooth();
poop = new ArrayList();
for (int i=0;i<100;i++)
{
Particle P = new Particle();
poop.add(P);
}
}
void mousePressed()
{
}
void draw()
{
background(20);
for (int i=0;i<poop.size();i++)
{
Particle Pn1 = (Particle) poop.get(i);
// Pn1.display();
for (int j = i + 1; j < poop.size(); j++) {
Particle Pn2 = (Particle) poop.get(j);
Pn2.display();
if (dist(Pn1.x, Pn1.y, Pn2.x, Pn2.y)< distance)
{
for (int k = j + 1; k < poop.size(); k++) {
Particle Pn3 = (Particle) poop.get(k);
Pn3.display();
if (dist(Pn3.x, Pn3.y, Pn2.x, Pn2.y)< distance) {
if (flag) {
stroke(255, 10);
fill(Pn3.c,95); // method to access the class property
Here I have written a code which should detect the size of the shape drawn on the screen and draw rectangle around it but the problem is it only saves the min value of the (x,y) coordinates of the shape and doesn't save the max value of coordinates instead it saves the last coordinates of the mouse.
I want to add one more feature in my current drawing application. I want to draw a closed shape with mouse and paint it. Please don confuse it with filling the shape.
I need help creating an erase for the this drawing application. It is a simple code and you can see that I have used PGraphics layer where I am drawing which is transparent too. So question is how to create an eraser for this transparent layer ?
I know I can do this other way around but
I just want it in this way.
I am creating a clickable menu which I later put into an Android phone. Here, I have created 4 dummy menu and each menu has its own images and sounds ( currently sound is not there). So the problem is when I click on button '0' it clicks button '0' zero of every menu and click until it gets the last menu. So when I click the button '0' of first menu1 it should go to the menu2 but it goes to menu4.
In every menu button number "10" is set to prev menu but it is also not working and button 11 is set for MAIN MENU which is working fine. Each button will lead to some MENU so here when you click on button '0' it open another menu and if you click on button '0' of this menu it will open some other menu and so on.
If you are not able to understand my problem you can simply try the application and try clicking on the button zero.
I know there is some logic problem which I am not able to see so please help me to fix this. It is really urgent
----------------------------------------------
P.S. I know I could have create the class of the "MENU" but I didn't do because I wanted to make it simple and understandable.
Is there any way to use diewald_CV_kit library with SimpleOpenNI ? Currently the examples comes along with the library work with dLib.freekinect but I want them use with SimpleOpenNI.
I have understood the basics of Processing programming and I can do quit a good programming now but my question how to program effectively in processing.
How to make program short, easy and effective using various functions and techniques?
I have seen some people use processing very effectively using various unknown (I would say hidden) functions and techniques. Can any one of you brings those techniques to us (noobs) ? or suggests some tutorials
Is it possible to send images from the webcam over network or LAN to other computer like a video chat? Please help me.. in my other post I have asked for help creating Video chat application but didn't get any helpful reply.
It should splash color on the PGraphics but it not happening. It is continuously throwing Null point exception error... it uses NITE click gesture to throw color ...please help
import SimpleOpenNI.*;
SimpleOpenNI context;
PGraphics topLayer;
boolean handsTrackFlag = false;
PVector handVec = new PVector();
PVector handVec2D = new PVector();//just for drawing
String lastGesture = "";
float lastZ = 0;
boolean isPushing,wasPushing;
float yourClickThreshold = 20;//set this up as you see fit for your interaction
void setup(){
size(640,480);
context = new SimpleOpenNI(this);
context.enableDepth();
// enable hands + gesture generation
context.enableGesture();
context.enableHands();
// add focus gestures / here i do have some problems on the mac, i only recognize raiseHand ? Maybe cpu performance ?
I have problem of unifying the two code into one. As I have frame-difference code and blob detection code. I am trying to make finger detection more robust using these two techniques.
I have thought that if I could apply the blob detection on the frame that is left after the frame-subtraction but it is not working. Can anyone of you give me some insight on my code ...Sometime I do lot of stupid things and got blind not to see them.
I am using SimpleOpenNi with processing 2.08b. I want to know how to calculate the distance between two objects ? Here in this case I want to calculate the distance between hand and a object.
The first picture shows that depthmap of the scene
Actually what I want to do is that if somehow I can check if I am touching any object or not. Here what I did, I have hand coordinates ( handPosition.x, handPosition.y, handPosition.z) and from the rgb frame ( frame = kinect.rgbImage(); ) I am detecting the depth of the pixel at (handPosition.x, handPosition.y)
-------------------------------------------
// I have a frame size(640,480);
-----------------------
int[] depthvalues = kinect.depth();
int loc = handPosition.x + handPosition.y * 480
int mm = depthvalues[loc];
-------------
if ( abs(mm - handPosition.z ) < threshold )
{
println("You have touched an object");
}
------------------
Problems: handPosition.z gives me some 3 digit values where as mm gives me some 6 digit values. I dont understand why this is happening?
Somewhere I read the handPosition does not repsensts real depth coordinates. it has been converted using this fucntion " convertRealWorldToProjective "
I know I ask a lot of question
but this one really irritating me
. I have googled a lot but couldn't find any solution.
Question is
I got a code from somewhere which can track any color picked from a video by mouse clicking and draw a ellipse filled with it. I want this is to use as tool to draw images over the video.
I have come across through the anaglyph 3D processing application on www.openprocessing.org . I'av gone through the codes of those application but didnt understand anything.
Can anyone help me out step by step making a simple anaglyph 3d box in processing without any rotation and translation?
I have seen their codes where some used PGraphics some does without PGgraphics and it makes thing difficult to understand.
I wanted to make an water balloons like the real one ( if possible) . It should be responsive I mean when you squeeze with mouse, it should change its shape and restore back after releasing it.
Here first time I am using minim library for audio input analysis.I don't know if it would serve my purpose at all. I am taking the stereo audio input from laptop microphones (left and right channel both).
what I want to do
I want to calculate the distance of the tap on my laptop screen and also want to detect if I have tapped on the right side or the left side of the screen.
Basically I am trying to make a poor's man touch screen detecting sound tap on the screen.