just stuck. moving nowhere. moved drawSpectrum to new file

master
Nova deViator 2015-09-12 22:04:20 +02:00
parent ffff4ad562
commit f38675e511
3 changed files with 112 additions and 21 deletions

View File

@ -175,20 +175,13 @@ void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
// SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / | // SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / |
// drawSpectrum // drawSpectrum
drawSpectrum(boolean(1), drawSpectrum(boolean(1),
siLinesData, // ArrayList<FloatList> 2D data siLinesData, // ArrayList<FloatList> 2D data
0, // threshold 0, // threshold 0-1000 (1000 = nothing)
drawSpectrumAFactor, // alpha factor (58 = 1) drawSpectrumAFactor, // alpha factor (58 = 1)
127 // line height 127 // line height
); );

View File

@ -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<FloatList> 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);
}
}
}
}

View File

@ -185,22 +185,77 @@ postln("~~~ function ~viewLinesFunc ...");
/*
( // DEBUG/test: ( // DEBUG/test:
~postLines = {
// display table of all data to post window // display table of all data to post window
~siLinesData.do({ |item, i| ~siLinesData.do({ |item, i|
post(i + ""); var minutes = (item[0]/60).asInt;
item.do({ |value, i| var seconds = (item[0]%60).asInt;
post(i);
post(":"); if (item[3].asInt > 99, {
post(value);
// post("[");
// post(i.asString.padLeft(3));
// post("] ");
post(item[1]);
post(" "); 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;
) )
*/