Compare commits
3 Commits
dacb1f2cb7
...
15962335c0
Author | SHA1 | Date |
---|---|---|
Jakob | 15962335c0 | |
Jakob | 489bd02ddd | |
Jakob | 9015a501fe |
|
@ -6,3 +6,9 @@ test:
|
||||||
|
|
||||||
test-gits:
|
test-gits:
|
||||||
glslViewer main.frag gits.mp4 -w 960 -h 540 -p 4242 -e "error_screen,off" --nocursor --fps30
|
glslViewer main.frag gits.mp4 -w 960 -h 540 -p 4242 -e "error_screen,off" --nocursor --fps30
|
||||||
|
|
||||||
|
run-video2:
|
||||||
|
glslViewer main.frag /dev/video2 -l -w 960 -h 540 -p 4242 -e "error_screen,off" --nocursor --noncurses
|
||||||
|
|
||||||
|
run-blackBG-edit:
|
||||||
|
nvim -c "hi Normal ctermbg=232" main.frag
|
||||||
|
|
Binary file not shown.
|
@ -4,10 +4,11 @@ import ddf.minim.analysis.*;
|
||||||
Minim minim;
|
Minim minim;
|
||||||
AudioInput myAudio;
|
AudioInput myAudio;
|
||||||
|
|
||||||
// beat detection with sound energy
|
// beat detection with sound energy
|
||||||
BeatDetect myBeat;
|
BeatDetect myBeat;
|
||||||
int myBeatMax = 20; // sync with gui
|
int myBeatMax = 20; // sync with gui
|
||||||
int myBeatCurrent = 0;
|
int myBeatCurrent = 0;
|
||||||
|
int myBeatPrevious = 0;
|
||||||
|
|
||||||
FFT myFFT;
|
FFT myFFT;
|
||||||
|
|
||||||
|
@ -21,7 +22,7 @@ void setupAudioAnalysis() {
|
||||||
// fft setup
|
// fft setup
|
||||||
myFFT = new FFT(myAudio.bufferSize(), myAudio.sampleRate());
|
myFFT = new FFT(myAudio.bufferSize(), myAudio.sampleRate());
|
||||||
myFFT.logAverages(22, 12); // (22,12) -> 120 averages
|
myFFT.logAverages(22, 12); // (22,12) -> 120 averages
|
||||||
myFFT.window(FFT.NONE);
|
myFFT.window(FFT.HANN);
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
println("[debug][audio]: number of fft bins: "+myFFT.avgSize());
|
println("[debug][audio]: number of fft bins: "+myFFT.avgSize());
|
||||||
|
@ -29,23 +30,57 @@ void setupAudioAnalysis() {
|
||||||
|
|
||||||
void drawAudioAnalysis() {
|
void drawAudioAnalysis() {
|
||||||
// beat detection processing
|
// beat detection processing
|
||||||
if(myBeatCurrent > 0) {
|
if (myBeatCurrent > 0) {
|
||||||
myBeatCurrent--; // linear decay
|
myBeatCurrent--; // linear decay
|
||||||
}
|
}
|
||||||
myBeat.detect(myAudio.mix);
|
myBeat.detect(myAudio.mix);
|
||||||
if(myBeat.isOnset()) {
|
if (myBeat.isOnset()) {
|
||||||
myBeatCurrent = myBeatMax;
|
myBeatCurrent = myBeatMax;
|
||||||
}
|
}
|
||||||
// draw beat detection
|
// draw beat detection
|
||||||
fill(0);noStroke();
|
//fill(0);
|
||||||
rect(160,40,40,40);
|
//noStroke();
|
||||||
|
//rect(160, 40, 40, 40);
|
||||||
fill(255);
|
fill(255);
|
||||||
circle(160+20,40+20,getBeatDetectNormalized()*36);
|
circle(160+20, 40+20, getBeatDetectNormalized()*36);
|
||||||
|
// send osc
|
||||||
|
oscSendBeatValue(getBeatDetectNormalized());
|
||||||
|
|
||||||
// fft processing
|
// fft processing
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*******************************
|
||||||
|
beat helper functions
|
||||||
|
********************************/
|
||||||
float getBeatDetectNormalized() {
|
float getBeatDetectNormalized() {
|
||||||
return (myBeatCurrent / float(myBeatMax));
|
return (myBeatCurrent / float(myBeatMax));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void setBeatDecay(float val) {
|
||||||
|
gui_beatDecay.setValue(map(val, 0,1, gui_beatDecay.getStartLimit(), gui_beatDecay.getEndLimit()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/********************************
|
||||||
|
fft helper functions
|
||||||
|
********************************/
|
||||||
|
void setAmpBeginFraction(float val) {
|
||||||
|
gui_fftAmpBeginFrac.setValue(map(val, 0,1, gui_fftAmpBeginFrac.getStartLimit(), gui_fftAmpBeginFrac.getEndLimit()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAmpStart(float val) {
|
||||||
|
gui_ampStart.setValue(map(val, 0,1, gui_ampStart.getStartLimit(), gui_ampStart.getEndLimit()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setAmpStep(float val) {
|
||||||
|
gui_ampStep.setValue(map(val, 0,1, gui_ampStep.getStartLimit(), gui_ampStep.getEndLimit()));
|
||||||
|
}
|
||||||
|
|
||||||
|
void drawFFT() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
GSlider gui_fftAmpBeginFrac;
|
||||||
|
GSlider gui_baseAmp;
|
||||||
|
GSlider gui_ampStart;
|
||||||
|
GSlider gui_ampStep;
|
||||||
|
|
|
@ -5,18 +5,21 @@ import g4p_controls.*;
|
||||||
color bgColor = #333344;
|
color bgColor = #333344;
|
||||||
|
|
||||||
void setup() {
|
void setup() {
|
||||||
size(900,900);
|
size(900, 900);
|
||||||
frameRate(30);
|
frameRate(30);
|
||||||
background(bgColor);
|
background(bgColor);
|
||||||
|
|
||||||
setupAudioAnalysis();
|
setupAudioAnalysis();
|
||||||
|
|
||||||
createGUI();
|
createGUI();
|
||||||
|
|
||||||
|
setupOsc();
|
||||||
}
|
}
|
||||||
|
|
||||||
void draw() {
|
void draw() {
|
||||||
background(bgColor);
|
background(bgColor);
|
||||||
|
|
||||||
drawAudioAnalysis();
|
drawAudioAnalysis();
|
||||||
|
|
||||||
|
drawOsc();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
hann
|
||||||
none
|
none
|
||||||
bartlett
|
bartlett
|
||||||
bartletthann
|
bartletthann
|
||||||
|
@ -5,6 +6,5 @@ blackmann
|
||||||
cosine
|
cosine
|
||||||
gauss
|
gauss
|
||||||
hammin
|
hammin
|
||||||
hann
|
|
||||||
lanczos
|
lanczos
|
||||||
triangular
|
triangular
|
||||||
|
|
|
@ -5,9 +5,9 @@
|
||||||
* designer and care should be taken when editing this file.
|
* designer and care should be taken when editing this file.
|
||||||
* Only add/edit code inside the event handlers i.e. only
|
* Only add/edit code inside the event handlers i.e. only
|
||||||
* use lines between the matching comment tags. e.g.
|
* use lines between the matching comment tags. e.g.
|
||||||
|
|
||||||
void myBtnEvents(GButton button) { //_CODE_:button1:12356:
|
void myBtnEvents(GButton button) { //_CODE_:button1:12356:
|
||||||
// It is safe to enter your event code here
|
// It is safe to enter your event code here
|
||||||
} //_CODE_:button1:12356:
|
} //_CODE_:button1:12356:
|
||||||
|
|
||||||
* Do not rename this tab!
|
* Do not rename this tab!
|
||||||
|
@ -43,31 +43,31 @@ public void gui_fftWindowing_click(GDropList source, GEvent event) { //_CODE_:gu
|
||||||
} //_CODE_:gui_fftWindowing:384393:
|
} //_CODE_:gui_fftWindowing:384393:
|
||||||
|
|
||||||
public void gui_fftAmpBeginFrac_change(GSlider source, GEvent event) { //_CODE_:gui_fftAmpBeginFrac:516902:
|
public void gui_fftAmpBeginFrac_change(GSlider source, GEvent event) { //_CODE_:gui_fftAmpBeginFrac:516902:
|
||||||
println("slider1 - GSlider >> GEvent." + event + " @ " + millis());
|
//println("slider1 - GSlider >> GEvent." + event + " @ " + millis());
|
||||||
} //_CODE_:gui_fftAmpBeginFrac:516902:
|
} //_CODE_:gui_fftAmpBeginFrac:516902:
|
||||||
|
|
||||||
public void gui_baseAmp_change(GSlider source, GEvent event) { //_CODE_:gui_baseAmp:888464:
|
public void gui_baseAmp_change(GSlider source, GEvent event) { //_CODE_:gui_baseAmp:888464:
|
||||||
println("slider2 - GSlider >> GEvent." + event + " @ " + millis());
|
//println("slider2 - GSlider >> GEvent." + event + " @ " + millis());
|
||||||
} //_CODE_:gui_baseAmp:888464:
|
} //_CODE_:gui_baseAmp:888464:
|
||||||
|
|
||||||
public void gui_ampStart_change(GSlider source, GEvent event) { //_CODE_:gui_ampStart:865325:
|
public void gui_ampStart_change(GSlider source, GEvent event) { //_CODE_:gui_ampStart:865325:
|
||||||
println("slider1 - GSlider >> GEvent." + event + " @ " + millis());
|
//println("slider1 - GSlider >> GEvent." + event + " @ " + millis());
|
||||||
} //_CODE_:gui_ampStart:865325:
|
} //_CODE_:gui_ampStart:865325:
|
||||||
|
|
||||||
public void gui_ampStep_change(GSlider source, GEvent event) { //_CODE_:gui_ampStep:498343:
|
public void gui_ampStep_change(GSlider source, GEvent event) { //_CODE_:gui_ampStep:498343:
|
||||||
println("slider2 - GSlider >> GEvent." + event + " @ " + millis());
|
//println("slider2 - GSlider >> GEvent." + event + " @ " + millis());
|
||||||
} //_CODE_:gui_ampStep:498343:
|
} //_CODE_:gui_ampStep:498343:
|
||||||
|
|
||||||
public void gui_beatDecay_change(GSlider source, GEvent event) { //_CODE_:gui_beatDecay:302227:
|
public void gui_beatDecay_change(GSlider source, GEvent event) { //_CODE_:gui_beatDecay:302227:
|
||||||
println("gui_beatDecay - GSlider >> GEvent." + event + " @ " + millis());
|
//println("gui_beatDecay - GSlider >> GEvent." + event + " @ " + millis());
|
||||||
myBeatMax = source.getValueI();
|
myBeatMax = source.getValueI();
|
||||||
} //_CODE_:gui_beatDecay:302227:
|
} //_CODE_:gui_beatDecay:302227:
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Create all the GUI controls.
|
// Create all the GUI controls.
|
||||||
// autogenerated do not edit
|
// autogenerated do not edit
|
||||||
public void createGUI(){
|
public void createGUI() {
|
||||||
G4P.messagesEnabled(false);
|
G4P.messagesEnabled(false);
|
||||||
G4P.setGlobalColorScheme(GCScheme.CYAN_SCHEME);
|
G4P.setGlobalColorScheme(GCScheme.CYAN_SCHEME);
|
||||||
G4P.setMouseOverEnabled(false);
|
G4P.setMouseOverEnabled(false);
|
||||||
|
@ -79,37 +79,37 @@ public void createGUI(){
|
||||||
label1 = new GLabel(this, 20, 110, 80, 20);
|
label1 = new GLabel(this, 20, 110, 80, 20);
|
||||||
label1.setText("windowing:");
|
label1.setText("windowing:");
|
||||||
label1.setOpaque(true);
|
label1.setOpaque(true);
|
||||||
label2 = new GLabel(this, 20, 140, 180, 20);
|
label2 = new GLabel(this, 20, 130, 180, 20);
|
||||||
label2.setText("amp begin at bin fraction");
|
label2.setText("amp begin at bin fraction");
|
||||||
label2.setOpaque(true);
|
label2.setOpaque(true);
|
||||||
label3 = new GLabel(this, 20, 210, 180, 20);
|
label3 = new GLabel(this, 20, 190, 180, 20);
|
||||||
label3.setText("base amp");
|
label3.setText("base amp");
|
||||||
label3.setOpaque(true);
|
label3.setOpaque(true);
|
||||||
label4 = new GLabel(this, 20, 280, 180, 20);
|
label4 = new GLabel(this, 20, 250, 180, 20);
|
||||||
label4.setText("amp start");
|
label4.setText("amp start");
|
||||||
label4.setOpaque(true);
|
label4.setOpaque(true);
|
||||||
gui_fftAmpBeginFrac = new GSlider(this, 20, 160, 180, 40, 10.0);
|
gui_fftAmpBeginFrac = new GSlider(this, 20, 150, 180, 40, 10.0);
|
||||||
gui_fftAmpBeginFrac.setShowValue(true);
|
gui_fftAmpBeginFrac.setShowValue(true);
|
||||||
gui_fftAmpBeginFrac.setLimits(0.3, 0.0, 1.0);
|
gui_fftAmpBeginFrac.setLimits(0.3, 0.0, 1.0);
|
||||||
gui_fftAmpBeginFrac.setNumberFormat(G4P.DECIMAL, 2);
|
gui_fftAmpBeginFrac.setNumberFormat(G4P.DECIMAL, 2);
|
||||||
gui_fftAmpBeginFrac.setOpaque(true);
|
gui_fftAmpBeginFrac.setOpaque(true);
|
||||||
gui_fftAmpBeginFrac.addEventHandler(this, "gui_fftAmpBeginFrac_change");
|
gui_fftAmpBeginFrac.addEventHandler(this, "gui_fftAmpBeginFrac_change");
|
||||||
gui_baseAmp = new GSlider(this, 20, 230, 180, 40, 10.0);
|
gui_baseAmp = new GSlider(this, 20, 210, 180, 40, 10.0);
|
||||||
gui_baseAmp.setShowValue(true);
|
gui_baseAmp.setShowValue(true);
|
||||||
gui_baseAmp.setLimits(30.0, 1.0, 100.0);
|
gui_baseAmp.setLimits(30.0, 1.0, 100.0);
|
||||||
gui_baseAmp.setNumberFormat(G4P.DECIMAL, 2);
|
gui_baseAmp.setNumberFormat(G4P.DECIMAL, 2);
|
||||||
gui_baseAmp.setOpaque(true);
|
gui_baseAmp.setOpaque(true);
|
||||||
gui_baseAmp.addEventHandler(this, "gui_baseAmp_change");
|
gui_baseAmp.addEventHandler(this, "gui_baseAmp_change");
|
||||||
label5 = new GLabel(this, 20, 350, 180, 20);
|
label5 = new GLabel(this, 20, 310, 180, 20);
|
||||||
label5.setText("amp step");
|
label5.setText("amp step");
|
||||||
label5.setOpaque(true);
|
label5.setOpaque(true);
|
||||||
gui_ampStart = new GSlider(this, 20, 300, 180, 40, 10.0);
|
gui_ampStart = new GSlider(this, 20, 270, 180, 40, 10.0);
|
||||||
gui_ampStart.setShowValue(true);
|
gui_ampStart.setShowValue(true);
|
||||||
gui_ampStart.setLimits(0.05, 0.005, 0.2);
|
gui_ampStart.setLimits(0.05, 0.005, 0.2);
|
||||||
gui_ampStart.setNumberFormat(G4P.DECIMAL, 3);
|
gui_ampStart.setNumberFormat(G4P.DECIMAL, 3);
|
||||||
gui_ampStart.setOpaque(true);
|
gui_ampStart.setOpaque(true);
|
||||||
gui_ampStart.addEventHandler(this, "gui_ampStart_change");
|
gui_ampStart.addEventHandler(this, "gui_ampStart_change");
|
||||||
gui_ampStep = new GSlider(this, 20, 370, 180, 40, 10.0);
|
gui_ampStep = new GSlider(this, 20, 330, 180, 40, 10.0);
|
||||||
gui_ampStep.setShowValue(true);
|
gui_ampStep.setShowValue(true);
|
||||||
gui_ampStep.setLimits(0.02, 0.005, 0.2);
|
gui_ampStep.setLimits(0.02, 0.005, 0.2);
|
||||||
gui_ampStep.setNumberFormat(G4P.DECIMAL, 3);
|
gui_ampStep.setNumberFormat(G4P.DECIMAL, 3);
|
||||||
|
@ -126,17 +126,17 @@ public void createGUI(){
|
||||||
gui_beatDecay.addEventHandler(this, "gui_beatDecay_change");
|
gui_beatDecay.addEventHandler(this, "gui_beatDecay_change");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Variable declarations
|
// Variable declarations
|
||||||
// autogenerated do not edit
|
// autogenerated do not edit
|
||||||
GDropList gui_fftWindowing;
|
GDropList gui_fftWindowing;
|
||||||
GLabel label1;
|
GLabel label1;
|
||||||
GLabel label2;
|
GLabel label2;
|
||||||
GLabel label3;
|
GLabel label3;
|
||||||
GLabel label4;
|
GLabel label4;
|
||||||
GSlider gui_fftAmpBeginFrac;
|
GSlider gui_fftAmpBeginFrac;
|
||||||
GSlider gui_baseAmp;
|
GSlider gui_baseAmp;
|
||||||
GLabel label5;
|
GLabel label5;
|
||||||
GSlider gui_ampStart;
|
GSlider gui_ampStart;
|
||||||
GSlider gui_ampStep;
|
GSlider gui_ampStep;
|
||||||
GLabel label6;
|
GLabel label6;
|
||||||
GSlider gui_beatDecay;
|
GSlider gui_beatDecay;
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
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 (chkmsg(msgIn, "/slider_group1")) {
|
||||||
|
setBeatDecay(msgIn.get(0).floatValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (chkmsg(msgIn, "/slider_group2")) {
|
||||||
|
setAmpBeginFraction(msgIn.get(0).floatValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (chkmsg(msgIn, "/knob_group1")) {
|
||||||
|
setAmpStart(msgIn.get(0).floatValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (chkmsg(msgIn, "/knob_group2")) {
|
||||||
|
setAmpStep(msgIn.get(0).floatValue());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
float last_beat = 0;
|
||||||
|
void oscSendBeatValue(float beat) {
|
||||||
|
if ( beat != last_beat ) {
|
||||||
|
OscMessage msg = new OscMessage("/osc_beat_val");
|
||||||
|
msg.add(beat);
|
||||||
|
oscObj.send(msg, shaderNetAddress);
|
||||||
|
last_beat = beat;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean chkmsg(OscMessage msg, String name) {
|
||||||
|
return msg.checkAddrPattern(name) && msg.checkTypetag("f");
|
||||||
|
}
|
|
@ -22,10 +22,12 @@ void setupAudioAnalysis() {
|
||||||
// fft setup
|
// fft setup
|
||||||
myFFT = new FFT(myAudio.bufferSize(), myAudio.sampleRate());
|
myFFT = new FFT(myAudio.bufferSize(), myAudio.sampleRate());
|
||||||
myFFT.logAverages(22, 12); // (22,12) -> 120 averages
|
myFFT.logAverages(22, 12); // (22,12) -> 120 averages
|
||||||
myFFT.window(FFT.NONE);
|
myFFT.window(FFT.HANN); // good for "random" signals
|
||||||
|
|
||||||
// debug
|
// debug
|
||||||
|
println(".");
|
||||||
println("[debug][audio]: number of fft bins: "+myFFT.avgSize());
|
println("[debug][audio]: number of fft bins: "+myFFT.avgSize());
|
||||||
|
println(".");
|
||||||
}
|
}
|
||||||
|
|
||||||
void drawAudioAnalysis() {
|
void drawAudioAnalysis() {
|
||||||
|
|
Loading…
Reference in New Issue