cleaned up, added record button
This commit is contained in:
@@ -1,2 +1,2 @@
|
|||||||
//globals
|
//globals
|
||||||
uptime = 116625522
|
uptime = 116626470
|
||||||
|
|||||||
24
effects.pde
24
effects.pde
@@ -1,19 +1,3 @@
|
|||||||
final static int SINE = 0; //add 0.25 to phase to get cos
|
|
||||||
final static int SAWTOOTH = 1;
|
|
||||||
final static int SAWTOOTHINVERSE = 2;
|
|
||||||
final static int SQUARE = 3; //switches between -1 and 1, that's all
|
|
||||||
final static int TRIANGLE = 4;
|
|
||||||
final static int TAN = 5;
|
|
||||||
final static int TANINVERSE = 6;
|
|
||||||
final static int RAMP = 7; //line for half the sequence up to 1, then stay at 1 for the other half
|
|
||||||
final static int RAMPINVERSE = 8; //line for half the sequence up to 1, then stay at 1 for the other half
|
|
||||||
final static int RAMPUPDOWN = 9; //line up, stay, line down, stay
|
|
||||||
final static int RANDOM = 10;
|
|
||||||
|
|
||||||
final static int RANDOMIZE_ALL = 777; //not for wave-generation. meant for low frequency oscillator that calls a function after every beat
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
||||||
ASDFPIXELSORT
|
ASDFPIXELSORT
|
||||||
@@ -23,16 +7,16 @@ final static int RANDOMIZE_ALL = 777; //not for wave-generation. meant for low f
|
|||||||
class ASDFPIXELSORT extends Shader {
|
class ASDFPIXELSORT extends Shader {
|
||||||
ASDFPIXELSORT() {
|
ASDFPIXELSORT() {
|
||||||
name = "fxASDFPixelSort";
|
name = "fxASDFPixelSort";
|
||||||
params.add(new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANGLE}));
|
params.add(new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||||
params.add(new Param("mode", INTVAL, 0, 2, new int[]{RANDOM}));
|
params.add(new Param("mode", INTVAL, 0, 2, new int[]{RANDOM}));
|
||||||
}
|
}
|
||||||
int previousMode;
|
int previousMode;
|
||||||
|
|
||||||
void apply() {
|
void apply() {
|
||||||
if (previousMode != int(params.get(1).value)) {
|
if (previousMode != int(params.get(1).value)) {
|
||||||
if (params.get(1).value == 0) changeParam(0, new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANGLE}));
|
if (params.get(1).value == 0) changeParam(0, new Param("black", INTVAL, -17000000, -2000000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||||
if (params.get(1).value == 1) changeParam(0, new Param("brightness", INTVAL, 0, 200, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANGLE}));
|
if (params.get(1).value == 1) changeParam(0, new Param("brightness", INTVAL, 0, 200, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||||
if (params.get(1).value == 2) changeParam(0, new Param("white", INTVAL, -15000000, -700000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANGLE}));
|
if (params.get(1).value == 2) changeParam(0, new Param("white", INTVAL, -15000000, -700000, new int[]{SINE, SAWTOOTH, RAMPUPDOWN, TAN, TANINVERSE, TRIANG}));
|
||||||
}
|
}
|
||||||
previousMode = int(params.get(1).value);
|
previousMode = int(params.get(1).value);
|
||||||
row = 0;
|
row = 0;
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import drop.*;
|
import drop.*;
|
||||||
import test.*;
|
|
||||||
import controlP5.*;
|
import controlP5.*;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
@@ -65,7 +64,7 @@ void setup() {
|
|||||||
String[] args = {"SecondFrame"};
|
String[] args = {"SecondFrame"};
|
||||||
gui = new SecondApplet();
|
gui = new SecondApplet();
|
||||||
PApplet.runSketch(args, gui);
|
PApplet.runSketch(args, gui);
|
||||||
|
|
||||||
renderer = createGraphics(width, height);
|
renderer = createGraphics(width, height);
|
||||||
viewport = createImage(renderer.width, renderer.height, ARGB);
|
viewport = createImage(renderer.width, renderer.height, ARGB);
|
||||||
sourceManager = new SourceManager();
|
sourceManager = new SourceManager();
|
||||||
@@ -79,7 +78,7 @@ void draw() {
|
|||||||
sourceManager.update(); //will write some image to the renderer
|
sourceManager.update(); //will write some image to the renderer
|
||||||
sourceManager.setSource();
|
sourceManager.setSource();
|
||||||
gui.shaderManager.applyShader(); //boolean animate (iterative calcs), boolean apply (draw)
|
gui.shaderManager.applyShader(); //boolean animate (iterative calcs), boolean apply (draw)
|
||||||
|
|
||||||
background(color(0));
|
background(color(0));
|
||||||
imageMode(CENTER);
|
imageMode(CENTER);
|
||||||
viewport = renderer.get();
|
viewport = renderer.get();
|
||||||
@@ -91,7 +90,6 @@ void draw() {
|
|||||||
if (viewport.height > height) viewport.resize(0, height);
|
if (viewport.height > height) viewport.resize(0, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//sourceManager.setSource();
|
//sourceManager.setSource();
|
||||||
image(viewport, width/2, height/2);
|
image(viewport, width/2, height/2);
|
||||||
|
|
||||||
@@ -104,5 +102,15 @@ void draw() {
|
|||||||
|
|
||||||
if (recording) {
|
if (recording) {
|
||||||
snapshot();
|
snapshot();
|
||||||
|
fill(#ff0000);
|
||||||
|
ellipse(width-100, height-100, 30, 30);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void snapshot() {
|
||||||
|
frameName = str(uptime);
|
||||||
|
renderer.save(dataPath("")+"/snapshots/" + frameName + ".png");
|
||||||
|
saveData[1] = "uptime = " + frameName;
|
||||||
|
println("Rendered " + frameName + ".png at " + dataPath("")+"/snapshots/ with a resolution of " + renderer.width + " x " + renderer.height);
|
||||||
|
saveStrings(dataPath("saves.sav"), saveData);
|
||||||
|
}
|
||||||
|
|||||||
120
oscillator.pde
Normal file
120
oscillator.pde
Normal file
@@ -0,0 +1,120 @@
|
|||||||
|
class Oscillator {
|
||||||
|
float speed; //in milliseconds
|
||||||
|
int spawnMillis;
|
||||||
|
int pauseMillis;
|
||||||
|
int beatCount = 0;
|
||||||
|
int mode;
|
||||||
|
|
||||||
|
//int function; //function to be called by bang-oscillators
|
||||||
|
float position; // between 0 and TWO_PI
|
||||||
|
float value; // is returned, constrained between "low" and "high"
|
||||||
|
float low = -1.0;
|
||||||
|
float high = 1.0;
|
||||||
|
boolean playing, pause, valInvert;
|
||||||
|
|
||||||
|
Oscillator(float bpm_) {
|
||||||
|
bpm(bpm_);
|
||||||
|
play();
|
||||||
|
}
|
||||||
|
|
||||||
|
void amplitude(float low_, float high_) {
|
||||||
|
low = low_;
|
||||||
|
high = high_;
|
||||||
|
}
|
||||||
|
void frequency(float hertz_) {
|
||||||
|
speed = 1000/hertz_;
|
||||||
|
}
|
||||||
|
void bpm(float bpm_) {
|
||||||
|
speed = int(60 / bpm_ * 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
void play() {
|
||||||
|
if (pause) {
|
||||||
|
float pauseTime = millis() - pauseMillis;
|
||||||
|
spawnMillis += pauseTime;
|
||||||
|
pause = false;
|
||||||
|
} else if (!playing) {
|
||||||
|
spawnMillis = millis();
|
||||||
|
}
|
||||||
|
playing = true;
|
||||||
|
}
|
||||||
|
void pause() {
|
||||||
|
if (playing) {
|
||||||
|
pauseMillis = millis();
|
||||||
|
pause = true;
|
||||||
|
playing = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
void stop() {
|
||||||
|
beatCount = 0;
|
||||||
|
playing = false;
|
||||||
|
value = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void update() {
|
||||||
|
if (playing) {
|
||||||
|
while (millis() - spawnMillis > speed*beatCount) {
|
||||||
|
beatCount++;
|
||||||
|
}
|
||||||
|
|
||||||
|
float millisToBeat = millis() - spawnMillis - (speed*beatCount);
|
||||||
|
position = map(-millisToBeat, speed, 0, 0, TWO_PI);
|
||||||
|
|
||||||
|
switch(mode) {
|
||||||
|
case(SINE):
|
||||||
|
value = sin(position);
|
||||||
|
break;
|
||||||
|
case(SAWTOOTH):
|
||||||
|
value = ((position % TWO_PI)-PI)/PI;
|
||||||
|
break;
|
||||||
|
case(SAWTOOTHINVERSE):
|
||||||
|
value = (((position % TWO_PI)-PI)/PI)*-1;
|
||||||
|
break;
|
||||||
|
case(SQUAR):
|
||||||
|
value = sin(position > PI ? 1 : -1);
|
||||||
|
break;
|
||||||
|
case(TRIANG):
|
||||||
|
value = position-PI < 0 ? ((position % TWO_PI)-PI)/PI : (((position % TWO_PI)-PI)/PI)*-1;
|
||||||
|
value+=0.5;
|
||||||
|
value*=2;
|
||||||
|
if (value == 3.0) value = -1;
|
||||||
|
break;
|
||||||
|
case(TAN):
|
||||||
|
value = tan(position);
|
||||||
|
break;
|
||||||
|
case(TANINVERSE):
|
||||||
|
value = tan(position)*-1;
|
||||||
|
break;
|
||||||
|
case(RAMP):
|
||||||
|
value = sin(position) > 0 ? ((position % TWO_PI)-PI)/PI : 0;
|
||||||
|
value+=0.5;
|
||||||
|
value*=2;
|
||||||
|
if (value == 3.0) value = -1;
|
||||||
|
break;
|
||||||
|
case(RAMPINVERSE):
|
||||||
|
value = sin(position) > 0 ? ((position % TWO_PI)-PI)/PI : 0;
|
||||||
|
value+=0.5;
|
||||||
|
value*=2;
|
||||||
|
if (value == 3.0) value = -1;
|
||||||
|
value = value*-1;
|
||||||
|
break;
|
||||||
|
case(RAMPUPDOWN):
|
||||||
|
if (sin(position) <= -1.6666666666) value = -1.6666666666;
|
||||||
|
else if (sin(position) < 1.6666666666 && sin(position) > -1.6666666666) value = sin(position);
|
||||||
|
else if (sin(position) >= 1.6666666666) value = 1.6666666666;
|
||||||
|
value *= 1.5;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
value = constrain(value, -1.0, 1.0);
|
||||||
|
|
||||||
|
value = map(value, -1.0, 1.0, low, high);
|
||||||
|
//value = valInvert? map(value, 1.0, -1.0, low, high) : map(value, -1.0, 1.0, low, high);
|
||||||
|
}
|
||||||
|
|
||||||
|
//fill(0);
|
||||||
|
//ellipse(inc, height/2+value*height/4, 1, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
301
secondapplet.pde
301
secondapplet.pde
@@ -1,51 +1,52 @@
|
|||||||
|
//contains the GUI (ie CP5) in the secondapplet. also contains 3 classes: shaderManager, Brick and Slider
|
||||||
|
|
||||||
PImage bin;
|
PImage bin;
|
||||||
final static int INTVAL = 100;
|
|
||||||
final static int FLOATVAL = 101;
|
|
||||||
|
|
||||||
public class SecondApplet extends PApplet {
|
public class SecondApplet extends PApplet {
|
||||||
ControlP5 cp5;
|
ControlP5 cp5;
|
||||||
|
|
||||||
final static int SINE = 0; //add 0.25 to phase to get cos
|
|
||||||
final static int SAWTOOTH = 1;
|
|
||||||
final static int SAWTOOTHINVERSE = 2;
|
|
||||||
final static int SQUARE = 3; //switches between -1 and 1, that's all
|
|
||||||
final static int TRIANGLE = 4;
|
|
||||||
final static int TAN = 5;
|
|
||||||
final static int TANINVERSE = 6;
|
|
||||||
final static int RAMP = 7; //line for half the sequence up to 1, then stay at 1 for the other half
|
|
||||||
final static int RAMPINVERSE = 8; //line for half the sequence up to 1, then stay at 1 for the other half
|
|
||||||
final static int RAMPUPDOWN = 9; //line up, stay, line down, stay
|
|
||||||
final static int RANDOM = 10;
|
|
||||||
final static int RANDOMIZE_ALL = 777; //not for wave-generation. meant for low frequency oscillator that calls a function after every beat
|
|
||||||
String availableFx[] = {
|
|
||||||
"fxASDFPixelSort",
|
|
||||||
"fxDistorter",
|
|
||||||
"fxWahWah",
|
|
||||||
"fxAuEcho",
|
|
||||||
"fxPhaser",
|
|
||||||
"fxWZIP",
|
|
||||||
"fxDarker",
|
|
||||||
"fxBrighter",
|
|
||||||
"fxMove",
|
|
||||||
"fxScale",
|
|
||||||
"fxEpilepsy",
|
|
||||||
"fxPosterize",
|
|
||||||
"fxCopyZoom",
|
|
||||||
"fxDual",
|
|
||||||
"fxScanker",
|
|
||||||
"fxPixelSort",
|
|
||||||
"fxHSB",
|
|
||||||
"fxEcho",
|
|
||||||
"fxSubtleSort",
|
|
||||||
"fxBlackWhite",
|
|
||||||
"fxDrawGenerative",
|
|
||||||
"fxDrawStrokes",
|
|
||||||
"fxFM",
|
|
||||||
"fxGrauzone",
|
|
||||||
"fxSlitScan"
|
|
||||||
};
|
|
||||||
|
|
||||||
shaderManager shaderManager = new shaderManager();
|
shaderManager shaderManager = new shaderManager();
|
||||||
|
ArrayList<Shader> shaderList = new ArrayList<Shader>();
|
||||||
|
ArrayList<Brick> bricks = new ArrayList<Brick>();
|
||||||
|
ArrayList<Slider> slider = new ArrayList<Slider>(); //brick
|
||||||
|
|
||||||
|
public void settings() {
|
||||||
|
size(275, 500);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setup() {
|
||||||
|
surface.setLocation(285, 240);
|
||||||
|
List l = Arrays.asList(availableFx);
|
||||||
|
cp5 = new ControlP5(this);
|
||||||
|
cp5.addScrollableList("")
|
||||||
|
.setPosition(10, height-110)
|
||||||
|
.setSize(80, 100)
|
||||||
|
.setBarHeight(0)
|
||||||
|
.setItemHeight(20)
|
||||||
|
.plugTo(this, "CP5_listActions")
|
||||||
|
.addItems(l)
|
||||||
|
.setType(ControlP5.LIST);
|
||||||
|
cp5.addToggle("rec")
|
||||||
|
.setPosition(100, height-50)
|
||||||
|
.setSize(20,20)
|
||||||
|
.plugTo(this, "CP5_recordAction");
|
||||||
|
}
|
||||||
|
|
||||||
|
void CP5_recordAction(){
|
||||||
|
recording = !recording;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void draw() {
|
||||||
|
background(68, 68, 68);
|
||||||
|
image(bin, width-55, height-85, 40, 40);
|
||||||
|
stroke(255);
|
||||||
|
strokeWeight(1);
|
||||||
|
line(0, height-120, width, height-120);
|
||||||
|
for (int i = 0; i < shaderList.size(); i++) {
|
||||||
|
bricks.get(i).update();
|
||||||
|
bricks.get(i).display();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
class shaderManager {
|
class shaderManager {
|
||||||
void addShader(Shader shader) {
|
void addShader(Shader shader) {
|
||||||
shaderList.add(shader);
|
shaderList.add(shader);
|
||||||
@@ -59,8 +60,8 @@ public class SecondApplet extends PApplet {
|
|||||||
Collections.swap(bricks, pos1, pos2);
|
Collections.swap(bricks, pos1, pos2);
|
||||||
shaderList.get(pos1).pos = pos1;
|
shaderList.get(pos1).pos = pos1;
|
||||||
shaderList.get(pos2).pos = pos2;
|
shaderList.get(pos2).pos = pos2;
|
||||||
bricks.get(pos1).setPosition(pos1);
|
bricks.get(pos1).pos = pos1;
|
||||||
bricks.get(pos2).setPosition(pos2);
|
bricks.get(pos2).pos = pos2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
void removeShader(int pos) {
|
void removeShader(int pos) {
|
||||||
@@ -68,7 +69,7 @@ public class SecondApplet extends PApplet {
|
|||||||
shaderList.remove(pos);
|
shaderList.remove(pos);
|
||||||
bricks.remove(pos);
|
bricks.remove(pos);
|
||||||
for (int i = shaderList.size()-1; i > -1; i--) {
|
for (int i = shaderList.size()-1; i > -1; i--) {
|
||||||
bricks.get(i).setPosition(i);
|
bricks.get(i).pos = i;
|
||||||
shaderList.get(i).pos = i;
|
shaderList.get(i).pos = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -82,19 +83,16 @@ public class SecondApplet extends PApplet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<Shader> shaderList = new ArrayList<Shader>();
|
|
||||||
ArrayList<Brick> bricks = new ArrayList<Brick>();
|
|
||||||
|
|
||||||
class Brick {
|
class Brick {
|
||||||
ArrayList<Slider> slider = new ArrayList<Slider>();
|
ArrayList<Slider> slider = new ArrayList<Slider>();
|
||||||
ArrayList<Param> params = new ArrayList<Param>();
|
ArrayList<Param> params = new ArrayList<Param>();
|
||||||
int position;
|
int pos;
|
||||||
|
|
||||||
Brick(int position_, ArrayList params_) {
|
Brick(int pos_, ArrayList params_) {
|
||||||
position = position_;
|
pos = pos_;
|
||||||
params = params_;
|
params = params_;
|
||||||
for (int i = 0; i < params.size(); i++) {
|
for (int i = 0; i < params.size(); i++) {
|
||||||
slider.add(new Slider(10, 10+20*i+position*75, 230, 12, params.get(i).minValue, params.get(i).maxValue, params.get(i).name, params.get(i).type)); //add possible waves to slider
|
slider.add(new Slider(10, 10+20*i+pos*75, 230, 12, params.get(i).minValue, params.get(i).maxValue, params.get(i).name, params.get(i).type)); //add possible waves to slider
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,8 +117,6 @@ public class SecondApplet extends PApplet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ArrayList<Slider> slider;
|
|
||||||
int pressedSlider = -1;
|
int pressedSlider = -1;
|
||||||
|
|
||||||
class Slider {
|
class Slider {
|
||||||
@@ -221,64 +217,8 @@ public class SecondApplet extends PApplet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public void settings() {
|
|
||||||
size(275, 500);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setup() {
|
|
||||||
slider = new ArrayList<Slider>(); //brick
|
|
||||||
|
|
||||||
cp5 = new ControlP5(this);
|
|
||||||
List l = Arrays.asList(availableFx);
|
|
||||||
|
|
||||||
|
|
||||||
cp5.addScrollableList("")
|
|
||||||
.setPosition(10, height-110)
|
|
||||||
.setSize(80, 100)
|
|
||||||
.setBarHeight(0)
|
|
||||||
.setItemHeight(20)
|
|
||||||
.plugTo(this, "liste")
|
|
||||||
.addItems(l)
|
|
||||||
.setType(ControlP5.LIST);
|
|
||||||
|
|
||||||
|
|
||||||
surface.setLocation(285, 240);
|
|
||||||
//surface.setSize(1000,100);
|
|
||||||
|
|
||||||
//testslider = new Slider(10, 10, 230, 15, 0, 5, "testslider", INTVAL);
|
|
||||||
|
|
||||||
randomizer = new Oscillator(5); //every 12 seconds;
|
|
||||||
randomizer.mode = RANDOMIZE_ALL;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public void draw() {
|
|
||||||
background(68, 68, 68);
|
|
||||||
image(bin, width-55, height-85, 40, 40);
|
|
||||||
stroke(255);
|
|
||||||
strokeWeight(1);
|
|
||||||
line(0, height-120, width, height-120);
|
|
||||||
|
|
||||||
randomizer.update();
|
|
||||||
|
|
||||||
//this goes to bricks
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
for (int i = 0; i < shaderList.size(); i++) {
|
|
||||||
bricks.get(i).update();
|
|
||||||
bricks.get(i).display();
|
|
||||||
|
|
||||||
//for (int j = 0; j < fxList.get(i).shader.params.size(); j++) {
|
|
||||||
//Slider s = fxList.get(i).shader.params.get(i);
|
|
||||||
//}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//CP5
|
//CP5
|
||||||
void liste(int n) {
|
void CP5_listActions(int n) {
|
||||||
if (shaderList.size() < maxFx) {
|
if (shaderList.size() < maxFx) {
|
||||||
switch(n) {
|
switch(n) {
|
||||||
case(0):
|
case(0):
|
||||||
@@ -364,143 +304,6 @@ public class SecondApplet extends PApplet {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Oscillator {
|
|
||||||
float speed; //in milliseconds
|
|
||||||
int spawnMillis;
|
|
||||||
int pauseMillis;
|
|
||||||
int beatCount = 0;
|
|
||||||
int mode;
|
|
||||||
|
|
||||||
//int function; //function to be called by bang-oscillators
|
|
||||||
float position; // between 0 and TWO_PI
|
|
||||||
float value; // is returned, constrained between "low" and "high"
|
|
||||||
float low = -1.0;
|
|
||||||
float high = 1.0;
|
|
||||||
boolean playing, pause, valInvert;
|
|
||||||
|
|
||||||
Oscillator(float bpm_) {
|
|
||||||
bpm(bpm_);
|
|
||||||
play();
|
|
||||||
}
|
|
||||||
|
|
||||||
void amplitude(float low_, float high_) {
|
|
||||||
low = low_;
|
|
||||||
high = high_;
|
|
||||||
}
|
|
||||||
void frequency(float hertz_) {
|
|
||||||
speed = 1000/hertz_;
|
|
||||||
}
|
|
||||||
void bpm(float bpm_) {
|
|
||||||
speed = int(60 / bpm_ * 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
void play() {
|
|
||||||
if (pause) {
|
|
||||||
float pauseTime = millis() - pauseMillis;
|
|
||||||
spawnMillis += pauseTime;
|
|
||||||
pause = false;
|
|
||||||
} else if (!playing) {
|
|
||||||
spawnMillis = millis();
|
|
||||||
}
|
|
||||||
playing = true;
|
|
||||||
}
|
|
||||||
void pause() {
|
|
||||||
if (playing) {
|
|
||||||
pauseMillis = millis();
|
|
||||||
pause = true;
|
|
||||||
playing = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
void stop() {
|
|
||||||
beatCount = 0;
|
|
||||||
playing = false;
|
|
||||||
value = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void update() {
|
|
||||||
if (playing) {
|
|
||||||
while (millis() - spawnMillis > speed*beatCount) {
|
|
||||||
beatCount++;
|
|
||||||
if (mode == RANDOMIZE_ALL) randomize_all();
|
|
||||||
}
|
|
||||||
|
|
||||||
float millisToBeat = millis() - spawnMillis - (speed*beatCount);
|
|
||||||
position = map(-millisToBeat, speed, 0, 0, TWO_PI);
|
|
||||||
|
|
||||||
switch(mode) {
|
|
||||||
case(SINE):
|
|
||||||
value = sin(position);
|
|
||||||
break;
|
|
||||||
case(SAWTOOTH):
|
|
||||||
value = ((position % TWO_PI)-PI)/PI;
|
|
||||||
break;
|
|
||||||
case(SAWTOOTHINVERSE):
|
|
||||||
value = (((position % TWO_PI)-PI)/PI)*-1;
|
|
||||||
break;
|
|
||||||
case(SQUARE):
|
|
||||||
value = sin(position > PI ? 1 : -1);
|
|
||||||
break;
|
|
||||||
case(TRIANGLE):
|
|
||||||
value = position-PI < 0 ? ((position % TWO_PI)-PI)/PI : (((position % TWO_PI)-PI)/PI)*-1;
|
|
||||||
value+=0.5;
|
|
||||||
value*=2;
|
|
||||||
if (value == 3.0) value = -1;
|
|
||||||
break;
|
|
||||||
case(TAN):
|
|
||||||
value = tan(position);
|
|
||||||
break;
|
|
||||||
case(TANINVERSE):
|
|
||||||
value = tan(position)*-1;
|
|
||||||
break;
|
|
||||||
case(RAMP):
|
|
||||||
value = sin(position) > 0 ? ((position % TWO_PI)-PI)/PI : 0;
|
|
||||||
value+=0.5;
|
|
||||||
value*=2;
|
|
||||||
if (value == 3.0) value = -1;
|
|
||||||
break;
|
|
||||||
case(RAMPINVERSE):
|
|
||||||
value = sin(position) > 0 ? ((position % TWO_PI)-PI)/PI : 0;
|
|
||||||
value+=0.5;
|
|
||||||
value*=2;
|
|
||||||
if (value == 3.0) value = -1;
|
|
||||||
value = value*-1;
|
|
||||||
break;
|
|
||||||
case(RAMPUPDOWN):
|
|
||||||
if (sin(position) <= -1.6666666666) value = -1.6666666666;
|
|
||||||
else if (sin(position) < 1.6666666666 && sin(position) > -1.6666666666) value = sin(position);
|
|
||||||
else if (sin(position) >= 1.6666666666) value = 1.6666666666;
|
|
||||||
value *= 1.5;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
value = constrain(value, -1.0, 1.0);
|
|
||||||
|
|
||||||
value = map(value, -1.0, 1.0, low, high);
|
|
||||||
//value = valInvert? map(value, 1.0, -1.0, low, high) : map(value, -1.0, 1.0, low, high);
|
|
||||||
}
|
|
||||||
|
|
||||||
//fill(0);
|
|
||||||
//ellipse(inc, height/2+value*height/4, 1, 1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void randomize_all() {
|
|
||||||
for (int i = slider.size()-1; i >= 0; i--) {
|
|
||||||
Slider s = slider.get(i);
|
|
||||||
if (random(1) > .5) s.osci.mode = int(round(random(9)));
|
|
||||||
if (random(1) > .5) s.osci.play();
|
|
||||||
else pause();
|
|
||||||
if (random(1) > .5) s.osci.bpm(random(2, 10));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void mousePressed() {
|
void mousePressed() {
|
||||||
for (int i = slider.size()-1; i >= 0; i--) {
|
for (int i = slider.size()-1; i >= 0; i--) {
|
||||||
Slider s = slider.get(i);
|
Slider s = slider.get(i);
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ class Shader {
|
|||||||
|
|
||||||
void getValuesFromGUI(){
|
void getValuesFromGUI(){
|
||||||
params = gui.bricks.get(pos).params;
|
params = gui.bricks.get(pos).params;
|
||||||
println("Rendering " + this + " on position " + pos + "...");
|
if(frameRate < 1) println("Rendering " + this + " on position " + pos + "...");
|
||||||
}
|
}
|
||||||
|
|
||||||
void changeParam(int paramNo, Param newParam){
|
void changeParam(int paramNo, Param newParam){
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
Capture cam;
|
Capture cam;
|
||||||
Movie movie;
|
Movie movie;
|
||||||
boolean moviePlaying;
|
boolean moviePlaying;
|
||||||
|
|||||||
44
statics_and_lists.pde
Normal file
44
statics_and_lists.pde
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
final static int INTVAL = 100;
|
||||||
|
final static int FLOATVAL = 101;
|
||||||
|
|
||||||
|
//waveforms for oscillator
|
||||||
|
final static int SINE = 0; //add 0.25 to phase to get cos
|
||||||
|
final static int SAWTOOTH = 1;
|
||||||
|
final static int SAWTOOTHINVERSE = 2;
|
||||||
|
final static int SQUAR = 3; //switches between -1 and 1, that's all
|
||||||
|
final static int TRIANG = 4;
|
||||||
|
final static int TAN = 5;
|
||||||
|
final static int TANINVERSE = 6;
|
||||||
|
final static int RAMP = 7; //line for half the sequence up to 1, then stay at 1 for the other half
|
||||||
|
final static int RAMPINVERSE = 8; //line for half the sequence up to 1, then stay at 1 for the other half
|
||||||
|
final static int RAMPUPDOWN = 9; //line up, stay, line down, stay
|
||||||
|
final static int RANDOM = 10;
|
||||||
|
|
||||||
|
//available shaders
|
||||||
|
String availableFx[] = {
|
||||||
|
"fxASDFPixelSort",
|
||||||
|
"fxDistorter",
|
||||||
|
"fxWahWah",
|
||||||
|
"fxAuEcho",
|
||||||
|
"fxPhaser",
|
||||||
|
"fxWZIP",
|
||||||
|
"fxDarker",
|
||||||
|
"fxBrighter",
|
||||||
|
"fxMove",
|
||||||
|
"fxScale",
|
||||||
|
"fxEpilepsy",
|
||||||
|
"fxPosterize",
|
||||||
|
"fxCopyZoom",
|
||||||
|
"fxDual",
|
||||||
|
"fxScanker",
|
||||||
|
"fxPixelSort",
|
||||||
|
"fxHSB",
|
||||||
|
"fxEcho",
|
||||||
|
"fxSubtleSort",
|
||||||
|
"fxBlackWhite",
|
||||||
|
"fxDrawGenerative",
|
||||||
|
"fxDrawStrokes",
|
||||||
|
"fxFM",
|
||||||
|
"fxGrauzone",
|
||||||
|
"fxSlitScan"
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user