Sound Distance / Tap Distance
in
Core Library Questions
•
7 months ago
Hi Guys,
Please help me !
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.
Any help will be appreciated
- import ddf.minim.*;
- import ddf.minim.analysis.*;
- Minim minim;
- AudioInput in;
- void setup()
- {
- size(512, 200);
- smooth();
- minim = new Minim(this);
- in = minim.getLineIn(Minim.STEREO, 512);
- }
- void draw()
- {
- background(145);
- noStroke();
- for (int i = 0; i < in.bufferSize() - 1; i++)
- {
- fill(255);
- ellipse(100, 100, 50 + in.left.get(i+1)*50, 50 + in.left.get(i+1)*50);
- ellipse(300, 100, 50 + in.right.get(i+1)*50, 50 + in.right.get(i+1)*50);
- if (in.right.get(i)< in.left.get(i))
- {
- text("LEFT", 100, 150);
- }
- else if (in.right.get(i)> in.left.get(i)) {
- text("RIGHT", 300, 150);
- }
- else
- {
- text("MIDDLE", 300, 150);
- }
- }
- }
- void stop()
- {
- in.close();
- minim.stop();
- super.stop();
- }
1