Cant seem to find any examples on how to create a GUI for music visualizer. The GUI I want to create is just a simple one that can browse music from my computer and play music through it. And also has standard buttons like play, pause and stop. Can anyone guide me or show me some examples ??
Creating GUI for music visualizer
[GP4 GuiBuilder] resize Main Window
I created my application using GuiBuilder tool. Now, I need to insert many other controls (button and so on) on Main Window, but It seem impossible resizing it from Guibuilder. Someone can help me?
Thanks a lot.
.
Sprites coordinates (with S4P)
Hello,
It drove me crazy but I finally understood that the "setXY" and the "getXY" methods sets/returns the X and Y coordinates of the center of the sprite. This is similar to the situation when you draw an image with "ImageMode(CENTER)". Is it any possibility to have the (X,Y) coordinates refer to the upper-left corner of the sprite; that is, a "ImageMode(CORNER) option?
Thank you in advance. Hervé
how to improve this codes? (Interative object)
hello, I'm studying for my project with the leap motion and processing. It's my first time to do programming, I'm trying to mix up some of sketches i found and to change little bit. based on https://www.openprocessing.org/collection/2560
whatever, Here is my Question.
1.how to change WordPaint axis? It moves to the left around the edges.
1-1. how to make to move WordPaint automatically on Y axis only? (wants to move like BBQ)
2.Wants to limit space. move inside on 'size'
import peasy.*;
import com.leapmotion.leap.*;
int width = 400;
int height = 400;
float turns = radians(360);
float xRotation = 0;
float yRotation = 0;
float zRotation = 0;
Controller leap = new Controller();
// variables =============================================
// Camera
PeasyCam cam;
int bufferSize = 1256;
int bufferWritePosition = 0;
String[] buffer = new String[bufferSize];
int factorBetweenBoxes = 3;
int factorBetweenLetters = 30;
float angle = 0.0001;
float angleAdd = 0.009;
float jitter;
// letterSpacing: use -6 for 'W' to put more space after the W
int letterSpacing = 0;
// functions =============================================
void setup () {
size (1000, 1000, P3D);
cam = new PeasyCam(this, 2000.0 );
cam.pan(170, 400);
noSmooth();
fill(color(255, 255, 255));
stroke(color(25,25,0));
}
void draw () {
Frame frame = leap.frame();
Hand hand = frame.hands().frontmost();
if ( hand.isValid() )
{
InteractionBox box = frame.interactionBox();
Vector controlPosition = hand.palmPosition();
Vector normalizedPosition = box.normalizePoint(controlPosition, false);
xRotation = turns * normalizedPosition.getX();
yRotation = turns * (1 - normalizedPosition.getY());
zRotation = turns * (1 - normalizedPosition.getZ());
}
background(0);
rotateX(zRotation);
rotateY(xRotation);
rotateZ(yRotation);
translate(width/2, height/8);
if (second() % 2 == 0) {
jitter = random(-0.0001, 0.0001);
}
angle = angle + jitter;
float c = cos(angle/2);
translate(width/2, height/2);
rotate(c);
WordPaint("I HATE YOU");
angle += angleAdd/5;
}
void keyPressed() {
if (key == CODED) {
if (keyCode == UP) {
factorBetweenBoxes-=1;
} else if (keyCode == DOWN) {
factorBetweenBoxes+=1;
}
if (keyCode == LEFT) {
factorBetweenLetters-=1;
} else if (keyCode == RIGHT) {
factorBetweenLetters+=1;
}
} else {
// not coded
if (key == '1') {
if (angleAdd==0.0) {
angleAdd=0.009;
} else {
angleAdd=0.0;
};
} // SPACE
else if (key == 'm') {
angleAdd=0.1;
}
} // else not coded
} // func
void WordPaint(String InputWordOfFunction) {
final int BoxWidth=3;
letterSpacing=0;
for (int i = 0; i < InputWordOfFunction.length(); i = i+1) {
buffer = new String[bufferSize];
bufferWritePosition=0;
letterSpacing=0;
keyPaintHelper(InputWordOfFunction.charAt(i));
for (int j = 0; j < bufferWritePosition; j = j+1) {
for (int k = 0; k < buffer[j].length(); k = k+1) {
if (buffer[j].charAt(k) == '*') {
pushMatrix();
translate((j*factorBetweenBoxes)+(i*factorBetweenLetters)-100+letterSpacing,
300-(k*factorBetweenBoxes)+100,
-1);
// rotateY(0.3); // ;-)
box (BoxWidth, BoxWidth, BoxWidth+BoxWidth+BoxWidth);
popMatrix();
}
}
}
}
}
void keyPaintHelper(char InputKeyOfFunction) {
char k = Character.toUpperCase(InputKeyOfFunction);
letterSpacing=0;
switch(k) {
case 'A':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ****** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * ";
buffer[bufferWritePosition + 3] = " * * ";
buffer[bufferWritePosition + 4] = " ******* ";
buffer[bufferWritePosition + 5] = " ****** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'B':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * * ";
buffer[bufferWritePosition + 3] = " * * * ";
buffer[bufferWritePosition + 4] = " ******* ";
buffer[bufferWritePosition + 5] = " ** ** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'C':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ***** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * ";
buffer[bufferWritePosition + 3] = " * * ";
buffer[bufferWritePosition + 4] = " * * ";
buffer[bufferWritePosition + 5] = " * * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'D':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * ";
buffer[bufferWritePosition + 3] = " ** ** ";
buffer[bufferWritePosition + 4] = " ***** ";
buffer[bufferWritePosition + 5] = " *** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'E':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * * ";
buffer[bufferWritePosition + 3] = " * * * ";
buffer[bufferWritePosition + 4] = " * * * ";
buffer[bufferWritePosition + 5] = " * * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'F':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * ";
buffer[bufferWritePosition + 3] = " * * ";
buffer[bufferWritePosition + 4] = " * * ";
buffer[bufferWritePosition + 5] = " * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'G':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ***** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " ** * * ";
buffer[bufferWritePosition + 3] = " ** * * ";
buffer[bufferWritePosition + 4] = " **** ** ";
buffer[bufferWritePosition + 5] = " **** * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'H':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * ";
buffer[bufferWritePosition + 3] = " * ";
buffer[bufferWritePosition + 4] = " ******* ";
buffer[bufferWritePosition + 5] = " ******* ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'I':
if (thereAreEnoughSlots(6)) {
buffer[bufferWritePosition + 0] = " ";
buffer[bufferWritePosition + 1] = " * * ";
buffer[bufferWritePosition + 2] = " ******* ";
buffer[bufferWritePosition + 3] = " ******* ";
buffer[bufferWritePosition + 4] = " * * ";
buffer[bufferWritePosition + 5] = " ";
bufferWritePosition += 6;
}
break;
case 'J':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ** ";
buffer[bufferWritePosition + 1] = " *** ";
buffer[bufferWritePosition + 2] = " * * ";
buffer[bufferWritePosition + 3] = " ******* ";
buffer[bufferWritePosition + 4] = " ****** ";
buffer[bufferWritePosition + 5] = " * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'K':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " *** ";
buffer[bufferWritePosition + 3] = " ** ** ";
buffer[bufferWritePosition + 4] = " ** ** ";
buffer[bufferWritePosition + 5] = " * * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'L':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * ";
buffer[bufferWritePosition + 3] = " * ";
buffer[bufferWritePosition + 4] = " * ";
buffer[bufferWritePosition + 5] = " * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'M':
if (thereAreEnoughSlots(9)) {
buffer[bufferWritePosition + 0] = " ****** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " **** ";
buffer[bufferWritePosition + 3] = " **** ";
buffer[bufferWritePosition + 4] = " **** ";
buffer[bufferWritePosition + 5] = " **** ";
buffer[bufferWritePosition + 6] = " ******* ";
buffer[bufferWritePosition + 7] = " ****** ";
buffer[bufferWritePosition + 8] = " ";
bufferWritePosition += 9;
}
break;
case 'N':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " ** ";
buffer[bufferWritePosition + 3] = " ** ";
buffer[bufferWritePosition + 4] = " ******* ";
buffer[bufferWritePosition + 5] = " ******* ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'O':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ***** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * ";
buffer[bufferWritePosition + 3] = " * * ";
buffer[bufferWritePosition + 4] = " ******* ";
buffer[bufferWritePosition + 5] = " ***** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'P':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * * ";
buffer[bufferWritePosition + 3] = " * * ";
buffer[bufferWritePosition + 4] = " **** ";
buffer[bufferWritePosition + 5] = " ** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'Q':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ***** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " ** * ";
buffer[bufferWritePosition + 3] = " ** * ";
buffer[bufferWritePosition + 4] = "******** ";
buffer[bufferWritePosition + 5] = "* ***** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'R':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ******* ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " ** * ";
buffer[bufferWritePosition + 3] = " *** * ";
buffer[bufferWritePosition + 4] = " ** **** ";
buffer[bufferWritePosition + 5] = " * ** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'S':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ** ** ";
buffer[bufferWritePosition + 1] = " ** **** ";
buffer[bufferWritePosition + 2] = " * * * ";
buffer[bufferWritePosition + 3] = " * * * ";
buffer[bufferWritePosition + 4] = " **** ** ";
buffer[bufferWritePosition + 5] = " ** ** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'T':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " * ";
buffer[bufferWritePosition + 1] = " * ";
buffer[bufferWritePosition + 2] = " ******* ";
buffer[bufferWritePosition + 3] = " ******* ";
buffer[bufferWritePosition + 4] = " * ";
buffer[bufferWritePosition + 5] = " * ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'U':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ****** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " * ";
buffer[bufferWritePosition + 3] = " * ";
buffer[bufferWritePosition + 4] = " ******* ";
buffer[bufferWritePosition + 5] = " ****** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'V':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ***** ";
buffer[bufferWritePosition + 1] = " ****** ";
buffer[bufferWritePosition + 2] = " ** ";
buffer[bufferWritePosition + 3] = " ** ";
buffer[bufferWritePosition + 4] = " ****** ";
buffer[bufferWritePosition + 5] = " ***** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'W':
letterSpacing=-6 ; // -6 for 'W'
if (thereAreEnoughSlots(9)) {
buffer[bufferWritePosition + 0] = " ****** ";
buffer[bufferWritePosition + 1] = " ******* ";
buffer[bufferWritePosition + 2] = " ** ";
buffer[bufferWritePosition + 3] = " **** ";
buffer[bufferWritePosition + 4] = " **** ";
buffer[bufferWritePosition + 5] = " ** ";
buffer[bufferWritePosition + 6] = " ******* ";
buffer[bufferWritePosition + 7] = " ****** ";
buffer[bufferWritePosition + 8] = " ";
bufferWritePosition += 9;
}
break;
case 'X':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ** ** ";
buffer[bufferWritePosition + 1] = " *** *** ";
buffer[bufferWritePosition + 2] = " *** ";
buffer[bufferWritePosition + 3] = " *** ";
buffer[bufferWritePosition + 4] = " *** *** ";
buffer[bufferWritePosition + 5] = " ** ** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'Y':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " *** ";
buffer[bufferWritePosition + 1] = " **** ";
buffer[bufferWritePosition + 2] = " **** ";
buffer[bufferWritePosition + 3] = " **** ";
buffer[bufferWritePosition + 4] = " **** ";
buffer[bufferWritePosition + 5] = " *** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case 'Z':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " ** * ";
buffer[bufferWritePosition + 1] = " *** * ";
buffer[bufferWritePosition + 2] = " * ** * ";
buffer[bufferWritePosition + 3] = " * ** * ";
buffer[bufferWritePosition + 4] = " * *** ";
buffer[bufferWritePosition + 5] = " * ** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case '.':
if (thereAreEnoughSlots(3)) {
buffer[bufferWritePosition + 0] = " ** ";
buffer[bufferWritePosition + 1] = " ** ";
buffer[bufferWritePosition + 2] = " ";
bufferWritePosition += 3;
}
break;
case ',':
if (thereAreEnoughSlots(4)) {
buffer[bufferWritePosition + 0] = "* ";
buffer[bufferWritePosition + 1] = "*** ";
buffer[bufferWritePosition + 2] = " ** ";
buffer[bufferWritePosition + 3] = " ";
bufferWritePosition += 4;
}
break;
case '\'':
if (thereAreEnoughSlots(3)) {
buffer[bufferWritePosition + 0] = " *** ";
buffer[bufferWritePosition + 1] = " *** ";
buffer[bufferWritePosition + 2] = " ";
bufferWritePosition += 3;
}
break;
case '?':
if (thereAreEnoughSlots(7)) {
buffer[bufferWritePosition + 0] = " * ";
buffer[bufferWritePosition + 1] = " ** ";
buffer[bufferWritePosition + 2] = " * * * ";
buffer[bufferWritePosition + 3] = " * ** * ";
buffer[bufferWritePosition + 4] = " **** ";
buffer[bufferWritePosition + 5] = " ** ";
buffer[bufferWritePosition + 6] = " ";
bufferWritePosition += 7;
}
break;
case '!':
if (thereAreEnoughSlots(4)) {
buffer[bufferWritePosition + 0] = " ";
buffer[bufferWritePosition + 1] = " * ***** ";
buffer[bufferWritePosition + 2] = " * ***** ";
buffer[bufferWritePosition + 3] = " ";
bufferWritePosition += 4;
}
break;
case '-':
if (thereAreEnoughSlots(4)) {
buffer[bufferWritePosition + 0] = " ** ";
buffer[bufferWritePosition + 1] = " ** ";
buffer[bufferWritePosition + 2] = " ** ";
buffer[bufferWritePosition + 3] = " ";
bufferWritePosition += 4;
}
break;
case ' ':
if (thereAreEnoughSlots(4)) {
buffer[bufferWritePosition + 0] = " ";
buffer[bufferWritePosition + 1] = " ";
buffer[bufferWritePosition + 2] = " ";
buffer[bufferWritePosition + 3] = " ";
bufferWritePosition += 4;
}
break;
default:
/*
if (key == CODED) {
if (keyCode == UP) {
timeToWait += 10;
}
else if (keyCode == DOWN && timeToWait >= 10) {
timeToWait -= 10;
if (timeToWait < 0) {
timeToWait = 0;
}
}
}
break;
*/
}
}
boolean thereAreEnoughSlots(int slotsRequired) {
/*
if((bufferSize - bufferWritePosition)
loop() stereo soundfile with processing sound library
Hi. I've just startede using the sound library in Processing 3, but I'm having trouble with it.
Whenever i try to make a stereo soundfile loop it plays once and stops.
I've tried using, .wav, .aif and .mp3 but none of them works in stereo – only in mono.
Anyone found a fix for this?
`import processing.sound.*; SoundFile soundscape;
void setup() { size(640, 360); background(255);
// Load a soundfile from the /data folder of the sketch and play it back soundscape = new SoundFile(this, "soundscape.wav"); soundscape.loop(); }
void draw() { }`
Target VM failed to initialize ?
I tried to run a simple sound example:
import processing.sound.*;
WhiteNoise noise;
void setup() {
size(640, 360);
background(255);
// Create the noise generator
noise = new WhiteNoise(this);
noise.play();}
void draw() {}
But console says:
_# A fatal error has been detected by the Java Runtime Environment:_
_#_
_# Internal Error (0x20474343), pid=8820, tid=0x0000000000001994_
_#_
_# JRE version: Java(TM) SE Runtime Environment (8.0_102-b14) (build 1.8.0_102-b14)_
_# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.102-b14 mixed mode windows-amd64 compressed oops)_
_# Problematic frame:_
_# C [KERNELBASE.dll+0x17788]_
_#_
_# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows_
_#_
_# An error report file with more information is saved as:_
_# R:\processing-3.2.1\hs_err_pid8820.log_
_#_
_# If you would like to submit a bug report, please visit:_
_# http://bugreport.java.com/bugreport/crash.jsp_
_# The crash happened outside the Java Virtual Machine in native code._
_# See problematic frame for where to report the bug._
_#_
_Could not run the sketch (Target VM failed to initialize)._
_For more information, read revisions.txt and Help ? Troubleshooting._
Hay to fix it ?
I use Processing 3.2.1 on WIN10 64bit
How to let my program detect and change frequency?
How do I let my music visualizer detect the frequency of the song when its high it display a smiley face(which i already did) and a frown face when the song is slow with low frequency. I have already able to draw the faces but dont know how to make my code detect the beat and change
import ddf.minim.*;
import ddf.minim.analysis.*;
Minim minim;
AudioPlayer groove;
AudioMetaData meta;
BeatDetect beat;
float yoff = 0.0;
float slowChange;
int screen=0;
void setup()
{
selectInput("Select a file to process:", "fileSelected");
size(640, 360, P3D);
ellipseMode(CENTER);
}
void fileSelected(File selection) {
if (selection == null) {
println("Window was closed or the user hit cancel.");
screen = 1;
} else {
println("User selected " + selection.getAbsolutePath());
minim = new Minim(this);
groove = minim.loadFile(selection.getAbsolutePath(), 2048);
groove.play();
beat = new BeatDetect();
screen = 2;
}
}
void draw()
{
if (screen ==2)
{
background(#7A9EB9);
fill(#FFA00F);
ellipse(320, 180, 300, 300);
beat.detect(groove.mix);
stroke(#40FAFF);
strokeWeight(2);
if(beat.isOnset()==true)
{
fill(#FF0808);
ellipse(270, 120, 60, 60);
fill(#2CE823);
ellipse(370, 120, 90, 90);
}
else
{
fill(#3B0D37);
ellipse(270, 120, 60, 60);
fill(#2754CB);
ellipse(370, 120, 90, 90);
}
if(keyPressed)
{
//sad
noFill();
for(int i = 0; i < groove.bufferSize() - 2; i++){
slowChange = lerp(slowChange, groove.left.get(0), 0.2);
//Left right, up down, (how high)
arc(310, 320 + (30 * slowChange), 100, 300, PI+QUARTER_PI, TWO_PI, OPEN);
}
}
else //happy
{
noFill();
for(int i = 0; i < groove.bufferSize() - 2; i++){
slowChange = lerp(slowChange, groove.left.get(0), 0.2);
arc(320, 180 + (50 * slowChange), 300, 200, 0, PI, OPEN);
}
}
fill(#0220D8);
beginShape();
float xoff = 0;
for (float x = 0; x <= width; x += 10) {
float y = map(noise(xoff, yoff), 10, 1, 0, 300);
vertex(x, y);
xoff += 0.10;
}
yoff += 0.10;
vertex(width, height);
vertex(0, height);
endShape(CLOSE);
}
else
{
rect(10,50,60,20);
}
}
what to consider when trying to get() pixels following a neighbouring pixel with same color val
essentially im trying to find a edge or profile or simply a color line on a white background? something leaning into object detection NOT object recognition, its noticing patterns connecting the dots sorta speak.
we can read the pixels from x&y across the screen but how do i stop searching and start following a pattern with a matching value or close to that value?
ok ok IF this something not done before cuz its hard den i guess ill drop it, or if i have to lean,.....wait hold on why do ppl use xml files to read this pixels in face detection?
Movie playback in Linux Ubuntu 16.04
Hello there.
I'm trying to use the movie examples, but I can't get it to work. I had similar problems when using capture, but installing some libraries related and from gstreamer, I managed it to work. The same is not happening in what regards "Movie". I've found some posts in different forums about this same issue and all were pointing to the installation of libraries, which I did, but no luck so far.
I'm running Ubuntu Studio 16.04. I'm not getting any errors, which make difficult to locate what exactly is not working.
I appreciate any directions given, and if somebody out there is having the same problems, say hello and maybe we can try to find a solution together.
best regards, Gil
Get stroke color of svg drawing
Hi, I'm trying to animate a line drawing. This article helped me to do it: https://forum.processing.org/one/topic/make-a-dot-follow-a-svg-path.html But - I have an SVG with strokes in different colors. How can I read it so the slowly painted image looks like the sourcefile in the end? (The draw order or z-index is also interesting. ) I could not find any explanation how to get and use the stroke-color with geomerative anywhere. Best regards Jens
Questions about draw function
The following is my code.
Since I am using PeasyCam and thenShapes3D for the box, do I need to ask this question in the Libraries area also?
The question I have is that I am only changing 1 box every second or so, but i am having to redraw all 8000 blocks each draw cycle. Is there a way to have draw only redraw the changed objects?
void draw() {
int CPS=20;
pushMatrix();
for (int i = 0; i < CPS; i++) {
for (int j = 0; j < CPS; j++) {
for (int k = 0; k < CPS; k++) {
box[i][j][k].draw();
}
}
}
popMatrix();
cam.rotateY(rotateAngle);
cam.rotateX(rotateAngle);
cam.rotateZ(rotateAngle);
}
how to convert a svg fill to a scribbled stroke path?
Hi! I did a sketch that converts the strokes of a svg image to an animated pencil drawing: https://forum.processing.org/two/discussion/18979/get-stroke-color-of-svg-drawing
It would be great to be able to convert a fill to a scribbled path that looks like drawn by hand, too. Almost similar to a scribble effect in inkscape or illustrator. Once it is a stroke it could also be animated. Did someone already do something similar? What would be a good way of doing that?
Using geomerative it is possible to shift a line over the image, get the intersection points and draw lines first between all first and second, than between all third and fourth intersection points. But it is hard (impossible for me) to get control points for bezier curves this way. Below is a fast sketch with curvevertices, that does not produce a vector path of course. (it does not care about lifting the pen either)
Another approach could be to move a "pentip" over the fill, set vertices and let the "pentip" walk back or in another (random) direction once it leaves the fillarea. Trial and error. Then make a curvy path through the vertices afterwards. (bezier again...). Something like a collision detection for strange shapes with cutouts possibly.
Any ideas, suggestions or perfectly working solutions ;-)? best regards Jens
Here is the mentioned sketch:
import processing.opengl.*;
import geomerative.*;
RShape shp;
RShape cuttingLine = RG.getLine(0 , 0, 0, 0);
int rnd = 50;
void setup() {
size(700, 700);
smooth();
// VERY IMPORTANT: Allways initialize the library before using it
RG.init(this);
//RG.setPolygonizer(RG.ADAPTATIVE);
shp = RG.loadShape("M.svg"); // circle.svg
//shp = RG.centerIn(shp, g);
RG.ignoreStyles();
background(255);
}
void draw() {
fill(255,30);
rect(0,0,width,height);
translate(200, 200);
noFill();
curveTightness(random(0,0.5)); // def 1
beginShape();
stroke(0, 100);
strokeWeight(2);
for (int counter = 0; counter < width; counter = counter + 10+(int)random(rnd)) {
// Draw the shape
//RG.shape(shp);
// Create and draw a cutting line
cuttingLine = RG.getLine(counter+ random(-rnd,rnd) , 0, 0, counter+ random(-rnd,rnd));
//RG.shape(cuttingLine);
// Get the intersection points
RPoint[] ps = shp.getIntersections(cuttingLine);
if (ps != null) {
if (ps.length > 1) {
//line(ps[0].x, ps[0].y, ps[1].x, ps[1].y);
curveVertex(ps[1].x, ps[1].y);
curveVertex(ps[0].x, ps[0].y);
}
}
counter = counter + 10;
cuttingLine = RG.getLine(counter + random(-rnd,rnd), 0, 0, counter + random(-rnd,rnd));
ps = shp.getIntersections(cuttingLine);
if (ps != null) {
if (ps.length > 1) {
curveVertex(ps[0].x, ps[0].y);
curveVertex(ps[1].x, ps[1].y);
}
}
}
endShape();
beginShape();
for (int counter = 0; counter < width; counter = counter + 10 + (int)random(rnd)) {
cuttingLine = RG.getLine(counter+ random(-rnd,rnd), 0, 0, counter+random(-rnd,rnd));
RPoint[] ps = shp.getIntersections(cuttingLine);
if (ps != null) {
if (ps.length > 3) {
curveVertex(ps[3].x, ps[3].y);
curveVertex(ps[2].x, ps[2].y);
}
}
counter = counter + 10;
cuttingLine = RG.getLine(counter+ random(-rnd,rnd), 0, 0, counter+ random(-rnd,rnd));
ps = shp.getIntersections(cuttingLine);
if (ps != null) {
if (ps.length > 3) {
curveVertex(ps[2].x, ps[2].y);
curveVertex(ps[3].x, ps[3].y);
}
}
}
endShape();
}
Here is a simple path made with inkscape to try the sketch (save as "M.svg" in "data"):
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
version="1.1"
id="svg2"
viewBox="0 0 247.85716 239.28571"
height="67.531746mm"
width="69.950798mm">
<defs
id="defs4" />
<metadata
id="metadata7">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
transform="translate(-180.35713,-224.14791)"
id="layer1">
<path
id="path4324"
d="m 186.92312,458.88793 19.1929,-223.24371 60.10408,0.50508 26.76904,68.69037 49.49747,-69.19545 65.65992,0 -3.03046,215.66757 -61.11423,0.50508 -3.53553,-115.15739 -57.07362,53.033 -30.80965,-71.21575 -9.09138,137.88582 z"
style="fill:none;fill-rule:evenodd;stroke:#000000;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" />
</g>
</svg>
Controlp5 Responsiveness Issue
I'm having this issue with all ControlP5 controllers. If I click, the controller activate (ready for me to release and trigger an event), but then if I move at all before releasing, the controller deactivates. If I then release my mouse, the event assigned to the controller is not triggered. The result is that you have to be very careful with your click and release. If you're trying to click and activate aspects of controlp5 quickly, it is very difficult. I would love to figure out how to adjust this and make the controllers more responsive.
Thoughts?
cc @sojamo
Add border/stroke to ControlP5 Controller / Element?
Is it possible to add a border/stroke to a ControlP5 Controller or element? Right now I am trying to render a scrollableList on top of other stuff in my app, but the other stuff is visible through the splits/gaps/cracks of the scrollableList elements.
cc @sojamo
[GP4 GuiBuilder] Change color of Label
Currently, Guibuilder create this row label5.setLocalColorScheme(GCScheme.GREEN_SCHEME) to set color on my label. How can I set a custom color?
composition/mix videos
Hello, I'm wondering if is possible to make a player that is able to mix/fade from one video to another.
looking to translate a elipse within a cube ?
Hello guys once again im back looking to work out something to work around the whole 3D space while keeping track of your own space, i will break that down cuz i know it does sound weird.
Well lets say that i will be using the live feed from a webcam and the cam its facing a room (this room is that cube i speak of in the main question) in this room we will have a cylinder or a ellipse flat on what would be the ground now this ellipse will be spinning at a steady pace/rate and basically i need processing to keep track of the direction and spin of the actually object in front of the cam in that room, finally not only keep track as explain above but as we move in about that room/cube we will keep track of where this spinning obj will be in respective to the camera so that at anytime if the cam was to turn back and look back at the direction where this ob was at we will still see the obj just from another perspective if that makes sense ?
now pretending that we are that cam i speak of and we walk into a festival and we see this carousel spinning as we walk through the festival i know that if i look towards that direction where the carousel was at i know that last time i seen it it was spinning in that direction.
here is what i think we should use to accomplish this task.
- Arduino
- IMU MPU6050 "this should help in keeping track of where the cam is at (in case the cam is not enough to do the trick)
- USB Webcam
as far as the imu goes i believe i can send Processing data from the IMU axis on its accel & gyro values and we should be able to setup some sort of variable which will keep the data from the the imu current state PLUS the current frame of the camera and its POS/LOC xy&z respectfully, basically if this current values from IMU are these numbers then those numbers are for this frame and if the gyro offset from what suppose to be the first frame then it means we moved on that direction and a simple for loop should increment its own internal Cartesian system to keep track of where we are in space (kinda like how watch dog works in arduino programming).
ok now as for the webcam magic, i believe that if we use the following functions from this programs i found i think we can make this program im thinking of.
1)
import peasy.*; //peasyCam
PeasyCam cam; //peasyCam
//set-up
void setup() {
size(800, 600, P3D); //screen size and 3D renderer
cam = new PeasyCam(this, 0, 0, 0, 500); //peasyCam inital lookAt(x,y,x,distance)
cam.setMinimumDistance(200); //minimum camera distance from subject, constrains zoom
cam.setMaximumDistance(500); //maximum camera distance from subject, constrains zoom
} //end setup()
//begin draw loop
void draw() {
background(0); //clears screen
//draw box just for a visual reference in the 3D space
noFill(); //box fill colour
stroke(150, 150, 150, 255); //box line colour
strokeWeight(2); //box line thickness
box(300, 300, 300); //box size (x,y,z)
float[] rotations = cam.getRotations(); //camera rotations in model space (x,y,z)
float lookedAt[]=cam.getLookAt(); //lookedAt coordinates in model space (x,y,z)
float camPos[]=cam.getPosition(); //camera coordinates in model space (x,y,z)
float distance=dist(lookedAt[0], lookedAt[1], lookedAt[2], camPos[0], camPos[1], camPos[2]); //distance from camera to looked at point
//this finds the position of the mouse in model space
float[] mousePos=new float[3]; //mouse coordinates in model space (x,y,z)
pushMatrix();
rotateX(rotations[0]);
rotateY(rotations[1]);
rotateZ(rotations[2]);
mousePos[0]=modelX(mouseX-width/2, mouseY-height/2, distance);
mousePos[1]=modelY(mouseX-width/2, mouseY-height/2, distance);
mousePos[2]=modelZ(mouseX-width/2, mouseY-height/2, distance);
popMatrix();
//vector from camera position to mouse position in model space
PVector camToMouse;
camToMouse=new PVector(mousePos[0]-camPos[0], mousePos[1]-camPos[1], mousePos[2]-camPos[2]);
//vector from camera position to looked at position in model space
PVector camToLookedAt;
camToLookedAt=new PVector(lookedAt[0]-camPos[0], lookedAt[1]-camPos[1], lookedAt[2]-camPos[2]);
//line from origin to 'mirrored' mouse position
line(0,0,0,mousePos[0]+2*camToLookedAt.x,mousePos[1]+2*camToLookedAt.y,mousePos[2]+2*camToLookedAt.z);
//prints distance from mouse position to mirrored mouse position (just to check!)
println(dist(mousePos[0],mousePos[1],mousePos[2],mousePos[0]+2*camToLookedAt.x,mousePos[1]+2*camToLookedAt.y,mousePos[2]+2*camToLookedAt.z));
} //end draw()
2)
import shapes3d.*;
import shapes3d.animation.*;
import shapes3d.utils.*;
import processing.video.*;
import gab.opencv.*;
import processing.video.*;
/*
mix this with cam3D cube
*/
//Movie mov;
Capture mov;
OpenCV opencv;
Shape3D[] shapes;
Box box;
int shapesNumTot = 1;
float angleX, angleY, angleZ;
void setup() {
size(1000, 750, P3D);
mov = new Capture(this, 1280/2, 720/2, "Microsoft LifeCam Front");
opencv = new OpenCV(this, 1280/2, 720/2);
mov.start();
// mov = new Movie(this, "Shots.mp4");
// mov.loop();
textureMode(NORMAL);
shapes = new Shape3D[shapesNumTot];
box = new Box(this);
//box.setTexture(mov, Box.FRONT); // if I try this instead it blocks my PC.
box.setTexture(mov); // this works as expected..
box.setSize(200, 200, 200);
box.drawMode(S3D.TEXTURE);
shapes[0] = box;
}
void draw() {
background(0);
pushMatrix();
camera(0, 0, 300, 0, 0, 0, 0, 1, 0);
// camera(70.0, 35.0, 120.0, 50.0, 50.0, 0.0,
// 0.0, 1.0, 0.0);
angleX += radians(0.913f);
angleY += radians(0.799f);
angleZ += radians(1.213f);
rotateX(angleX);
rotateY(angleY);
rotateZ(angleZ);
for (int i = 0; i < shapesNumTot; i++) {
shapes[i].draw();
}
popMatrix();
}
void movieEvent(Movie m) {
m.read();
}
void captureEvent(Capture c) {
c.read();
}
at this point im not sure what algorithms i should implement or where to tie up the imu varibles coming over serial but i do want to do something similar to how we would use mouseX,mouseY but instead replace those 2 with the variables corresponding to the imu x and y please advise of if anyone knows of a example close to this functions i need that be super!
how to instal a library to run a video
hello, I know there is a stepbystep instruction for that,
but it seems I'm not getting anywhere by my self, so, if anyone can help me, please...
maybe it is because I don't know how to create a 'sketchbook' folder....
I'm trying to run an .mp4 video in a loop, but I keep getting this message:
the package "processing.video" does not exist. You might be missing a library.
No library found for processing.video
Libraries must be installed in a folder named 'libraries' inside the 'sketchbook' folder.**
but I've tried dozens of times to install it... what am I doing wrong?
I have downloaded this processing-video-master.zip from github. and tried to save it all over those folders:
Documents
Processing
examples
libraries
modes
mysketch
tools
nothing seems to work...
please help.
Video speed control and going backwards
Hi, I can not get the Movie.speed() function to control speed or to reverse the direction. I am running the example from the docs
import processing.video.*;
Movie myMovie;
void setup() {
size(200, 200);
frameRate(30);
myMovie = new Movie(this, "totoro.mov");
myMovie.speed(4.0);
myMovie.loop();
}
void draw() {
if (myMovie.available()) {
myMovie.read();
}
image(myMovie, 0, 0);
}
but the player seems to ignore the call to Movie.speed() does it have to do with the video format, is there a video format that would work?
Thanks for any help sergio
How to pan an audiosignal in minim?
Hello, I see that certain AudioSignals like SawWave are able to do setPan because they extend? implement? Oscillator . I have my own class that implements AudioSignal, but setPan doesn't exist. If I want my audiosignals to be able to pan, whats the easiest way to get panning to work? do i have to extend the oscillator interface and copy whatever code exists there? or is there some other way to make audiosignals pan