drawSpectrum enchancements and improvements.
parent
f38675e511
commit
6f5ee8300c
|
@ -77,6 +77,13 @@ ArrayList<FloatList> siLinesData;
|
||||||
|
|
||||||
// drawSpectrum
|
// drawSpectrum
|
||||||
float drawSpectrumAFactor;
|
float drawSpectrumAFactor;
|
||||||
|
int drawSpectrumThreshold;
|
||||||
|
int drawSpectrumHeight;
|
||||||
|
int drawSpectrumWidth;
|
||||||
|
float drawSpectrumAwidth;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////
|
///////////////////////////////////////////////////////////////////////////////
|
||||||
void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
@ -169,7 +176,7 @@ void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
// clean screen ````````````````````````````````````````````````````|
|
// clean screen ````````````````````````````````````````````````````|
|
||||||
blendMode(BLEND);
|
//blendMode(BLEND);
|
||||||
screenClean(color(0));
|
screenClean(color(0));
|
||||||
|
|
||||||
|
|
||||||
|
@ -181,9 +188,11 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
||||||
// drawSpectrum
|
// drawSpectrum
|
||||||
drawSpectrum(boolean(1),
|
drawSpectrum(boolean(1),
|
||||||
siLinesData, // ArrayList<FloatList> 2D data
|
siLinesData, // ArrayList<FloatList> 2D data
|
||||||
0, // threshold 0-1000 (1000 = nothing)
|
drawSpectrumThreshold, // threshold 0-1000 (1000 = nothing)
|
||||||
drawSpectrumAFactor, // alpha factor (58 = 1)
|
drawSpectrumAFactor, // alpha factor (58 = 1)
|
||||||
127 // line height
|
drawSpectrumHeight, // line height
|
||||||
|
drawSpectrumWidth, // line height
|
||||||
|
drawSpectrumAwidth // alpha->width amp
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -16,12 +16,22 @@ void drawSpectrum(boolean render,
|
||||||
ArrayList<FloatList> siLinesData,
|
ArrayList<FloatList> siLinesData,
|
||||||
int threshold,
|
int threshold,
|
||||||
float afactor,
|
float afactor,
|
||||||
float line_height)
|
int line_height,
|
||||||
|
int rect_width,
|
||||||
|
float alpha_width)
|
||||||
{
|
{
|
||||||
if (render) {
|
if (render) {
|
||||||
|
// if((frameCount%60) < 1) { println("width: " + width); }; // DEBUG
|
||||||
|
|
||||||
//float afactor = float(afactor);
|
//float afactor = float(afactor);
|
||||||
afactor = map(pow(afactor, 5), 0, pow(127, 5), 0, 50 );
|
afactor = map(pow(afactor, 5), 0, pow(127, 5), 0, 50 );
|
||||||
line_height = map(line_height, 0, 127, 0, height/2);
|
line_height = int(map(line_height, 0, 127, 0, height/2));
|
||||||
|
threshold = int(map(pow(threshold, 3), 0, pow(127, 3), 0, 1000));
|
||||||
|
line_height = int(map(line_height, 0, 127, 0, height * 0.5));
|
||||||
|
rect_width = int(map(rect_width, 0, 127, 1, 400));
|
||||||
|
alpha_width = map(alpha_width, 0, 127, 0, 0.1);
|
||||||
|
// DEBUG:
|
||||||
|
// if((frameCount%60) < 1) { println("width: " + width); }; // DEBUG
|
||||||
|
|
||||||
for (int i = 0; i < siLinesData.size(); i++) {
|
for (int i = 0; i < siLinesData.size(); i++) {
|
||||||
if (siLinesData.get(i).get(1) > threshold) {
|
if (siLinesData.get(i).get(1) > threshold) {
|
||||||
|
@ -33,9 +43,15 @@ void drawSpectrum(boolean render,
|
||||||
float alpha = map(intensity, 0, 1000, 0, 255) * afactor;
|
float alpha = map(intensity, 0, 1000, 0, 255) * afactor;
|
||||||
color line_c = color(red, green, blue, alpha);
|
color line_c = color(red, green, blue, alpha);
|
||||||
|
|
||||||
stroke(line_c);
|
|
||||||
line(map(wavelength, 3950, 6741, 1, width), height/2 - line_height,
|
fill(line_c); noStroke();
|
||||||
map(wavelength, 3950, 6741, 1, width), height/2 + line_height);
|
rectMode(CENTER);
|
||||||
|
rect(map(wavelength, 3950, 6741, 1, width), height / 2, rect_width + (alpha * alpha_width), line_height/2 );
|
||||||
|
|
||||||
|
|
||||||
|
// stroke(line_c);
|
||||||
|
// line(map(wavelength, 3950, 6741, 1, width), height/2 - line_height,
|
||||||
|
// map(wavelength, 3950, 6741, 1, width), height/2 + line_height);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -26,9 +26,11 @@ void shuffle(int[] a)
|
||||||
}
|
}
|
||||||
|
|
||||||
void screenClean(color c) { // -----------------------------------------
|
void screenClean(color c) { // -----------------------------------------
|
||||||
|
// flickr? frameCount % var, amount towards black
|
||||||
fill(c);
|
fill(c);
|
||||||
noStroke();
|
noStroke();
|
||||||
rect(0, 0, width, height);
|
rectMode(CORNER);
|
||||||
|
rect(0, 0, width * 2, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -9,31 +9,27 @@
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
//_____________________________________________________________________________
|
||||||
|
void ctlin(int cc, int val) { // midi control values, from Renoise (via SC)
|
||||||
|
|
||||||
void ctlin(int cc, int val) {
|
// debug:
|
||||||
// public void ctlin(int cc, int val) {
|
|
||||||
// midi control values, from Renoise (via SC)
|
|
||||||
|
|
||||||
// debug
|
|
||||||
// println("### OSC: /ctlin cc:" + cc + " value:" + val);
|
// println("### OSC: /ctlin cc:" + cc + " value:" + val);
|
||||||
|
|
||||||
// patchbay
|
// patchbay
|
||||||
if (cc == 2) { tilesOverlap = val; }
|
if (cc == 2) { tilesOverlap = val; }
|
||||||
if (cc == 10) { drawSpectrumAFactor = val; }
|
if (cc == 10) { drawSpectrumAFactor = val; }
|
||||||
|
if (cc == 11) { drawSpectrumThreshold = val; }
|
||||||
// example:
|
if (cc == 12) { drawSpectrumHeight = val; }
|
||||||
// if (cc == 2) { flySpeedXfactor = (val - 64); }
|
if (cc == 13) { drawSpectrumWidth = val; }
|
||||||
|
if (cc == 14) { drawSpectrumAwidth = val; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// ____________________________________________________________________________
|
||||||
|
void scosc(String mount, int val) { // stuff coming directly from SuperCollider
|
||||||
|
|
||||||
|
// debug:
|
||||||
void scosc(String mount, int val) {
|
|
||||||
// public void scosc(String mount, int val) {
|
|
||||||
// stuff coming directly from SuperCollider
|
|
||||||
|
|
||||||
// debug
|
|
||||||
// println("### OSC: /sc mount:" + mount + " value:" + val);
|
// println("### OSC: /sc mount:" + mount + " value:" + val);
|
||||||
|
|
||||||
// patchbay
|
// patchbay
|
||||||
|
@ -41,6 +37,6 @@ void scosc(String mount, int val) {
|
||||||
if (mount.equals("testPictureToggle")) { testPictureToggle = boolean(val); }
|
if (mount.equals("testPictureToggle")) { testPictureToggle = boolean(val); }
|
||||||
|
|
||||||
|
|
||||||
}
|
} // - - - - - - - - - - - - - - - - - - - -
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -186,9 +186,9 @@ postln("~~~ function ~viewLinesFunc ...");
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
( // DEBUG/test:
|
(
|
||||||
|
|
||||||
~postLines = {
|
~postLines = { // print data in post window, NICELY!
|
||||||
|
|
||||||
// display table of all data to post window
|
// display table of all data to post window
|
||||||
~siLinesData.do({ |item, i|
|
~siLinesData.do({ |item, i|
|
||||||
|
@ -233,8 +233,14 @@ postln("~~~ function ~viewLinesFunc ...");
|
||||||
post(" ");
|
post(" ");
|
||||||
post(item[10].asString.padLeft(3));
|
post(item[10].asString.padLeft(3));
|
||||||
post(" | ");
|
post(" | ");
|
||||||
//post(item[14] //.asString.padLeft(3)
|
post(item[11].asString.padLeft(3));
|
||||||
//);
|
post(" ");
|
||||||
|
post(item[12].asString.padLeft(3));
|
||||||
|
post(" ");
|
||||||
|
post(item[13].asString.padLeft(3));
|
||||||
|
post(" | ");
|
||||||
|
post(item[14] //.asString.padLeft(3)
|
||||||
|
);
|
||||||
/*
|
/*
|
||||||
post(" |||");
|
post(" |||");
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue