diff --git a/src/2023-06-21.festl_is/Makefile b/src/2023-06-21.festl_is/Makefile index 57bcf89..a497bc6 100644 --- a/src/2023-06-21.festl_is/Makefile +++ b/src/2023-06-21.festl_is/Makefile @@ -2,7 +2,7 @@ # glslViewer order matters, single-dash options need to be before doubledashes? (at least for -p) test: - glslViewer main.frag video.mp4 -w 960 -h 540 -p 8881 -e "error_screen,off" --nocursor --fps30 + glslViewer main.frag video.mp4 -w 960 -h 540 -p 4242 -e "error_screen,off" --nocursor --fps30 test-gits: - glslViewer main.frag gits.mp4 -w 960 -h 540 -p 8881 -e "error_screen,off" --nocursor --fps30 + glslViewer main.frag gits.mp4 -w 960 -h 540 -p 4242 -e "error_screen,off" --nocursor --fps30 diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/GUI_BUILDER_DATA/gui.ser.4.4 b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/GUI_BUILDER_DATA/gui.ser.4.4 new file mode 100644 index 0000000..7bb8ca8 Binary files /dev/null and b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/GUI_BUILDER_DATA/gui.ser.4.4 differ diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/audioAnalysis.pde b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/audioAnalysis.pde new file mode 100644 index 0000000..7546d7f --- /dev/null +++ b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/audioAnalysis.pde @@ -0,0 +1,51 @@ +import ddf.minim.*; +import ddf.minim.analysis.*; + +Minim minim; +AudioInput myAudio; + +// beat detection with sound energy +BeatDetect myBeat; +int myBeatMax = 20; // sync with gui +int myBeatCurrent = 0; + +FFT myFFT; + +void setupAudioAnalysis() { + minim = new Minim(this); + myAudio = minim.getLineIn(); // Minim.STEREO, bufferSize=1024, sampleRate=44100, int bitDepth=16 + + // beat detection setup + myBeat = new BeatDetect(); + + // fft setup + myFFT = new FFT(myAudio.bufferSize(), myAudio.sampleRate()); + myFFT.logAverages(22, 12); // (22,12) -> 120 averages + myFFT.window(FFT.NONE); + + // debug + println("[debug][audio]: number of fft bins: "+myFFT.avgSize()); +} + +void drawAudioAnalysis() { + // beat detection processing + if(myBeatCurrent > 0) { + myBeatCurrent--; // linear decay + } + myBeat.detect(myAudio.mix); + if(myBeat.isOnset()) { + myBeatCurrent = myBeatMax; + } + // draw beat detection + fill(0);noStroke(); + rect(160,40,40,40); + fill(255); + circle(160+20,40+20,getBeatDetectNormalized()*36); + + // fft processing + +} + +float getBeatDetectNormalized() { + return (myBeatCurrent / float(myBeatMax)); +} diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/audio_processing_gui.pde b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/audio_processing_gui.pde new file mode 100644 index 0000000..dcc921e --- /dev/null +++ b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/audio_processing_gui.pde @@ -0,0 +1,22 @@ +import g4p_controls.*; + + + +color bgColor = #333344; + +void setup() { + size(900,900); + frameRate(30); + background(bgColor); + + setupAudioAnalysis(); + + createGUI(); +} + +void draw() { + background(bgColor); + + drawAudioAnalysis(); + +} diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/data/list_384393 b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/data/list_384393 new file mode 100644 index 0000000..ad4b5f7 --- /dev/null +++ b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/data/list_384393 @@ -0,0 +1,10 @@ +none +bartlett +bartletthann +blackmann +cosine +gauss +hammin +hann +lanczos +triangular diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/gui.pde b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/gui.pde new file mode 100644 index 0000000..bfb42c6 --- /dev/null +++ b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/gui.pde @@ -0,0 +1,142 @@ +/* ========================================================= + * ==== WARNING === + * ========================================================= + * The code in this tab has been generated from the GUI form + * designer and care should be taken when editing this file. + * Only add/edit code inside the event handlers i.e. only + * use lines between the matching comment tags. e.g. + + void myBtnEvents(GButton button) { //_CODE_:button1:12356: + // It is safe to enter your event code here + } //_CODE_:button1:12356: + + * Do not rename this tab! + * ========================================================= + */ + +public void gui_fftWindowing_click(GDropList source, GEvent event) { //_CODE_:gui_fftWindowing:384393: + //println("dropList1 - GDropList >> GEvent." + event + " @ " + millis()); + String selected = source.getSelectedText(); + switch(selected) { + case "bartlett": + myFFT.window(FFT.BARTLETT); + case "bartletthann": + myFFT.window(FFT.BARTLETTHANN); + case "blackmann": + myFFT.window(FFT.BLACKMAN); + case "cosine": + myFFT.window(FFT.COSINE); + case "gauss": + myFFT.window(FFT.GAUSS); + case "hammin": + myFFT.window(FFT.HAMMING); + case "hann": + myFFT.window(FFT.HANN); + case "lanczos": + myFFT.window(FFT.LANCZOS); + case "triangular": + myFFT.window(FFT.TRIANGULAR); + case "none": + default: + myFFT.window(FFT.NONE); + } +} //_CODE_:gui_fftWindowing:384393: + +public void gui_fftAmpBeginFrac_change(GSlider source, GEvent event) { //_CODE_:gui_fftAmpBeginFrac:516902: + println("slider1 - GSlider >> GEvent." + event + " @ " + millis()); +} //_CODE_:gui_fftAmpBeginFrac:516902: + +public void gui_baseAmp_change(GSlider source, GEvent event) { //_CODE_:gui_baseAmp:888464: + println("slider2 - GSlider >> GEvent." + event + " @ " + millis()); +} //_CODE_:gui_baseAmp:888464: + +public void gui_ampStart_change(GSlider source, GEvent event) { //_CODE_:gui_ampStart:865325: + println("slider1 - GSlider >> GEvent." + event + " @ " + millis()); +} //_CODE_:gui_ampStart:865325: + +public void gui_ampStep_change(GSlider source, GEvent event) { //_CODE_:gui_ampStep:498343: + println("slider2 - GSlider >> GEvent." + event + " @ " + millis()); +} //_CODE_:gui_ampStep:498343: + +public void gui_beatDecay_change(GSlider source, GEvent event) { //_CODE_:gui_beatDecay:302227: + println("gui_beatDecay - GSlider >> GEvent." + event + " @ " + millis()); + myBeatMax = source.getValueI(); +} //_CODE_:gui_beatDecay:302227: + + + +// Create all the GUI controls. +// autogenerated do not edit +public void createGUI(){ + G4P.messagesEnabled(false); + G4P.setGlobalColorScheme(GCScheme.CYAN_SCHEME); + G4P.setMouseOverEnabled(false); + GButton.useRoundCorners(false); + surface.setTitle("Sketch Window"); + gui_fftWindowing = new GDropList(this, 100, 110, 100, 220, 10, 10); + gui_fftWindowing.setItems(loadStrings("list_384393"), 0); + gui_fftWindowing.addEventHandler(this, "gui_fftWindowing_click"); + label1 = new GLabel(this, 20, 110, 80, 20); + label1.setText("windowing:"); + label1.setOpaque(true); + label2 = new GLabel(this, 20, 140, 180, 20); + label2.setText("amp begin at bin fraction"); + label2.setOpaque(true); + label3 = new GLabel(this, 20, 210, 180, 20); + label3.setText("base amp"); + label3.setOpaque(true); + label4 = new GLabel(this, 20, 280, 180, 20); + label4.setText("amp start"); + label4.setOpaque(true); + gui_fftAmpBeginFrac = new GSlider(this, 20, 160, 180, 40, 10.0); + gui_fftAmpBeginFrac.setShowValue(true); + gui_fftAmpBeginFrac.setLimits(0.3, 0.0, 1.0); + gui_fftAmpBeginFrac.setNumberFormat(G4P.DECIMAL, 2); + gui_fftAmpBeginFrac.setOpaque(true); + gui_fftAmpBeginFrac.addEventHandler(this, "gui_fftAmpBeginFrac_change"); + gui_baseAmp = new GSlider(this, 20, 230, 180, 40, 10.0); + gui_baseAmp.setShowValue(true); + gui_baseAmp.setLimits(30.0, 1.0, 100.0); + gui_baseAmp.setNumberFormat(G4P.DECIMAL, 2); + gui_baseAmp.setOpaque(true); + gui_baseAmp.addEventHandler(this, "gui_baseAmp_change"); + label5 = new GLabel(this, 20, 350, 180, 20); + label5.setText("amp step"); + label5.setOpaque(true); + gui_ampStart = new GSlider(this, 20, 300, 180, 40, 10.0); + gui_ampStart.setShowValue(true); + gui_ampStart.setLimits(0.05, 0.005, 0.2); + gui_ampStart.setNumberFormat(G4P.DECIMAL, 3); + gui_ampStart.setOpaque(true); + gui_ampStart.addEventHandler(this, "gui_ampStart_change"); + gui_ampStep = new GSlider(this, 20, 370, 180, 40, 10.0); + gui_ampStep.setShowValue(true); + gui_ampStep.setLimits(0.02, 0.005, 0.2); + gui_ampStep.setNumberFormat(G4P.DECIMAL, 3); + gui_ampStep.setOpaque(true); + gui_ampStep.addEventHandler(this, "gui_ampStep_change"); + label6 = new GLabel(this, 20, 20, 180, 20); + label6.setText("simple beat decay"); + label6.setOpaque(true); + gui_beatDecay = new GSlider(this, 20, 40, 140, 40, 10.0); + gui_beatDecay.setShowValue(true); + gui_beatDecay.setLimits(30.0, 1.0, 60.0); + gui_beatDecay.setNumberFormat(G4P.DECIMAL, 2); + gui_beatDecay.setOpaque(true); + gui_beatDecay.addEventHandler(this, "gui_beatDecay_change"); +} + +// Variable declarations +// autogenerated do not edit +GDropList gui_fftWindowing; +GLabel label1; +GLabel label2; +GLabel label3; +GLabel label4; +GSlider gui_fftAmpBeginFrac; +GSlider gui_baseAmp; +GLabel label5; +GSlider gui_ampStart; +GSlider gui_ampStep; +GLabel label6; +GSlider gui_beatDecay; diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/oscThings.pde b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/oscThings.pde new file mode 100644 index 0000000..e69de29 diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/user_gui_palette.png b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/user_gui_palette.png new file mode 100644 index 0000000..01204e5 Binary files /dev/null and b/src/2023-06-21.festl_is/processing_sketches/audio_processing_gui/user_gui_palette.png differ diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/audio.pde b/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/audio.pde new file mode 100644 index 0000000..3846696 --- /dev/null +++ b/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/audio.pde @@ -0,0 +1,52 @@ +import ddf.minim.*; +import ddf.minim.analysis.*; + +Minim minim; +AudioInput myAudio; + +// beat detection with sound energy +BeatDetect myBeat; +final int BEAT_MAX = 60; +int myBeatMax = 20; // sync with gui +int myBeatCurrent = 0; + +FFT myFFT; + +void setupAudioAnalysis() { + minim = new Minim(this); + myAudio = minim.getLineIn(); // Minim.STEREO, bufferSize=1024, sampleRate=44100, int bitDepth=16 + + // beat detection setup + myBeat = new BeatDetect(); + + // fft setup + myFFT = new FFT(myAudio.bufferSize(), myAudio.sampleRate()); + myFFT.logAverages(22, 12); // (22,12) -> 120 averages + myFFT.window(FFT.NONE); + + // debug + println("[debug][audio]: number of fft bins: "+myFFT.avgSize()); +} + +void drawAudioAnalysis() { + // beat detection processing + if(myBeatCurrent > 0) { + myBeatCurrent--; // linear decay + } + myBeat.detect(myAudio.mix); + if(myBeat.isOnset()) { + myBeatCurrent = myBeatMax; + } + // draw beat detection + fill(0);noStroke(); + rect(20,20,40,40); + fill(255); + circle(20+20,20+20,getBeatDetectNormalized()*36); + + // fft processing + +} + +float getBeatDetectNormalized() { + return constrain((myBeatCurrent / float(myBeatMax)), 0.0f, 1.0f); +} diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/audio_processing_with_touchosc.pde b/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/audio_processing_with_touchosc.pde new file mode 100644 index 0000000..d09cbf3 --- /dev/null +++ b/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/audio_processing_with_touchosc.pde @@ -0,0 +1,19 @@ +color bgColor = #333344; + +void setup() { + size(900,900); + frameRate(30); + background(bgColor); + + setupOsc(); + + setupAudioAnalysis(); +} + +void draw() { + background(bgColor); + + drawOsc(); + + drawAudioAnalysis(); +} diff --git a/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/oscStuff.pde b/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/oscStuff.pde new file mode 100644 index 0000000..3e1f477 --- /dev/null +++ b/src/2023-06-21.festl_is/processing_sketches/audio_processing_with_touchosc/oscStuff.pde @@ -0,0 +1,35 @@ +import oscP5.*; +import netP5.*; + +OscP5 oscObj; +final int RECEIVEPORT = 13337; +final int SENDPORT = 4242; +NetAddress shaderNetAddress; + +// sends osc messages +void setupOsc() { + oscObj = new OscP5(this, RECEIVEPORT); + shaderNetAddress = new NetAddress("127.0.0.1", SENDPORT); +} + +void drawOsc() { + if (frameCount % 5 == 0) { + OscMessage msg = new OscMessage("/osc_beat_val"); + msg.add(getBeatDetectNormalized()); + oscObj.send(msg, shaderNetAddress); + } +} + +// reacts to osc messages +void oscEvent(OscMessage msgIn) { + //print("### received an osc message."); + //print(" addrpattern: "+msgIn.addrPattern()); + //println(" typetag: "+msgIn.typetag()); + if (msgIn.checkAddrPattern("/beat_decay")==true) { + if (msgIn.checkTypetag("f")) { + myBeatMax = max(int(BEAT_MAX*msgIn.get(0).floatValue()), 1); + //println(" myBeatMax: "+myBeatMax+" f: "+msgIn.get(0).floatValue()); + return; + } + } +} diff --git a/src/2023-06-21.festl_is/todo.md b/src/2023-06-21.festl_is/todo.md index bbd292f..fa4e198 100644 --- a/src/2023-06-21.festl_is/todo.md +++ b/src/2023-06-21.festl_is/todo.md @@ -22,6 +22,7 @@ * [X] how does it default if no input is coming? can I adjust from glslViewer cli? -> black or last frame, doesn't matter * glslViewer * [.] passes + * [ ] look at inspiration: https://github.com/butterw/bShaders * [X] brigthness pass * [X] POC * [ ] edge detection pass