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 //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 drop.*;
import controlP5.*; import controlP5.*;
import processing.sound.*;
import java.util.*; import java.util.*;
import processing.net.*; //import processing.net.*;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import java.awt.event.KeyListener; import java.awt.event.KeyListener;
import processing.video.*; import processing.video.*;
import com.hamoid.*; import com.hamoid.*;
import java.io.*;
import java.util.Arrays;
Class<?> sketchClass; Class<?> sketchClass;
VideoExport videoExport; VideoExport videoExport;
AudioIn audioIn;
Amplitude loudness;
float volume;
float volumeRoof = 1.0;
int maxFx = 15; //possible amount of effect layers int maxFx = 15; //possible amount of effect layers
SDrop drop; SDrop drop;
PImage source; PImage source;
@@ -29,16 +46,31 @@ int w, h;
boolean spawnPlaying = false; boolean spawnPlaying = false;
boolean autoPlay = false; boolean autoPlay = false;
boolean videoRecord = 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; String[] params;
PImage droppedImage; PImage droppedImage;
void dropEvent(DropEvent theDropEvent) { void dropEvent(DropEvent theDropEvent) {
sourceManager.importURI(theDropEvent.filePath()); sourceManager.importURI(theDropEvent.filePath());
} }
SecondApplet gui; SecondApplet gui;
PApplet mainApplet; PApplet mainApplet;
void setup() { void setup() {
@@ -66,7 +98,29 @@ void setup() {
} }
fallbackImage = loadImage(dataPath("0.png")); fallbackImage = loadImage(dataPath("0.png"));
bin = loadImage(dataPath("bin.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(); OS = getOS();
String[] args = {"SecondFrame"}; String[] args = {"SecondFrame"};
@@ -74,6 +128,7 @@ void setup() {
gui = new SecondApplet(); gui = new SecondApplet();
PApplet.runSketch(args, gui); PApplet.runSketch(args, gui);
renderer = createGraphics(width, height); renderer = createGraphics(width, height);
renderer.noSmooth(); renderer.noSmooth();
viewport = createImage(renderer.width, renderer.height, ARGB); viewport = createImage(renderer.width, renderer.height, ARGB);
@@ -81,11 +136,38 @@ void setup() {
//sourceManager.importURI("/home/giers/.local/bin/fast-style-transfer/data/train2014"); //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() { void draw() {
uptime+=1; uptime+=1;
renderFrameRate = frameRate; renderFrameRate = frameRate;
volume = map(loudness.analyze(),0,1,0,volumeRoof);
if(volume > 1) volumeRoof -= 0.008;
//if(webcamRunning){
//webcamImg =
// }
background(255); background(255);
sourceManager.update(); //will write some image to the renderer sourceManager.update(); //will write some image to the renderer
sourceManager.setSource(); sourceManager.setSource();
if (autoPlay) gui.robot(); if (autoPlay) gui.robot();
@@ -115,6 +197,7 @@ void draw() {
} }
if (recording) { if (recording) {
snapshot(); snapshot();
fill(#ff0000); fill(#ff0000);
@@ -161,6 +244,7 @@ String getOS() {
return "other"; return "other";
} }
} }
/*
boolean runCommand(String[] command) { boolean runCommand(String[] command) {
//String returnedValues; //String returnedValues;
try { try {
@@ -186,4 +270,29 @@ boolean runCommand(String[] command) {
//println(e); //println(e);
return(false); return(false);
} }
}*/
int runCommand(String[] command) {
String returnedValues;
try {
println(command);
Process p = new ProcessBuilder(command).start();
int ii = p.waitFor();
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(command);
println(e);
return(3); //error signal
}
} }

View File

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

View File

@@ -3,6 +3,7 @@ class Param {
int type; int type;
float minValue, maxValue; float minValue, maxValue;
float value; float value;
float audioMulti;
int[] osciModes; int[] osciModes;
Param(String name_, int type_, float minValue_, float maxValue_, int[] osciModes_) { Param(String name_, int type_, float minValue_, float maxValue_, int[] osciModes_) {
name = name_; name = name_;
@@ -11,6 +12,9 @@ class Param {
maxValue = maxValue_; maxValue = maxValue_;
osciModes = osciModes_; 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 { class Shader {
@@ -60,6 +64,8 @@ class Shader {
} }
previousPos = pos; previousPos = pos;
if(volume > 0) paramChanged = true;
try{ try{
if (previousActive != gui.bricks.get(pos).active) { //fails if brick has not yet been loaded but shader has if (previousActive != gui.bricks.get(pos).active) { //fails if brick has not yet been loaded but shader has
paramChanged = true; paramChanged = true;

View File

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

View File

@@ -1,4 +1,7 @@
String FX[] = { String FX[] = {
"WEBCAM",
"MASK",
"IPHONE",
"ASDFPIXELSORT", "ASDFPIXELSORT",
"DISTORTER", "DISTORTER",
"FM", "FM",
@@ -17,7 +20,6 @@ String FX[] = {
"COPYZOOM", "COPYZOOM",
"SUBTLESORT", "SUBTLESORT",
"SCANKER", "SCANKER",
"MASK",
"DRAWSTROKES", "DRAWSTROKES",
"DRAWGENERATIVE", "DRAWGENERATIVE",
"PIXELDRIFTER", "PIXELDRIFTER",
@@ -32,6 +34,71 @@ String FX[] = {
"COLORCRUSHER", "COLORCRUSHER",
"JPGCORRUPTION", "JPGCORRUPTION",
"WEBPCORRUPTION" "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"*/
}; };