Compare commits

...

8 Commits

13 changed files with 1090 additions and 248 deletions

5
audioreactivity.pde Normal file
View File

@@ -0,0 +1,5 @@
AudioIn audioIn;
Amplitude loudness;
float volume;
float volumeRoof = 1.0;

View File

@@ -1,2 +1,2 @@
//globals
uptime = 117266253
uptime = 119045247

BIN
data/sox-0.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 754 B

BIN
data/sox-149.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 802 B

BIN
data/sox.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 981 KiB

1
data/sox.raw Normal file

File diff suppressed because one or more lines are too long

1
data/sox_sonified.raw Normal file

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@@ -1,16 +1,33 @@
/* todo:
- implement all sox effects
- don't rerender on change of blend-mode
- add blending option everywhere
- add blend-effect to blend a selected layer
- add png corruption
- add png, jpg, gif and fractal compression artifact effects
*/
import drop.*;
import controlP5.*;
import processing.sound.*;
import java.util.*;
import processing.net.*;
//import processing.net.*;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import processing.video.*;
import com.hamoid.*;
import java.io.*;
import java.util.Arrays;
Class<?> sketchClass;
VideoExport videoExport;
AudioIn audioIn;
Amplitude loudness;
float volume;
float volumeRoof = 1.0;
int maxFx = 15; //possible amount of effect layers
SDrop drop;
PImage source;
@@ -29,16 +46,31 @@ int w, h;
boolean spawnPlaying = false;
boolean autoPlay = false;
boolean videoRecord = false;
boolean webcamMode = false;
//boolean webcamMode = false;
int micChannel = 0; //which microphone?
//Capture[] cams;
//ArrayList<Capture> cams = new ArrayList<Capture>();
Capture cam;
Capture cam2;
String[] cameras;
int currentCam;
String[] params;
PImage droppedImage;
void dropEvent(DropEvent theDropEvent) {
sourceManager.importURI(theDropEvent.filePath());
}
SecondApplet gui;
PApplet mainApplet;
void setup() {
@@ -66,7 +98,29 @@ void setup() {
}
fallbackImage = loadImage(dataPath("0.png"));
bin = loadImage(dataPath("bin.png"));
cam = new Capture(this, 1280, 768);
audioIn = new AudioIn(this, micChannel);
audioIn.start();
loudness = new Amplitude(this);
loudness.input(audioIn);
cameras = Capture.list();
/*
for (int i = 0; i < cameras.length-1; i++) {
try {
cams.add(new Capture(this, 1920, 1080, cameras[i]));
}
catch(Exception e) {
println(e);
}
}
*/
//cam = new Capture(this, 1920,1080, "pipeline:autovideosrc");
//cam = new Capture(this, 1920,1080, "Video Assist 5\" 3G");
cam = new Capture(this, 1920, 1080, "OBS Virtual Camera", 60);
cam2 = new Capture(this, 1920, 1080, "Kamera von „Victors iPhone“", 60);
OS = getOS();
String[] args = {"SecondFrame"};
@@ -74,6 +128,7 @@ void setup() {
gui = new SecondApplet();
PApplet.runSketch(args, gui);
renderer = createGraphics(width, height);
renderer.noSmooth();
viewport = createImage(renderer.width, renderer.height, ARGB);
@@ -81,11 +136,38 @@ void setup() {
//sourceManager.importURI("/home/giers/.local/bin/fast-style-transfer/data/train2014");
}
PImage webcamImg;
PImage iPhoneImg;
void captureEvent(Capture c) {
c.read();
//webcamImg = cam.get();
if (c == cam) {
webcamImg = cam.get();
}
if (c == cam2) {
iPhoneImg = cam2.get();
}
}
void draw() {
uptime+=1;
renderFrameRate = frameRate;
volume = map(loudness.analyze(),0,1,0,volumeRoof);
if(volume > 1) volumeRoof -= 0.008;
//if(webcamRunning){
//webcamImg =
// }
background(255);
sourceManager.update(); //will write some image to the renderer
sourceManager.setSource();
if (autoPlay) gui.robot();
@@ -115,6 +197,7 @@ void draw() {
}
if (recording) {
snapshot();
fill(#ff0000);
@@ -161,29 +244,55 @@ String getOS() {
return "other";
}
}
/*
boolean runCommand(String[] command) {
//String returnedValues;
//String returnedValues;
try {
Process p = new ProcessBuilder(command).start();
int ii = p.waitFor();
if (ii == 0) { //success signal
//BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
//while ( (returnedValues = stdInput.readLine ()) != null) {
//println(returnedValues);
//}
return(true);
} else {
//BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
//println("Error:");
//while ( (returnedValues = stdErr.readLine ()) != null) {
//println(returnedValues);
//}
return(false);
}
}
catch (Exception e) {
//println("Error running command");
//println(e);
return(false);
}
}*/
int runCommand(String[] command) {
String returnedValues;
try {
println(command);
Process p = new ProcessBuilder(command).start();
int ii = p.waitFor();
if (ii == 0) { //success signal
//BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
//while ( (returnedValues = stdInput.readLine ()) != null) {
//println(returnedValues);
//}
return(true);
} else {
//BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
//println("Error:");
//while ( (returnedValues = stdErr.readLine ()) != null) {
//println(returnedValues);
//}
return(false);
BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
BufferedReader stdErr = new BufferedReader(new InputStreamReader(p.getErrorStream()));
while ( (returnedValues = stdInput.readLine ()) != null) {
println(returnedValues);
}
while ( (returnedValues = stdErr.readLine ()) != null) {
println(returnedValues);
}
println(ii);
return(ii);
}
catch (Exception e) {
//println("Error running command");
//println(e);
return(false);
println("Error running command");
println(command);
println(e);
return(3); //error signal
}
}

View File

@@ -24,7 +24,8 @@ public class SecondApplet extends PApplet {
public void settings() {
size(275, 120);
}
Toggle webcam, auto;
//Toggle webcam, auto;
Toggle auto;
public void setup() {
surface.setLocation(285, 240);
//List l = Arrays.asList(availableFx);
@@ -62,12 +63,12 @@ public class SecondApplet extends PApplet {
webcam = cp5.addToggle("webcam")
.setPosition(100, height-65)
.setSize(12, 12)
.setValue(false)
.plugTo(this, "CP5_webcamAction");
webcam.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20);
/* webcam = cp5.addToggle("webcam")
.setPosition(100, height-65)
.setSize(12, 12)
.setValue(false)
.plugTo(this, "CP5_webcamAction");
webcam.getCaptionLabel().getStyle().setMargin(-17, 0, 0, 20);*/
Toggle robot = cp5.addToggle("autoPlay")
.setPosition(100, height-50)
@@ -101,16 +102,16 @@ public class SecondApplet extends PApplet {
startRobot = true;
autoPlay = !autoPlay;
}
/*
void CP5_webcamAction()  {
webcamMode = !webcamMode;
if (webcamMode) sourceManager.startWebcam();
else {
sourceManager.stopWebcam();
source = null;
}
}
webcamMode = !webcamMode;
if (webcamMode) sourceManager.startWebcam();
else {
sourceManager.stopWebcam();
source = null; //to trigger auto-fallback next frame
}
}
*/
void CP5_nativeResoAction() {
renderSize = max(nativeResoX, nativeResoY);
//renderer.setSize(nativeResoX, nativeResoY);
@@ -179,6 +180,12 @@ public class SecondApplet extends PApplet {
noStroke();
rect(mouseX, mouseY, 35, 15);
}
//audioindicator
fill(map(volume,0,0.5,0,255));
noStroke();
ellipse(260,height-105,15,15);
}
boolean heightOverLimit;
@@ -381,7 +388,11 @@ public class SecondApplet extends PApplet {
for (int i = 0; i < slider.size(); i++) {
if (slider.get(i).hovering || slider.get(i).hovering_anim_btn) sliderHover = true;
if (paused && slider.get(i).animated) paused = false;
params.get(i).audioMulti = slider.get(i).audioVal * volume * 2;
}
if (mouseX > 10 && mouseX < 22 && mouseY > 4+totalBrickHeight+scrollAmount && mouseY < 4+totalBrickHeight+13+scrollAmount) {
hoverActiveButton = true;
@@ -413,8 +424,12 @@ public class SecondApplet extends PApplet {
}
for (int i = 0; i < slider.size(); i++) {
slider.get(i).update();
//params.get(i).value = slider.get(i).value;
//* map(volume,0,1,0.8,1.2);
//slider.get(i).value = map(volume,0,1,0.8,1.2) * slider.get(i).value;
params.get(i).value = slider.get(i).value;
slider.get(i).update();
}
brickBGcol = color(85, 85, 85);
}
@@ -476,8 +491,8 @@ public class SecondApplet extends PApplet {
class Slider {
int x, y, w, h, mode;
int[] osciModes;
float minVal, maxVal, value; //should be private but doesnt work lol
boolean hovering, hovering_anim_btn, animated;
float minVal, maxVal, value, audioVal; //should be private but doesnt work lol
boolean hovering, hovering_anim_btn,hovering_audio_slider, animated;
String label;
Oscillator osci;
@@ -495,7 +510,8 @@ public class SecondApplet extends PApplet {
osci = new Oscillator(int(random(2, 5)), osciModes);
osci.amplitude(minVal, maxVal);
osci.update();
setValue(osci.value);
//setValue(osci.value);
setValue((minVal+maxVal)/2);
animated = true;
@@ -538,14 +554,17 @@ public class SecondApplet extends PApplet {
void update() {
//float audioImpact = (audioVal * volume) + 1;
//setValue(value*(1+audioVal));
osci.update();
// osci.update();
if (animated) {
osci.update();
setValue(osci.value);
}
if (mouseX >= x && mouseX <= x+w && mouseY >= y+scrollAmount && mouseY <= y+h+scrollAmount) {
hovering = true;
@@ -558,6 +577,12 @@ public class SecondApplet extends PApplet {
} else {
hovering_anim_btn = false;
}
if (mouseX >= x+w+20 && mouseX <= x+w+35 && mouseY >= y+scrollAmount && mouseY <= y+h+scrollAmount) {
hovering_audio_slider = true;
} else {
hovering_audio_slider = false;
}
}
void display() {
@@ -577,6 +602,11 @@ public class SecondApplet extends PApplet {
fill(100+(40*int(hovering_anim_btn)));
}
rect(x+w+5, y, h, h);
stroke(255);
line(x+w+5+h+10,y, x+w+5+h+10, y+h);
line(x+w+5+h+5, y+h-(audioVal*h), x+w+5+h+15, y+h-(audioVal*h));
}
}
@@ -610,10 +640,13 @@ public class SecondApplet extends PApplet {
if (random(1)<0.01) {
int removeMe = int(random(shaderList.size()-1));
println("removing" + removeMe);
bricks.get(removeMe).press();
shaderManager.removeShader(removeMe);
pressedBrick = -1;
if ((removeMe == 0 && bricks.get(removeMe).name.equals("Webcam")) == false) {
println(bricks.get(removeMe).name);
println("removing" + removeMe);
bricks.get(removeMe).press();
shaderManager.removeShader(removeMe);
pressedBrick = -1;
}
}
}
@@ -639,6 +672,9 @@ public class SecondApplet extends PApplet {
Slider s = slider.get(i);
if (s.hovering) s.press(i);
if (s.hovering_anim_btn) s.animated = !s.animated;
if (s.hovering_audio_slider){
s.audioVal = map(mouseY-(s.y+scrollAmount),0,12,1,0);
}
}
for (int i = bricks.size()-1; i >= 0; i--) {
if (bricks.get(i).hovering) {
@@ -717,6 +753,12 @@ public class SecondApplet extends PApplet {
}
}
textSize(10);
if (mouseX > 245 && mouseY < height-90 && mouseY > height-120) {
volumeRoof -= float(event.getCount())/100;
if(volumeRoof > 100) volumeRoof = 100;
if(volumeRoof <= 0.01) volumeRoof = 0.01;
}
}
int numberTypedFrame;
boolean typingNumber;

View File

@@ -3,6 +3,7 @@ class Param {
int type;
float minValue, maxValue;
float value;
float audioMulti;
int[] osciModes;
Param(String name_, int type_, float minValue_, float maxValue_, int[] osciModes_) {
name = name_;
@@ -11,6 +12,9 @@ class Param {
maxValue = maxValue_;
osciModes = osciModes_;
}
float getValue(){
return(value + ((maxValue-minValue) * audioMulti)); //wenn man so auch die automation-values handhabt, kann man mit automatisierten slidern besser spielen .. mayb
}
}
class Shader {
@@ -59,6 +63,8 @@ class Shader {
paramChanged = true;
}
previousPos = pos;
if(volume > 0) paramChanged = true;
try{
if (previousActive != gui.bricks.get(pos).active) { //fails if brick has not yet been loaded but shader has
@@ -86,7 +92,7 @@ class Shader {
gui.bricks.get(pos).exchangeSlider(paramNo, newParam);
paramChanged = true;
}
void shade() {
if (renderSizeChanged || paramChanged) {
this.setupCanvas();

View File

@@ -1,4 +1,4 @@
Capture cam;
Movie movie;
boolean moviePlaying, imageChanged;
PImage fallbackImage;
@@ -38,7 +38,8 @@ class SourceManager { //no constructor
void setImage(PImage img) { //set image to source
imageChanged = true;
source = img.get();
if(!webcamMode)fallbackImage = source;
//if(!webcamMode) fallbackImage = source;
fallbackImage = source;
nativeResoX = source.width;
nativeResoY = source.height;
//println(nativeResoX);
@@ -48,7 +49,7 @@ class SourceManager { //no constructor
println("Fallback");
setImage(fallbackImage); //fallbackImage should always be a copy of the last image that worked
}
/*
void startWebcam() {
String[] cameras = Capture.list();
println(cameras);
@@ -58,15 +59,17 @@ class SourceManager { //no constructor
void stopWebcam() {
cam.stop();
webcamMode = false;
}
}*/
void update() {
/*
if (webcamMode) {
if (cam.available()) {
cam.read();
setImage(cam);
}
}
*/
if (source == null) {
fallback();
@@ -123,7 +126,7 @@ class SourceManager { //no constructor
if (isImage(path) || isVideo(path)) {
println("Importing file " + path);
if (moviePlaying) movie.stop();
if (webcamMode) gui.webcam.setValue(false);
//if (webcamMode) gui.webcam.setValue(false);
if (isImage(path)) {
moviePlaying = false;
setImage(loadImage(path));

View File

@@ -1,4 +1,7 @@
String FX[] = {
"WEBCAM",
"MASK",
"IPHONE",
"ASDFPIXELSORT",
"DISTORTER",
"FM",
@@ -17,7 +20,6 @@ String FX[] = {
"COPYZOOM",
"SUBTLESORT",
"SCANKER",
"MASK",
"DRAWSTROKES",
"DRAWGENERATIVE",
"PIXELDRIFTER",
@@ -32,6 +34,71 @@ String FX[] = {
"COLORCRUSHER",
"JPGCORRUPTION",
"WEBPCORRUPTION"
/*,
"SOXALLPASS",
"SOXBAND",
"SOXBANDPASS",
"SOXBANDREJECT",
"SOXBASS",
"SOXBEND",
"SOXBIQUAD",
"SOXCHORUS",
"SOXCHANNELS",
"SOXCOMPAND",
"SOXCONTRAST",
"SOXDCSHIFT",
"SOXDEEMPH",
"SOXDELAY",
"SOXDITHER",
"SOXDIVIDE",
"SOXDOWNSAMPLE",
"SOXEARWAX",
"SOXECHO",
"SOXECHOS",
"SOXEQUALIZER",
"SOXFADE",
"SOXFIR",
"SOXFIRFIT",
"SOXFLANGER",
"SOXGAIN",
"SOXHIGHPASS",
"SOXHILBERT",
"SOXINPUT",
"SOXLOUDNESS",
"SOXLOWPASS",
"SOXMCOMPAND",
"SOXNOISEPROF",
"SOXNOISERED",
"SOXNORM",
"SOXOOPS",
"SOXOUTPUT",
"SOXOVERDRIVE",
"SOXPAD",
"SOXPHASER",
"SOXPITCH",
"SOXRATE",
"SOXREMIX",
"SOXREPEAT",
"SOXREVERB",
"SOXREVERSE",
"SOXRIAA",
"SOXSILENCE",
"SOXSINC",
"SOXSPECTOGRAM",
"SOXSPEED",
"SOXSPLICE",
"SOXSTAT",
"SOXSTATS",
"SOXSTRETCH",
"SOXSWAP",
"SOXSYNTH",
"SOXTEMPO",
"SOXTREBLE",
"SOXTREMOLO",
"SOXTRIM",
"SOXUPSAMPLE",
"SOXVAD",
"SOXVOL"*/
};