drawSpectrum enchancements and improvements.

master
Nova deViator 2015-09-13 13:50:46 +02:00
parent f38675e511
commit 6f5ee8300c
5 changed files with 61 additions and 32 deletions

View File

@ -77,6 +77,13 @@ ArrayList<FloatList> siLinesData;
// drawSpectrum
float drawSpectrumAFactor;
int drawSpectrumThreshold;
int drawSpectrumHeight;
int drawSpectrumWidth;
float drawSpectrumAwidth;
///////////////////////////////////////////////////////////////////////////////
void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
@ -169,7 +176,7 @@ void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// clean screen ````````````````````````````````````````````````````|
blendMode(BLEND);
//blendMode(BLEND);
screenClean(color(0));
@ -181,9 +188,11 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// drawSpectrum
drawSpectrum(boolean(1),
siLinesData, // ArrayList<FloatList> 2D data
0, // threshold 0-1000 (1000 = nothing)
drawSpectrumThreshold, // threshold 0-1000 (1000 = nothing)
drawSpectrumAFactor, // alpha factor (58 = 1)
127 // line height
drawSpectrumHeight, // line height
drawSpectrumWidth, // line height
drawSpectrumAwidth // alpha->width amp
);

View File

@ -16,12 +16,22 @@ void drawSpectrum(boolean render,
ArrayList<FloatList> siLinesData,
int threshold,
float afactor,
float line_height)
int line_height,
int rect_width,
float alpha_width)
{
if (render) {
// if((frameCount%60) < 1) { println("width: " + width); }; // DEBUG
//float afactor = float(afactor);
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++) {
if (siLinesData.get(i).get(1) > threshold) {
@ -33,9 +43,15 @@ void drawSpectrum(boolean render,
float alpha = map(intensity, 0, 1000, 0, 255) * afactor;
color line_c = color(red, green, blue, alpha);
stroke(line_c);
line(map(wavelength, 3950, 6741, 1, width), height/2 - line_height,
map(wavelength, 3950, 6741, 1, width), height/2 + line_height);
fill(line_c); noStroke();
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);
}
}

View File

@ -26,9 +26,11 @@ void shuffle(int[] a)
}
void screenClean(color c) { // -----------------------------------------
// flickr? frameCount % var, amount towards black
fill(c);
noStroke();
rect(0, 0, width, height);
rectMode(CORNER);
rect(0, 0, width * 2, height);
}

View File

@ -9,31 +9,27 @@
*/
//_____________________________________________________________________________
void ctlin(int cc, int val) { // midi control values, from Renoise (via SC)
void ctlin(int cc, int val) {
// public void ctlin(int cc, int val) {
// midi control values, from Renoise (via SC)
// debug
// debug:
// println("### OSC: /ctlin cc:" + cc + " value:" + val);
// patchbay
if (cc == 2) { tilesOverlap = val; }
if (cc == 10) { drawSpectrumAFactor = val; }
// example:
// if (cc == 2) { flySpeedXfactor = (val - 64); }
if (cc == 11) { drawSpectrumThreshold = val; }
if (cc == 12) { drawSpectrumHeight = val; }
if (cc == 13) { drawSpectrumWidth = val; }
if (cc == 14) { drawSpectrumAwidth = val; }
}
// ____________________________________________________________________________
void scosc(String mount, int val) { // stuff coming directly from SuperCollider
void scosc(String mount, int val) {
// public void scosc(String mount, int val) {
// stuff coming directly from SuperCollider
// debug
// debug:
// println("### OSC: /sc mount:" + mount + " value:" + val);
// patchbay
@ -41,6 +37,6 @@ void scosc(String mount, int val) {
if (mount.equals("testPictureToggle")) { testPictureToggle = boolean(val); }
}
} // - - - - - - - - - - - - - - - - - - - -

View File

@ -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
~siLinesData.do({ |item, i|
@ -232,9 +232,15 @@ postln("~~~ function ~viewLinesFunc ...");
post(item[9].asString.padLeft(3));
post(" ");
post(item[10].asString.padLeft(3));
post(" |");
//post(item[14] //.asString.padLeft(3)
//);
post(" | ");
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(" |||");