From f38675e511fbe83a09982f8fe1de098d1c80d454 Mon Sep 17 00:00:00 2001 From: Nova deViator Date: Sat, 12 Sep 2015 22:04:20 +0200 Subject: [PATCH] just stuck. moving nowhere. moved drawSpectrum to new file --- pde/IF3Si/IF3Si.pde | 9 +---- pde/IF3Si/drawSpectrum.pde | 43 ++++++++++++++++++++ scd/snd_lines.scd | 81 ++++++++++++++++++++++++++++++++------ 3 files changed, 112 insertions(+), 21 deletions(-) create mode 100644 pde/IF3Si/drawSpectrum.pde diff --git a/pde/IF3Si/IF3Si.pde b/pde/IF3Si/IF3Si.pde index 412ae78..4249862 100644 --- a/pde/IF3Si/IF3Si.pde +++ b/pde/IF3Si/IF3Si.pde @@ -174,13 +174,6 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / | @@ -188,7 +181,7 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // drawSpectrum drawSpectrum(boolean(1), siLinesData, // ArrayList 2D data - 0, // threshold + 0, // threshold 0-1000 (1000 = nothing) drawSpectrumAFactor, // alpha factor (58 = 1) 127 // line height ); diff --git a/pde/IF3Si/drawSpectrum.pde b/pde/IF3Si/drawSpectrum.pde new file mode 100644 index 0000000..2868d9b --- /dev/null +++ b/pde/IF3Si/drawSpectrum.pde @@ -0,0 +1,43 @@ +/* + + This file is part of "Interface Fractures III - Silicon". + Copyright (c) 2015 Luka Prinčič, All rights reserved. + This program is free software distributed under + GNU General Public Licence. See COPYING for more info. + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + drawSpectrum.pde - draw spectral lines + +*/ + + + +void drawSpectrum(boolean render, + ArrayList siLinesData, + int threshold, + float afactor, + float line_height) +{ + if (render) { + //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); + + for (int i = 0; i < siLinesData.size(); i++) { + if (siLinesData.get(i).get(1) > threshold) { + float wavelength = siLinesData.get(i).get(0); + float intensity = siLinesData.get(i).get(1); + float red = siLinesData.get(i).get(2); + float green = siLinesData.get(i).get(3); + float blue = siLinesData.get(i).get(4); + 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); + } + } + + } +} diff --git a/scd/snd_lines.scd b/scd/snd_lines.scd index da54338..ccf4b6e 100644 --- a/scd/snd_lines.scd +++ b/scd/snd_lines.scd @@ -185,22 +185,77 @@ postln("~~~ function ~viewLinesFunc ..."); -/* -( // DEBUG/test: -// display table of all data to post window -~siLinesData.do({ |item, i| - post(i + ""); - item.do({ |value, i| - post(i); - post(":"); - post(value); - post(" "); +( // DEBUG/test: + +~postLines = { + + // display table of all data to post window + ~siLinesData.do({ |item, i| + var minutes = (item[0]/60).asInt; + var seconds = (item[0]%60).asInt; + + if (item[3].asInt > 99, { + + // post("["); + // post(i.asString.padLeft(3)); + // post("] "); + + post(item[1]); + post(" "); + + post(item[3].asString.padLeft(4)); + post(" "); + + if (minutes < 10, { minutes = "0" ++ minutes.asString;}); + post(minutes); + post(":"); + if (seconds < 10, { seconds = "0" ++ seconds.asString; }); + post(seconds); + //post(i); + post(" "); + + + + post(item[4].asString.padLeft(5)); + post("Hz "); + post(item[5].asString.padLeft(5)); + post("Hz "); + + post(item[6].asString.padLeft(5)); // midi1 + post(" "); + post(item[7].asString.padLeft(5)); // midi2 + post(" | "); + + post(item[8].asString.padLeft(3)); + post(" "); + post(item[9].asString.padLeft(3)); + post(" "); + post(item[10].asString.padLeft(3)); + post(" |"); + //post(item[14] //.asString.padLeft(3) + //); + /* + post(" |||"); + + item.do({ |value, i| + //post(i); + post(Char.tab); + post(value.asFloat.round(1)); + post(" "); + + });*/ + post("\n"); + }); }); - post("\n"); -}); + +}; + + +~postLines.value; + ) -*/ +