Skip to content

Commit

Permalink
commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
ffd8 committed Jul 23, 2017
0 parents commit b020ec9
Show file tree
Hide file tree
Showing 17 changed files with 2,252 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
distribution
data
lib
web
resources
.DS_Store
.project
.classpath
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
XYScope is a library for Processing to render graphics on a vector display (oscilloscope, laser) by converting them to audio.

...
170 changes: 170 additions & 0 deletions examples/P3D_toroid/P3D_toroid.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
P3D_toroid
Minimal version of Ira Greenbergs Toroid example
for demonstrating P3D points and transformations can be used.
- mouseX » adjust pts
- mouseY » adjust segments
- keyboard » look below for details
https://processing.org/examples/toroid.html
cc teddavis.org 2017
*/

// import and create instance of XYscope
import xyscope.*;
XYscope xy;

// minim is required to generate audio
import ddf.minim.*;


int pts = 40;
float angle = 0;
float radius = 100.0;

// lathe segments
int segments = 20;
float latheAngle = 0;
float latheRadius = 100.0;

//vertices
PVector vertices[], vertices2[];

// for optional helix
boolean isHelix = false;
float helixOffset = 5.0;

void setup() {
size(512, 512, P3D);

// initialize XYscope with default sound out
xy = new XYscope(this);
}

void draw() {
background(0);

// clear waves like refreshing background
xy.clearWaves();

// change shape with mouse
pts = floor(map(mouseX, 0, width, 1, 50));
segments = floor(map(mouseY, 0, height, 1, 50));

//center and spin toroid
pushMatrix();

translate(width/2, height/2, -100);

rotateX(frameCount*PI/150);
rotateY(frameCount*PI/170);
rotateZ(frameCount*PI/90);

// initialize point arrays
vertices = new PVector[pts+1];
vertices2 = new PVector[pts+1];

// fill arrays
for (int i=0; i<=pts; i++) {
vertices[i] = new PVector();
vertices2[i] = new PVector();
vertices[i].x = latheRadius + sin(radians(angle))*radius;
if (isHelix) {
vertices[i].z = cos(radians(angle))*radius-(helixOffset*
segments)/2;
} else {
vertices[i].z = cos(radians(angle))*radius;
}
angle+=360.0/pts;
}

// draw toroid
latheAngle = 0;
for (int i=0; i<=segments; i++) {
xy.beginShape();

for (int j=0; j<=pts; j++) {
if (i>0) {
xy.vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z);
}
vertices2[j].x = cos(radians(latheAngle))*vertices[j].x;
vertices2[j].y = sin(radians(latheAngle))*vertices[j].x;
vertices2[j].z = vertices[j].z;
// optional helix offset
if (isHelix) {
vertices[j].z+=helixOffset;
}
xy.vertex(vertices2[j].x, vertices2[j].y, vertices2[j].z);
}
// create extra rotation for helix
if (isHelix) {
latheAngle+=720.0/segments;
} else {
latheAngle+=360.0/segments;
}
xy.endShape();
}
popMatrix();

// build audio from shapes
xy.buildWaves();

// draw all analytics
xy.drawAll();
}

/*
left/right arrow keys control ellipse detail
up/down arrow keys control segment detail.
'a','s' keys control lathe radius
'z','x' keys control ellipse radius
'w' key toggles between wireframe and solid
'h' key toggles between toroid and helix
*/
void keyPressed() {
if (key == CODED) {
// pts
if (keyCode == UP) {
if (pts<40) {
pts++;
}
} else if (keyCode == DOWN) {
if (pts>3) {
pts--;
}
}
// extrusion length
if (keyCode == LEFT) {
if (segments>3) {
segments--;
}
} else if (keyCode == RIGHT) {
if (segments<80) {
segments++;
}
}
}
// lathe radius
if (key =='a') {
if (latheRadius>0) {
latheRadius--;
}
} else if (key == 's') {
latheRadius++;
}
// ellipse radius
if (key =='z') {
if (radius>10) {
radius--;
}
} else if (key == 'x') {
radius++;
}
// helix
if (key =='h') {
if (isHelix) {
isHelix=false;
} else {
isHelix=true;
}
}
}
50 changes: 50 additions & 0 deletions examples/basic_drawing/basic_drawing.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
basic_drawing
You can draw by simply adding points directly or converted
cc teddavis.org 2017
*/

// import and create instance of XYscope
import xyscope.*;
XYscope xy;

