From fa5e51d9b14abbd0ded17766ba10cd726d8ae0b2 Mon Sep 17 00:00:00 2001 From: Nova deViator Date: Thu, 24 Sep 2015 09:28:56 +0200 Subject: [PATCH] final 0.9 beta state --- pde/IF3Si/IF3Si.pde | 258 ------------------------------------- pde/IF3Si/drawSpectrum.pde | 21 ++- pde/IF3Si/functions.pde | 29 ++++- pde/IF3Si/getImages.pde | 16 ++- pde/IF3Si/osc.pde | 42 +++++- pde/IF3Si/testPicture.pde | 6 +- pde/IF3Si/tiles.pde | 27 +++- scd/gui_core.scd | 4 +- scd/gui_main.scd | 12 ++ scd/snd_lines.scd | 70 +++++----- 10 files changed, 173 insertions(+), 312 deletions(-) delete mode 100644 pde/IF3Si/IF3Si.pde diff --git a/pde/IF3Si/IF3Si.pde b/pde/IF3Si/IF3Si.pde deleted file mode 100644 index 162e6ce..0000000 --- a/pde/IF3Si/IF3Si.pde +++ /dev/null @@ -1,258 +0,0 @@ -/* - - 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. - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - IF3Si.pde - - */ - - -// undecorate window (remove window borders etc) - - - - - - - - - - - - - - - -public void init() { frame.removeNotify(); frame.setUndecorated(true); - frame.addNotify(); super.init(); } - -// load libs -import oscP5.*; // Open Sound Control -import netP5.*; - - -// declarations - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -// declare OSC object -OscP5 oscP5; - - -// IMAGE POOL, a 2D array -PImage[][] imgPool; - -// texture (tiles) -float texX = 0; -float texY = 0; - -// generate an array of random numbers -int[] rands = new int[500]; -IntList randz; // arrayList - -// for draw cube -int cubesnum = 20; -PGraphics[] cubes = new PGraphics[cubesnum]; -PShader blur; -PGraphics bpass1, bpass2; - -// spheres -int ptsW, ptsH; - -int numPointsW; -int numPointsH_2pi; -int numPointsH; - -float[] coorX; -float[] coorY; -float[] coorZ; -float[] multXZ; - -PGraphics sphere; - -// tiles -int tilesOverlap; - -// testPicture -boolean testPictureToggle = false; -PFont testFont; - -// testPattern -boolean testPatternToggle = false; - - -// fps -PFont fpsFont; - - -// siLines -ArrayList siLinesData; - -// drawSpectrum -float drawSpectrumAFactor; -int drawSpectrumThreshold; -int drawSpectrumHeight; -int drawSpectrumWidth; -float drawSpectrumAwidth; - - - - -/////////////////////////////////////////////////////////////////////////////// -void setup() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - float sizefactor = 1; // define the size of the screen, 1 = 1080p - size( int( 1920 * sizefactor ), - int( 1080 * sizefactor ), - P3D ); // renderer - - // framerate - frameRate(60); - smooth(32); // 32?? - noCursor(); - background(0); - - println("\n\n~~~ Hello. Starting Interface Fractures III - SILICON." + - " - - - - - - - - - - - - - - - - - - - - - -\n"); - - - // open sound control - oscP5 = new OscP5(this,12000); // listening at port 12000 - println("~~~ starting oscP5 ..."); - oscP5.plug(this,"ctlin","/ctlin"); // osc from Renoise/Midi (via SC) -> function 'ctlin' - oscP5.plug(this,"scosc","/sc"); // osc from SuperCollider -> function 'scosc' - - // get all textures into an image pool - println("\n\n~~~ loading textures into image pool ...\n"); - imgPool = getImages("/images/"); - - - - - // ---------------------------------------------------------------------- - println("~~~ getting and processing lines data ..."); - //siLinesData = new ArrayList(); - siLinesData = getLinesData(); // function, returns an ArrayList - //printArray(siLinesData); - - - // ---------------------------------------------------------------------- - - - // create an array of random value between -50 and 50 - for (int i=0; i < 500; i++) { rands[i] = i-250; } - shuffle(rands); - - - // drawCube ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` ` - // an array of PGraphics - for (int i = 0; i < cubesnum; i++) { - cubes[i] = createGraphics(width, height, P3D); - } - blur = loadShader("blur.glsl"); - bpass1 = createGraphics(width, height, P3D); - bpass1.smooth(); - bpass2 = createGraphics(width, height, P3D); - bpass2.smooth(); - - - randz = new IntList(width); - for (int i=0; i < width; i++) { - randz.set(i, i); - } - randz.shuffle(); - //println(randz); - - // spheres - ptsW=30; - ptsH=30; - initializeSphere(ptsW, ptsH); // number of vertices around the width and height - sphere = createGraphics(width, height, P3D); - - // for testPicture - //String[] fontList = PFont.list(); - //printArray(fontList); - testFont = createFont("Oliver's Barney", 50); - - // fps - fpsFont = createFont("Ubuntu Mono", 16); - - - - - -} - - - -////////////////////////////////////////////////////////////////////////////// -void draw() { // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - // clean screen ````````````````````````````````````````````````````| - //blendMode(BLEND); - screenClean(color(0)); - - - - - // SCENENGINES / / / / / / / / / / / / / / / / / / / / / / / / / / | - - - // drawSpectrum - drawSpectrum(boolean(1), - siLinesData, // ArrayList 2D data - drawSpectrumThreshold, // threshold 0-1000 (1000 = nothing) - drawSpectrumAFactor, // alpha factor (58 = 1) - drawSpectrumHeight, // line height - drawSpectrumWidth, // line height - drawSpectrumAwidth // alpha->width amp - ); - - - // draw spheress```````````````````````````````````````````````````| - drawSpheres(boolean(0) - ); - - - - // draw tiles `````````````````````````````````````````````````````| - tiles(boolean(0), // render on/off - color(0, 0, 0, 80), // background color (HSBA) - color(80, 70, 20, 100), // tile color - 20, // tile hue distance - 0, // blendMode - 6, // number of tiles on X axis - 1, // number of tiles on Y axis - 2, // texture bank number - 0, // texture number/id - 10, // texture speed X - 1, // texture speed Y - tilesOverlap // overlap. 127 = 300% - ); - - - - // draw cubes `````````````````````````````````````````````````````| - drawCube(boolean(0), cubes, - 100, height/2, -100, - 400, 300, 300, - radians(frameCount), radians(frameCount*0.7), PI/2, - 0); - - - - // test pattern```````````````````````````````````````````````````| - - - testPattern(testPatternToggle, // boolean(0), // on/off - 2, 0, // img bank & ID - 255, // image alpha - 10, // number of horizontal 'lanes' - 10, // density - 4, // stroke width - 255, // stroke alpha - 2 // speed - ); - - - // debug `````````````````````````````````````````````````````````| - // draw test picture - testPicture(testPictureToggle); - - // frames per second - displayFps(true); - - // document - autoSnap(false); - -} // -------------------------------------------------------------------------- - - - diff --git a/pde/IF3Si/drawSpectrum.pde b/pde/IF3Si/drawSpectrum.pde index 1072f48..a042b6f 100644 --- a/pde/IF3Si/drawSpectrum.pde +++ b/pde/IF3Si/drawSpectrum.pde @@ -18,20 +18,23 @@ void drawSpectrum(boolean render, float afactor, int line_height, int rect_width, - float alpha_width) + float alpha_width, + float saturation) { 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 = int(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)); + //if((frameCount%60) < 1) { println("line_height: " + line_height); }; // DEBUG + line_height = int(map(pow(line_height,2), 0, pow(127,2), 0, height)); rect_width = int(map(rect_width, 0, 127, 1, 400)); - alpha_width = map(alpha_width, 0, 127, 0, 0.1); + alpha_width = map(alpha_width, 0, 127, 0, 0.1); + saturation = map(saturation, 0, 127, 0, 255); // DEBUG: - // if((frameCount%60) < 1) { println("width: " + width); }; // DEBUG + //if((frameCount%60) < 1) { println("line_height: " + line_height); }; // DEBUG for (int i = 0; i < siLinesData.size(); i++) { if (siLinesData.get(i).get(1) > threshold) { @@ -41,12 +44,18 @@ void drawSpectrum(boolean render, float green = siLinesData.get(i).get(3); float blue = siLinesData.get(i).get(4); float alpha = map(intensity, 0, 1000, 0, 255) * afactor; + colorMode(RGB); color line_c = color(red, green, blue, alpha); + colorMode(HSB); + float hue = hue(line_c); + float brightness = brightness(line_c); + line_c = color(hue, saturation, brightness, alpha); + fill(line_c); noStroke(); rectMode(CENTER); - rect(map(wavelength, 3950, 6741, 1, width), height / 2, rect_width + (alpha * alpha_width), line_height/2 ); + rect(map(wavelength, 3950, 6741, 1, width), height / 2, rect_width + (alpha * alpha_width), line_height ); // stroke(line_c); diff --git a/pde/IF3Si/functions.pde b/pde/IF3Si/functions.pde index 631e955..99b95ff 100644 --- a/pde/IF3Si/functions.pde +++ b/pde/IF3Si/functions.pde @@ -25,8 +25,32 @@ void shuffle(int[] a) } } -void screenClean(color c) { // ----------------------------------------- +// if screenClean is supposed to "clean" the screen +// alpha should always be to the max +void screenClean(float hue, + float saturation, + float brightness, + float alpha, + float flickrAmount, + float flickrSpeed) +{ + hue = map(hue, 0, 127, 0, 255); + saturation = map(saturation, 0, 127, 0, 255); + brightness = map(brightness, 0, 127, 0, 255); + alpha = map(alpha, 0, 127, 0, 255); + + flickrAmount = map(flickrAmount, 0, 127, 0, 1); + flickrSpeed = map(flickrSpeed, 0, 127, 1, 120); + if ((frameCount % int(flickrSpeed)) == 0) { + brightness = brightness * flickrAmount; + } + //println(frameCount + " " + flickrSpeed + " " + (frameCount % flickrSpeed)); + + colorMode(HSB); + color c = color(hue, saturation, brightness, alpha); + // flickr? frameCount % var, amount towards black + fill(c); noStroke(); rectMode(CORNER); @@ -42,9 +66,10 @@ void displayFps(boolean render) { // ----------------------------------- fill(255); textFont(fpsFont); textSize(16); - text(int(frameRate)+"fps", width-60, 20, 5);} + text(round(frameRate) + "fps", width-60, 20, 5);} } + void autoSnap(boolean render) { // ------------------------------------- if (render) { // auto-save snapshots diff --git a/pde/IF3Si/getImages.pde b/pde/IF3Si/getImages.pde index f707748..fdd39ee 100644 --- a/pde/IF3Si/getImages.pde +++ b/pde/IF3Si/getImages.pde @@ -11,25 +11,31 @@ // loads all images into an array - - - - - - - - - - - - - - - - - - - - - - - - - PImage[][] getImages(String folder) { +//ArrayList getImages(String folder) { PImage[][] imgPool; // declare 2D array imgPool + //ArrayList imgPool; + File dir = new File(dataPath(sketchPath + folder)); // first folder String[] dirlist = dir.list(); // an array of folders (strings) dirlist = sort(dirlist); // - imgPool = new PImage[dirlist.length][10]; // create 2d array imgPool - + //imgPool = new ArrayList(); + imgPool = new PImage[dirlist.length][100]; // create 2d array imgPool for (int i = 0; i < dirlist.length; i++) { String fulldir = dataPath(sketchPath + folder + dirlist[i]) + "/"; File dir2 = new File(fulldir); String[] filelist = dir2.list(); // an array of image names filelist = sort(filelist); - + println("\n~~~ BANK no." + i + ": " + dirlist[i]); + if (filelist.length != 0) { + imgPool[i] = (PImage[]) expand(imgPool[i], filelist.length); + // geez: ^^^^^^^^^^ !!!!! for (int j = 0; j < filelist.length; j++) { - println("imgPool[" + i + "][" + j + "]: " + fulldir + filelist[j]); + println(" imgPool[" + i + "][" + j + "]: " + dirlist[i] + " " + filelist[j]); imgPool[i][j] = loadImage(fulldir + filelist[j]); } @@ -38,6 +44,8 @@ PImage[][] getImages(String folder) { } } + println("\n~~~ Done loading images.\n"); + return imgPool; } diff --git a/pde/IF3Si/osc.pde b/pde/IF3Si/osc.pde index 50e4da1..78ba4f2 100644 --- a/pde/IF3Si/osc.pde +++ b/pde/IF3Si/osc.pde @@ -16,12 +16,46 @@ void ctlin(int cc, int val) { // midi control values, from Renoise (via SC) // println("### OSC: /ctlin cc:" + cc + " value:" + val); // patchbay - if (cc == 2) { tilesOverlap = val; } + + if (cc == 3) { screenCleanHue = val; } + if (cc == 4) { screenCleanSaturation = val; } + if (cc == 5) { screenCleanBrightness = val; } + if (cc == 6) { screenCleanAlpha = val; } + if (cc == 7) { screenCleanFlickrAmount = val; } + if (cc == 8) { screenCleanFlickrSpeed = val; } + + if (cc == 9) { + if (val == 0) { drawSpectrumToggle = true; } + if (val == 1) { drawSpectrumToggle = false; } + if (val == 2) { drawTilesToggle = true; } + if (val == 3) { drawTilesToggle = false; } + } + + if (cc == 10) { drawSpectrumAFactor = val; } if (cc == 11) { drawSpectrumThreshold = val; } if (cc == 12) { drawSpectrumHeight = val; } if (cc == 13) { drawSpectrumWidth = val; } if (cc == 14) { drawSpectrumAwidth = val; } + if (cc == 15) { drawSpectrumSaturation = val; } + + if (cc == 16) { tilesBgHue = val; } + if (cc == 17) { tilesBgSat = val; } + if (cc == 18) { tilesBgBri = val; } + if (cc == 19) { tilesHue = val; } + if (cc == 20) { tilesSat = val; } + if (cc == 21) { tilesBri = val; } + if (cc == 22) { tilesNumX = val; } + if (cc == 23) { tilesNumY = val; } + if (cc == 24) { tilesTexBank = val; } + if (cc == 25) { tilesTexId = val; } + if (cc == 26) { tilesTexSpeedX = val; } + if (cc == 27) { tilesTexSpeedY = val; } + if (cc == 28) { tilesOverlap = val; } + + //if (cc == 30) {} + + } @@ -33,8 +67,10 @@ void scosc(String mount, int val) { // stuff coming directly from SuperCollider // println("### OSC: /sc mount:" + mount + " value:" + val); // patchbay - if (mount.equals("testPatternToggle")) { testPatternToggle = boolean(val); } - if (mount.equals("testPictureToggle")) { testPictureToggle = boolean(val); } + if (mount.equals("testPatternToggle")) { testPatternToggle = boolean(val); println("~~~ testPatternToggle: " + val);} + if (mount.equals("testPictureToggle")) { testPictureToggle = boolean(val); println("~~~ testPictureToggle: " + val);} + if (mount.equals("drawSpectrumToggle")) { drawSpectrumToggle = boolean(val); println("~~~ drawSpectrumToggle: " + val);} + if (mount.equals("drawTilesToggle")) { drawTilesToggle = boolean(val); println("~~~ drawTilesToggle: " + val);} } // - - - - - - - - - - - - - - - - - - - - diff --git a/pde/IF3Si/testPicture.pde b/pde/IF3Si/testPicture.pde index 043bfd5..06920ce 100644 --- a/pde/IF3Si/testPicture.pde +++ b/pde/IF3Si/testPicture.pde @@ -12,11 +12,13 @@ void testPicture(boolean render) { if (render) { - + + blendMode(BLEND); fill(127); stroke(255); - strokeWeight(1); + strokeWeight(4); + rectMode(CORNER); rect(1, 1, width-2, height-2); ellipse(width/2, height/2, height-4, height-4); diff --git a/pde/IF3Si/tiles.pde b/pde/IF3Si/tiles.pde index ab9a641..58cb87b 100644 --- a/pde/IF3Si/tiles.pde +++ b/pde/IF3Si/tiles.pde @@ -12,6 +12,7 @@ + // TILES - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - /* TODO: - different zooms (random?) @@ -24,8 +25,10 @@ */ void tiles( boolean render, // should we render or not? - color bgfill, // backgorund color - color tilecolor, // tile color + int tilesBgHue, int tilesBgSat, int tilesBgBri, + int tilesHue, int tilesSat, int tilesBri, + //color bgfill, // backgorund color + //!!color tilecolor, // tile color int huedist, // tile color distance for interpolation int blendMode, // blending mode of tiles int numx, // number of tiles on X @@ -38,18 +41,34 @@ void tiles( boolean render, // should we render or not? { if (render) { - colorMode(HSB, 360, 100, 100, 100); + colorMode(HSB, 127, 127, 127, 127); blendMode(BLEND); + color bgfill = color(tilesBgHue, tilesBgSat, tilesBgBri); + color tilecolor = color(tilesHue, tilesSat, tilesBri); + fill(bgfill); noStroke(); rect(0, 0, width, height); switchBlendMode(blendMode); // blendMode function using integers + + texBank = min(texBank, imgPool.length - 1); + texNum = min(texNum, imgPool[texBank].length - 1); + + // for (int i = 0; i < imgPool.length; i++) { + // if (texBank == i) { + + // } + // } + + texSpeedX *= 0.01; texSpeedY *= 0.01; texX += sq(texSpeedX); texY += sq(texSpeedY); - + + numx = max(1, numx); + numy = max(1, numy); float numxfact = 1 / float(numx); float numyfact = 1 / float(numy); float aspectRatio = (height / float(numy)) / (width / float(numx)); diff --git a/scd/gui_core.scd b/scd/gui_core.scd index 08d80c6..ef0e9c8 100644 --- a/scd/gui_core.scd +++ b/scd/gui_core.scd @@ -31,11 +31,11 @@ w = Window.new( name: "Interface Fractures III", bounds: Rect(0, 2, ~screenWidth, ~screenHeight), //bounds: w.availableBounds, resizable: true, - border: false, + border: true, server: s, scroll: true ).front; -w.fullScreen; +//w.fullScreen; postln("~~~ Created window ..." + w.bounds); w.background_(Color.gray(0.2)); diff --git a/scd/gui_main.scd b/scd/gui_main.scd index 1519df0..b12383a 100644 --- a/scd/gui_main.scd +++ b/scd/gui_main.scd @@ -39,6 +39,18 @@ ); }) .minHeight_(70).minWidth_(70), + nil, + + Button().minHeight_(70).minWidth_(70) + .states_([ ["draw Spectrum"], ["draw Spectrum", Color.gray(0.2), Color.grey(0.8)] ]) + .mouseDownAction_({ | state | + switch(state.value, + 0, { postln("~~~ draw Spectrum on!"); + ~zarquOsc.sendMsg("/sc", "drawSpectrumToggle", 1); }, + 1, { postln("~~~ draw Spectrum off!"); + ~zarquOsc.sendMsg("/sc", "drawSpectrumToggle", 0); } + ); + }), Button().minHeight_(70).minWidth_(70) .states_([ ["Test pattern"], ["Test pattern", Color.gray(0.2), Color.grey(0.8)] ]) diff --git a/scd/snd_lines.scd b/scd/snd_lines.scd index 4b785a4..6037ae6 100644 --- a/scd/snd_lines.scd +++ b/scd/snd_lines.scd @@ -115,7 +115,7 @@ postln("~~~ function ~procLinesFunc ..."); }; -// process lines, store to a List +// evaluate: process lines, store to a List postln("~~~ process lines, store to a list: ~siLinesData, sort ..."); ~siLinesData = ~procLinesFunc.value; @@ -179,14 +179,18 @@ postln("~~~ function ~viewLinesFunc ..."); swin.refresh; swin.front; }; // end of viewLines function +// this could be bound to a button, +// or ideally expanded to an animated timeline +// and included in main window...: + +// evaluate: show a window/view with lines - score +// ~viewLinesFunc.value; - - -( + ~postLines = { // print data in post window, NICELY! @@ -195,49 +199,61 @@ postln("~~~ function ~viewLinesFunc ..."); var minutes = (item[0]/60).asInt; var seconds = (item[0]%60).asInt; - if (item[3].asInt > 99, { + if (item[3].asInt > 199, { // post("["); // post(i.asString.padLeft(3)); // post("] "); - post(item[1]); - post(" "); - - post(item[3].asString.padLeft(4)); - post(" "); - + // time if (minutes < 10, { minutes = "0" ++ minutes.asString;}); post(minutes); post(":"); if (seconds < 10, { seconds = "0" ++ seconds.asString; }); post(seconds); - //post(i); + post(" "); + + // wavelength + post(item[2]); + post("Å "); + + + // layer + post(item[1]); + post(" "); + + // intensity + post(item[3].asString.padLeft(4)); post(" "); + // frequency post(item[4].asString.padLeft(5)); post("Hz "); post(item[5].asString.padLeft(5)); post("Hz "); + // midi/tone post(item[6].asString.padLeft(5)); // midi1 post(" "); post(item[7].asString.padLeft(5)); // midi2 post(" | "); + // RGB post(item[8].asString.padLeft(3)); post(" "); post(item[9].asString.padLeft(3)); post(" "); post(item[10].asString.padLeft(3)); - post(" | "); - post(item[11].asString.padLeft(3)); - post(" "); - post(item[12].asString.padLeft(3)); - post(" "); - post(item[13].asString.padLeft(3)); + + // HSV/B + // 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) ); @@ -257,20 +273,12 @@ postln("~~~ function ~viewLinesFunc ..."); }; - -~postLines.value; - -) +// evaluate function +//~postLines.value; -// this could be bound to a button, -// or ideally expanded to an animated timeline -// and included in main window...: -// show a window/view with lines - score -// ~viewLinesFunc.value; - @@ -309,7 +317,7 @@ SynthDef(\siliconSynth, { |freq = 440, amp = 0.2, attack = 1, release = 1| ; // ------------------------------------------------------------------------------------------- sig = sig * env; // envlope the final sound - Out.ar(0, sig); // output + Out.ar(2, sig); // output postln("\n~~~ adding SynthDef: siliconSynth ..."); }).add; // ----------------------------------------------------------------------------- @@ -320,7 +328,7 @@ post(" "); ~mainTimeline = Routine({ - arg layer = 0; + //arg layer = 0; var delta, playhead, frequency, amp, step=0, nextdelta, nextplayhead, nextfrequency, nextamp, @@ -333,7 +341,7 @@ post(" "); while { step < siLines.size; - layer == siLines[step] + //layer == siLines[step] } { // exposition