From 6f5ee8300c264fba293acb51dfe01c08c33af687 Mon Sep 17 00:00:00 2001 From: Nova deViator Date: Sun, 13 Sep 2015 13:50:46 +0200 Subject: [PATCH] drawSpectrum enchancements and improvements. --- pde/IF3Si/IF3Si.pde | 17 +++++++++++++---- pde/IF3Si/drawSpectrum.pde | 28 ++++++++++++++++++++++------ pde/IF3Si/functions.pde | 4 +++- pde/IF3Si/osc.pde | 28 ++++++++++++---------------- scd/snd_lines.scd | 16 +++++++++++----- 5 files changed, 61 insertions(+), 32 deletions(-) diff --git a/pde/IF3Si/IF3Si.pde b/pde/IF3Si/IF3Si.pde index 4249862..162e6ce 100644 --- a/pde/IF3Si/IF3Si.pde +++ b/pde/IF3Si/IF3Si.pde @@ -77,6 +77,13 @@ ArrayList 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 2D data - 0, // threshold 0-1000 (1000 = nothing) - drawSpectrumAFactor, // alpha factor (58 = 1) - 127 // line height + drawSpectrumThreshold, // threshold 0-1000 (1000 = nothing) + drawSpectrumAFactor, // alpha factor (58 = 1) + drawSpectrumHeight, // line height + drawSpectrumWidth, // line height + drawSpectrumAwidth // alpha->width amp ); diff --git a/pde/IF3Si/drawSpectrum.pde b/pde/IF3Si/drawSpectrum.pde index 2868d9b..1072f48 100644 --- a/pde/IF3Si/drawSpectrum.pde +++ b/pde/IF3Si/drawSpectrum.pde @@ -16,13 +16,23 @@ void drawSpectrum(boolean render, ArrayList 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) { float wavelength = siLinesData.get(i).get(0); @@ -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); } } diff --git a/pde/IF3Si/functions.pde b/pde/IF3Si/functions.pde index 8f86ed0..631e955 100644 --- a/pde/IF3Si/functions.pde +++ b/pde/IF3Si/functions.pde @@ -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); } diff --git a/pde/IF3Si/osc.pde b/pde/IF3Si/osc.pde index e111dd7..50e4da1 100644 --- a/pde/IF3Si/osc.pde +++ b/pde/IF3Si/osc.pde @@ -9,31 +9,27 @@ */ - -void ctlin(int cc, int val) { -// public void ctlin(int cc, int val) { - // midi control values, from Renoise (via SC) +//_____________________________________________________________________________ +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) { -// public void scosc(String mount, int val) { - // stuff coming directly from SuperCollider +// ____________________________________________________________________________ +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); } -} +} // - - - - - - - - - - - - - - - - - - - - diff --git a/scd/snd_lines.scd b/scd/snd_lines.scd index ccf4b6e..4b785a4 100644 --- a/scd/snd_lines.scd +++ b/scd/snd_lines.scd @@ -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(" |||");