// minim is required to generate audio
import ddf.minim.*;

void setup() {
size(512, 512);

// initialize XYscope with default sound out
xy = new XYscope(this);

// smooth waves to reduce visible points
xy.smoothWaves(true);

// test best smoothAmount, default 12
xy.smoothWavesAmount(12);
}


void draw() {
background(0);

// build audio from shapes
xy.buildWaves();

// draw all analytics
xy.drawAll();
}

void mouseDragged() {
// add point based on width/height
xy.point(mouseX, mouseY);

// add point normalized to 0 – 1
//xy.addPoint(norm(mouseX, 0, width), norm(mouseY, 0, height));
}

void keyPressed() {
if (keyCode == 8) { // DELETE
xy.clearWaves();
}
}
48 changes: 48 additions & 0 deletions examples/basic_shapes/basic_shapes.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/*
basic_shapes
Test this to make sure your setup is up and running.
cc teddavis.org 2017
*/

// import and create instance of XYscope
import xyscope.*;
XYscope xy;

// minim is required to generate audio
import ddf.minim.*;

void setup() {
size(512, 512);

// initialize XYscope with default sound out
xy = new XYscope(this);
}

void draw() {
background(0);

// clear waves like refreshing background
xy.clearWaves();

// set detail of vertex ellipse
xy.ellipseDetail(30);

// use most primative shapes with class instance infront
xy.ellipse(mouseX, mouseY, width/4, width/4);
//xy.rect(mouseX, mouseY, width/4, width/4);
//xy.line(mouseX, mouseY, width/4, width/4);
//xy.point(mouseX, mouseY);


// build audio from shapes
xy.buildWaves();

// draw all analytics
xy.drawAll();

// or specific ones
// xy.drawPath();
// xy.drawWaveform();
// xy.drawWaves();
// xy.drawXY();
}
86 changes: 86 additions & 0 deletions examples/clock/clock.pde
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
clock
Extending Processing Clock example for XYscope
https://processing.org/examples/clock.html
cc teddavis.org 2017
*/

// import and create instance of XYscope
import xyscope.*;
XYscope xy;

// minim is required to generate audio
import ddf.minim.*;

int cx, cy;
float secondsRadius;
float minutesRadius;
float hoursRadius;
float clockDiameter;

void setup() {
size(512, 512);
stroke(255);

// initialize XYscope with default sound out
xy = new XYscope(this);

// for clock
int radius = min(width, height) / 2;
secondsRadius = radius * 0.8;
minutesRadius = radius * 0.60;
hoursRadius = radius * 0.40;
clockDiameter = radius * .8;

cx = width / 2;
cy = height / 2;
}

void draw() {
background(0);

// clear waves like refreshing background
xy.clearWaves();

// Angles for sin() and cos() start at 3 o'clock;
// subtract HALF_PI to make them start at the top
float s = map(second(), 0, 60, 0, TWO_PI) - HALF_PI;
float m = map(minute() + norm(second(), 0, 60), 0, 60, 0, TWO_PI) - HALF_PI;
float h = map(hour() + norm(minute(), 0, 60), 0, 24, 0, TWO_PI * 2) - HALF_PI;

// Draw the hands of the clock
int dots = 10;
float step = map(second(), 0, 59, 1, .1);
for (int i=0; i<int(dots); i++) {
xy.line(cx, cy, cx + cos(s) * secondsRadius*i/dots, cy + sin(s) * secondsRadius*i/dots);
}
for (int i=1; i<dots; i++) {
xy.line(cx, cy, cx + cos(m) * minutesRadius*i/dots, cy + sin(m) * minutesRadius*i/dots);
}
for (int i=1; i<dots; i++) {
xy.line(cx, cy, cx + cos(h) * hoursRadius*i/dots, cy + sin(h) * hoursRadius*i/dots);
}

// Draw the minute ticks
for (int a = 0; a < 360; a+=6) {
float angle = radians(a);
float x = cx + cos(angle) * secondsRadius;
float y = cy + sin(angle) * secondsRadius;
xy.point(x, y);
}

// build audio from shapes
xy.buildWaves();

// draw all analytics
xy.drawAll();
}

// adjust freq() with arrow keys
void keyPressed() {
if (keyCode == 38) { // UP
xy.freq(xy.freq().x+.5);
} else if (keyCode == 40) { // DOWN
xy.freq(xy.freq().x-.5);
}
}
Loading

0 comments on commit b020ec9

Please sign in to comment.