Fade in and fade out text, on change, within Array

I’m doing something wrong here - it almost does what I want - but how can I make this fade in / fade out only when I change the Bank array index? - right now my text fades in and out without being aware of the conditional change. The BankTxt array shows the correct Bank on the change (A, B, C) but I am looking to fade between these, rather than a cut…

Many thanks for any advice, jNt

// Define a variable to store a transparency value
float transparency = 0;

// Define a variable to store fade direction (1 for fade in, -1 for fade out)
int fadeDirection = 1;

// Use a loop to handle the different elements in a "Bank" array
for (int i = 0; i <= 16; i++) {
  if (Bank == i) {
    // Increment or decrement the transparency value depending on the fade direction
    transparency += fadeDirection;
    
    // Check if the transparency value has reached the minimum or maximum limit, and change the fade direction if necessary
    if (transparency <= 0) {
      transparency = 0;
      fadeDirection = 1;
    }
    else if (transparency >= 255) {
      transparency = 255;
      fadeDirection = -1;
    }
    
    // Use the transparency value to set the fill color for the text
    fill(0, transparency);
    text(BankTxt[i], width/2, height/3);  
  }
}

Does this mean, Bank is the number of the current bank? Maybe choose a better name in terms of readability.

you can see such a change only when it’s called from draw (throughout). When you call it from a code section that’s called ONLY when you change the Bank array index it won’t work.

(we can’t tell because maybe you don’t provide enough context)

In this case, you need to move the line transparency += fadeDirection; to draw() and change the transparency here.

Add something like

if (transparency >= 255) {
      transparency = 255;
      fadeDirection = 0;
    }

Hello @JonnieNightTime,

My exploration of this:

int Bank;
String [] BankTxt = { "Element 1","Element 2", "Element 3", "Element 4", "Element 5"};

void setup()
  {
  size(600, 200);
  textAlign(CENTER, CENTER);
  textSize(96);
  }

  // Initial values:
  // Define a variable to store a transparency value
  float transparency = 0;

  // Define a variable to store fade direction (1 for fade in, -1 for fade out)
  int fadeDirection = 1;

  int i;

void draw()
  {
  background(255);  
  // int i = (frameCount/512)%5;  //Just for testing!
 // Your code WITHOUT the for loop goes here...
  }
  
  void keyPressed()
    {
    i = int(random(0, 5)); // generates random integer 0 to 4
    // reset everything to initial values!
    // Add code here!
    }

The above worked and may give you some insight.

:)

Dear Chrisir. I appreciate that a little more context might have been useful. Here’s a fuller part of my sketch. My purpose is to receive OSC from an ipad to control an AV performance - (ipad also sending MIDI to an Octratrack for audio). The OSC is working great - I’m now trying to fade between different Banks (Octratack language) and, nested within 16 of these, 16 different Patterns.

import oscP5.*;
import netP5.*;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES

// Define a variable to store the transparency value
float transparency = 0;

// Define a variable to store the fade direction (1 for fade in, -1 for fade out)
int fadeDirection = 1;

OscP5 oscP5; 

int Bank = 0; 
int Pattern = 0; 
String[] BankTxt;
String[] PatternTxt;

/////////////////////////////////////////////////////////////////////////// TEXT VARIABLES

PFont FontBigCaslon48;

void setup() { ///////////////// SET-UP STARTS
  
  size(300,300);
  
  BankTxt = new String[16]; 
    
    BankTxt[0]="A"; /// mapped to Octatrack Banks 
    BankTxt[1]="B"; 
    BankTxt[2]="C"; 
    BankTxt[3]="D"; 
    BankTxt[4]="E"; 
    BankTxt[5]="F"; 
    BankTxt[6]="G"; 
    BankTxt[7]="H"; 
    BankTxt[8]="I"; BankTxt[9]="J"; BankTxt[10]="K"; BankTxt[11]="L"; BankTxt[12]="M"; BankTxt[13]="N"; BankTxt[14]="O"; BankTxt[15]="P";

oscP5 = new OscP5(this,10000);
    
  PatternTxt = new String[16]; /// 16 for now = all of Bank A
    
    PatternTxt[0]="1"; ///  Octatrack Patterns - A1-A16  for now
    PatternTxt[1]="2"; 
    PatternTxt[2]="3"; 
    PatternTxt[3]="4"; 
    PatternTxt[4]="5"; 
    PatternTxt[5]="6"; 
    PatternTxt[6]="7"; 
    PatternTxt[7]="8"; 
    PatternTxt[8]="9"; PatternTxt[9]="10"; PatternTxt[10]="11"; PatternTxt[11]="12"; PatternTxt[12]="13"; PatternTxt[13]="14"; PatternTxt[14]="15"; PatternTxt[15]="16";
      
} ///// SET-UP CLOSE

void draw() { ////// DRAW LOOP START
 
  background (255);
  textFont(FontBigCaslon48);
  
  transparency += fadeDirection;
  
  if (transparency >= 255) {
      transparency = 255;
      fadeDirection = 0;
    }
 
for (int i = 0; i <= 16; i++) {   /// Bank Conditional Start
  if (Bank == i) {
    fill(0, transparency);
    text(BankTxt[i], width/2, height/3);  
  }
  
  for (int j = 0; j <= 16; j++) { /// Nested Pattern Conditional Start
  if (Pattern == j) {
    fill(0);
    text(PatternTxt[j], width/1.6, height/3);  
  }
 }    /// Nested Pattern Conditional Close
 
} ////////////// Bank Conditional Close

} /////// DRAW LOOP CLOSE

void oscEvent(OscMessage theOscMessage) { ////// OSC FROM IPAD INTERFACE

if(theOscMessage.checkTypetag("i")) { 
  
  if (theOscMessage.checkAddrPattern("/program/bank")==true){
    Bank = theOscMessage.get(0).intValue(); 
    println("Bank: ", Bank+1);

  } else if (theOscMessage.checkAddrPattern("/program/pattern")==true){ 
  Pattern = theOscMessage.get(0).intValue(); 
    println("Pattern: ", Pattern+1); }
    }  
 
if(theOscMessage.checkTypetag("f")) { float val = theOscMessage.get(0).floatValue();  println(""+theOscMessage.addrPattern(), ""+val+ ""); }
      
} //////////// OSC CLOSE

Hi glv,

Thanks for your response - I’m not quite grasping what you’re pointing me towards - that I should reset a transparency within, in my case, an OSC function, like in your example keypressed? I’m not looking for a random value, just one bank to fade out, as another fades in…

I still didn’t get it

here is a version where the old number fades out and the new one fades in…

you have to hit a key 3 times to really see it

  • Example is without OSC, just a key press changes the bank

// 

final int maxFade=255; 

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES

// Define 2 variables to store the transparency values
float transparencyOut = 0; 
float transparencyIn = 0;

// Define a variable to store the fade direction (1 for fade in, -1 for fade out)
int fadeDirectionIn = 1;
int fadeDirectionOut = 1;

int currentBankNumber = -1; // -1 means NONE  
int prevNumber=-1; 
int newNumber=-1; 

int Pattern = 0; 
String[] BankTxt;
String[] PatternTxt;

/////////////////////////////////////////////////////////////////////////// TEXT VARIABLES

PFont FontBigCaslon48;

void setup() { ///////////////// SET-UP STARTS

  size(300, 300);

  BankTxt = new String[16]; 

  BankTxt[0]="A"; /// mapped to Octatrack Banks 
  BankTxt[1]="B"; 
  BankTxt[2]="C"; 
  BankTxt[3]="D"; 
  BankTxt[4]="E"; 
  BankTxt[5]="F"; 
  BankTxt[6]="G"; 
  BankTxt[7]="H"; 
  BankTxt[8]="I"; 
  BankTxt[9]="J"; 
  BankTxt[10]="K"; 
  BankTxt[11]="L"; 
  BankTxt[12]="M"; 
  BankTxt[13]="N"; 
  BankTxt[14]="O"; 
  BankTxt[15]="P";


  PatternTxt = new String[16]; /// 16 for now = all of Bank A

  PatternTxt[0]="1"; ///  Octatrack Patterns - A1-A16  for now
  PatternTxt[1]="2"; 
  PatternTxt[2]="3"; 
  PatternTxt[3]="4"; 
  PatternTxt[4]="5"; 
  PatternTxt[5]="6"; 
  PatternTxt[6]="7"; 
  PatternTxt[7]="8"; 
  PatternTxt[8]="9"; 
  PatternTxt[9]="10"; 
  PatternTxt[10]="11"; 
  PatternTxt[11]="12"; 
  PatternTxt[12]="13"; 
  PatternTxt[13]="14"; 
  PatternTxt[14]="15"; 
  PatternTxt[15]="16";
} ///// SET-UP CLOSE

void draw() { ////// DRAW LOOP START

  background (255);

  transparencyIn += fadeDirectionIn;
  transparencyOut += fadeDirectionOut;

  if (transparencyIn > maxFade) {
    transparencyIn = maxFade;
    fadeDirectionIn = 0; // stop
    println("Stop");
  }

  if (transparencyOut < 0) {
    transparencyOut = 0;
    fadeDirectionOut = 0; // stop
  }

  for (int i = 0; i < 16; i++) {   /// Bank Conditional Start
    //default 
    fill(0);
    // show >
    if (currentBankNumber == i) {
      text(">", width/2-10, (height/3-55)+i*12);
    }

    // make transparency
    if (newNumber == i) {
      fill(0, transparencyIn);
    }
    if (prevNumber == i) {
      fill(0, transparencyOut);
    }
    text(BankTxt[i], width/2, (height/3-55)+i*12);


    for (int j = 0; j <= 16; j++) { /// Nested Pattern Conditional Start
      if (Pattern == j) {
        fill(0);
        text(PatternTxt[j], width/1.6, height/3);
      }
    }    /// Nested Pattern Conditional Close
  } ////////////// Bank Conditional Close

  fill(0); 
  text("Press a key *****************************************************", 8, height-22);
} /////// DRAW LOOP CLOSE

void keyPressed() {
  //  store old number
  if (currentBankNumber!=-1) {
    prevNumber = currentBankNumber;
  }
  // set new number 
  int test1=int(random(16));
  if (test1!=currentBankNumber) { 
    currentBankNumber=test1; // OK
  } else {
    // try again 
    test1=int(random(16));
    currentBankNumber=test1;
  }

  newNumber=currentBankNumber;

  // manage transparencies !!!!!!!!!! 
  transparencyIn = 0; // fade in
  transparencyOut = maxFade; // fade out

  fadeDirectionIn = 1; // fade in
  fadeDirectionOut = -1;  // fade out
}//func 
//

1 Like

This is so cool - though I don’t quite understand the test1=int(random(16) part to set the new number. Rather than this being a random number, how can I specify it?

Using keypressed e.g. how can key 1 = Bank1, 2 = Bank2, 3 = Bank3 etc. I’ve been trying to work it out for a couple of hours, but I’m just not getting it…

Hey @JonnieNightTime!

random (n) generates a random number between 0 and n | including 0 but not ‘n’.

The int (...) part is casting. In this case, it is converting the returned value of random () which is float to an int. It essentially removes any number to the right of the decimal point leaving you with an integer number. For instance, str ('8') would convert character ‘8’ to String.

As for your keyPressed request to map keys to Bank#s, I ask whether you’d be satisfied with a total of 10 entries (0 - 9) – as it seems like you are looking to use number keys.

If so, you could use this snippet in your keyPressed ():

  // set new number
  if (key >= '0' && key <= '9')
    currentBankNumber = int (str (key));

  newNumber = currentBankNumber;

What it does: is check whether the current pressed key is between '0' and '9'. Note that these are characters (what key’s type is) and not the same as the numbers 0 and 9. the str (key) is casting char to String and itself being in int (...)) is converted to a number.

Basically saying, if the key pressed is a number between 0 and 9, assign this number (as an integer) to currentBankNumber.

If NOT, you could add elements of the keys you want to serve as a trigger into an array, and iterate to see whether that key has been pressed and assign it to currentBankNumber.

1 Like

Hi Abel, Thanks for your clear explanation. Here’s the full context of what I’m trying to do - I’m actually wanting to receive OSC from an iPad, rather than keypressed… Any suggestions would be hugely appreciated…

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT LIBRARIES
final int maxFade=255; 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT OSC

import oscP5.*;
import netP5.*;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES
 
/////////////////////////////////////////////////////////////////////////// OSC VARIABLES

OscP5 oscP5; 

// Define 2 variables to store the bank transparency values
float BankTransparencyOut = 0; 
float BankTransparencyIn = 0;

// Define a variable to store the bank fade direction (1 for fade in, -1 for fade out)
int BankfadeDirectionIn = 1;
int BankfadeDirectionOut = 1;

int Bank = -1; // -1 means NONE  nb/ currentBankNumber
int prevNumber=-1; 
int newNumber=-1; 

int Pattern = 0; 
String[] BankTxt;
String[] PatternTxt;

/////////////////////////////////////////////////////////////////////////// TEXT VARIABLES

PFont FontBigCaslon48;

void setup() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP STARTS
  
  size(300,300);
  println(totalMem()); //////////// Memory Management
  
  BankTxt = new String[16]; 
    BankTxt[0]="A"; /// mapped to Octatrack Banks - can be renamed to track titles e.g "A" -> "disoedd"
    BankTxt[1]="B"; 
    BankTxt[2]="C"; 
    BankTxt[3]="D"; 
    BankTxt[4]="E"; 
    BankTxt[5]="F"; 
    BankTxt[6]="G"; 
    BankTxt[7]="H"; 
    BankTxt[8]="I"; BankTxt[9]="J"; BankTxt[10]="K"; BankTxt[11]="L"; BankTxt[12]="M"; BankTxt[13]="N"; BankTxt[14]="O"; BankTxt[15]="P";
    
  PatternTxt = new String[16]; /// 6 for now = all of Bank A
    PatternTxt[0]="1"; ///  Octatrack Patterns - A1-P16 = 16 x 16 = 256 (0-255) for text to appear subsequently? array really necessary?
    PatternTxt[1]="2"; 
    PatternTxt[2]="3"; 
    PatternTxt[3]="4"; 
    PatternTxt[4]="5"; 
    PatternTxt[5]="6"; 
    PatternTxt[6]="7"; 
    PatternTxt[7]="8"; 
    PatternTxt[8]="9"; PatternTxt[9]="10"; PatternTxt[10]="11"; PatternTxt[11]="12"; PatternTxt[12]="13"; PatternTxt[13]="14"; PatternTxt[14]="15"; PatternTxt[15]="16";
  
FontBigCaslon48 = loadFont("BigCaslon-Medium-48.vlw");
oscP5 = new OscP5(this,10000);
        
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP CLOSE

void draw() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP START
  background (255);
  //textFont(FontBigCaslon48);
  
  if(frameCount % 10 == 0){ ////////////////////////////////////// Memory Management STARTS
  
    int percent = (int)(100*(double)usedMem()/totalMem());
    //println("Visual Processing Memory Usage:", percent + "%");
  
  } ///////////////////////////////////////////////////////////// Memory Management CLOSES
  
  BankTransparencyIn += BankfadeDirectionIn;
  BankTransparencyOut += BankfadeDirectionOut;

  if (BankTransparencyIn > maxFade) {
    BankTransparencyIn = maxFade;
    BankfadeDirectionIn = 0; // stop
    println("Stop");
  }

  if (BankTransparencyOut < 0) {
    BankTransparencyOut = 0;
    BankfadeDirectionOut = 0; // stop
  }
  
    for (int i = 0; i < 16; i++) {   ///////////////////////////////////// Bank Conditional Start
    fill(0);
    // show >
    if (Bank == i) {
      text(">", width/2-10, (height/3-55)+i*12);
    }

    // make transparency
    if (newNumber == i) {
      fill(0, BankTransparencyIn);
    }
    if (prevNumber == i) {
      fill(0, BankTransparencyOut);
    }
    text(BankTxt[i], width/2, (height/3-55)+i*12);

    for (int j = 0; j <= 16; j++) { ///////// Nested Pattern Conditional Start
      if (Pattern == j) {
        fill(0);
        text(PatternTxt[j], width/1.6, height/3);
      }
    }    //////////////////////////////////// Nested Pattern Conditional Close
    
  } /////////////////////////////////////////////////////////////////// Bank Conditional Close
  
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP CLOSE

void oscEvent(OscMessage theOscMessage) { //////////////////////////////////////////////////////////////////////// OSC MESSAGES FROM IPAD LEMUR INTERFACE

if(theOscMessage.checkTypetag("i")) { 
  
  if (theOscMessage.checkAddrPattern("/program/bank")==true){
   
    Bank = theOscMessage.get(0).intValue(); 
    println("Bank: ", Bank+1);
    
    if (Bank!=-1) {
    prevNumber = Bank;
  }
  // set new number /// but not to be a random int, but rather intValue of the OscMessage - I'm so stuck
  int test1=int(random(16));
  if (test1!=Bank) { 
    Bank=test1; // OK
  } else {
    // try again 
    test1=int(random(16));
    Bank=test1;
  }

  newNumber=Bank;

  // manage transparencies !!!!!!!!!! 
  BankTransparencyIn = 0; // fade in
  BankTransparencyOut = maxFade; // fade out

  BankfadeDirectionIn = 1; // fade in
  BankfadeDirectionOut = -1;  // fade out

  } else if (theOscMessage.checkAddrPattern("/program/pattern")==true){ 

  Pattern = theOscMessage.get(0).intValue();
  println("Pattern: ", Pattern+1); }

    }  
 
if(theOscMessage.checkTypetag("f")) { float val = theOscMessage.get(0).floatValue();  println(""+theOscMessage.addrPattern(), ""+val+ ""); }
      
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OSC MESSAGES SECTION CLOSE

public long totalMem() { /////////////////////////////////////////////////////////////////////////////////////////////// MEMORY MANAGEMENT FUNCTIONS START

  return Runtime.getRuntime().totalMemory();
}
 
public long usedMem() {
  return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
} 

Could you implement my findings into your sketch?

It doesn’t matter if the chance occurs via key press or via osc…

Does it work now…?

Hi Chrisir,
Good to hear from you. Yes - I could implement your findings. It’s working great, other than I’m failing at to // set new number so not to be a random int, but rather intValue of the OscMessage - I’m so stuck.

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT LIBRARIES
final int maxFade=255; 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT OSC

import oscP5.*;
import netP5.*;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES
 
/////////////////////////////////////////////////////////////////////////// OSC VARIABLES

OscP5 oscP5; 

// Define 2 variables to store the bank transparency values
float BankTransparencyOut = 0; 
float BankTransparencyIn = 0;

// Define a variable to store the bank fade direction (1 for fade in, -1 for fade out)
int BankfadeDirectionIn = 1;
int BankfadeDirectionOut = 1;

int Bank = -1; // -1 means NONE  nb/ currentBankNumber
int prevNumber=-1; 
int newNumber=-1; 

int Pattern = 0; 
String[] BankTxt;
String[] PatternTxt;

/////////////////////////////////////////////////////////////////////////// TEXT VARIABLES

PFont FontBigCaslon48;

void setup() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP STARTS
  
  size(300,300);
  println(totalMem()); //////////// Memory Management
  
  BankTxt = new String[16]; 
    BankTxt[0]="A"; /// mapped to Octatrack Banks - can be renamed to track titles e.g "A" -> "disoedd"
    BankTxt[1]="B"; 
    BankTxt[2]="C"; 
    BankTxt[3]="D"; 
    BankTxt[4]="E"; 
    BankTxt[5]="F"; 
    BankTxt[6]="G"; 
    BankTxt[7]="H"; 
    BankTxt[8]="I"; BankTxt[9]="J"; BankTxt[10]="K"; BankTxt[11]="L"; BankTxt[12]="M"; BankTxt[13]="N"; BankTxt[14]="O"; BankTxt[15]="P";
    
  PatternTxt = new String[16]; /// 6 for now = all of Bank A
    PatternTxt[0]="1"; ///  Octatrack Patterns - A1-P16 = 16 x 16 = 256 (0-255) for text to appear subsequently? array really necessary?
    PatternTxt[1]="2"; 
    PatternTxt[2]="3"; 
    PatternTxt[3]="4"; 
    PatternTxt[4]="5"; 
    PatternTxt[5]="6"; 
    PatternTxt[6]="7"; 
    PatternTxt[7]="8"; 
    PatternTxt[8]="9"; PatternTxt[9]="10"; PatternTxt[10]="11"; PatternTxt[11]="12"; PatternTxt[12]="13"; PatternTxt[13]="14"; PatternTxt[14]="15"; PatternTxt[15]="16";
  
FontBigCaslon48 = loadFont("BigCaslon-Medium-48.vlw");
oscP5 = new OscP5(this,10000);
        
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP CLOSE

void draw() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP START
  background (255);
  //textFont(FontBigCaslon48);
  
  if(frameCount % 10 == 0){ ////////////////////////////////////// Memory Management STARTS
  
    int percent = (int)(100*(double)usedMem()/totalMem());
    //println("Visual Processing Memory Usage:", percent + "%");
  
  } ///////////////////////////////////////////////////////////// Memory Management CLOSES
  
  BankTransparencyIn += BankfadeDirectionIn;
  BankTransparencyOut += BankfadeDirectionOut;

  if (BankTransparencyIn > maxFade) {
    BankTransparencyIn = maxFade;
    BankfadeDirectionIn = 0; // stop
    println("Stop");
  }

  if (BankTransparencyOut < 0) {
    BankTransparencyOut = 0;
    BankfadeDirectionOut = 0; // stop
  }
  
    for (int i = 0; i < 16; i++) {   ///////////////////////////////////// Bank Conditional Start
    fill(0);
    // show >
    if (Bank == i) {
      text(">", width/2-10, (height/3-55)+i*12);
    }

    // make transparency
    if (newNumber == i) {
      fill(0, BankTransparencyIn);
    }
    if (prevNumber == i) {
      fill(0, BankTransparencyOut);
    }
    text(BankTxt[i], width/2, (height/3-55)+i*12);

    for (int j = 0; j <= 16; j++) { ///////// Nested Pattern Conditional Start
      if (Pattern == j) {
        fill(0);
        text(PatternTxt[j], width/1.6, height/3);
      }
    }    //////////////////////////////////// Nested Pattern Conditional Close
    
  } /////////////////////////////////////////////////////////////////// Bank Conditional Close
  
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP CLOSE

void oscEvent(OscMessage theOscMessage) { //////////////////////////////////////////////////////////////////////// OSC MESSAGES FROM IPAD LEMUR INTERFACE

if(theOscMessage.checkTypetag("i")) { 
  
  if (theOscMessage.checkAddrPattern("/program/bank")==true){
   
    Bank = theOscMessage.get(0).intValue(); 
    println("Bank: ", Bank+1);
    
    if (Bank!=-1) {
    prevNumber = Bank;
  }
  // set new number /// but not to be a random int, but rather intValue of the OscMessage - I'm so stuck
  int test1=int(random(16));
  if (test1!=Bank) { 
    Bank=test1; // OK
  } else {
    // try again 
    test1=int(random(16));
    Bank=test1;
  }

  newNumber=Bank;

  // manage transparencies !!!!!!!!!! 
  BankTransparencyIn = 0; // fade in
  BankTransparencyOut = maxFade; // fade out

  BankfadeDirectionIn = 1; // fade in
  BankfadeDirectionOut = -1;  // fade out

  } else if (theOscMessage.checkAddrPattern("/program/pattern")==true){ 

  Pattern = theOscMessage.get(0).intValue();
  println("Pattern: ", Pattern+1); }

    }  
 
if(theOscMessage.checkTypetag("f")) { float val = theOscMessage.get(0).floatValue();  println(""+theOscMessage.addrPattern(), ""+val+ ""); }
      
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OSC MESSAGES SECTION CLOSE

public long totalMem() { /////////////////////////////////////////////////////////////////////////////////////////////// MEMORY MANAGEMENT FUNCTIONS START

  return Runtime.getRuntime().totalMemory();
}
 
public long usedMem() {
  return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}

ok, here is your Sketch with working 0...9 numbers

I don’t know what osc is, so I couldn’t test it.
But it could work.

Same principle in oscEvent as in keyPressed() function.

Chrisir



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT LIBRARIES
final int maxFade=255; 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT OSC

import oscP5.*;
import netP5.*;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES

/////////////////////////////////////////////////////////////////////////// OSC VARIABLES

OscP5 oscP5; 

/////////////////////////////////////////////////////////////////////////// transparency values

// Define 2 variables to store the bank transparency values
float BankTransparencyOut = 255; 
float BankTransparencyIn = 0;

// Define a variable to store the bank fade direction (1 for fade in, -1 for fade out)
int BankfadeDirectionIn = 1;
int BankfadeDirectionOut = -1;

int Bank = -1; // -1 means NONE  nb/ currentBankNumber
int prevNumber=-1; 
int newNumber=-1; 

int Pattern = 0; 
String[] BankTxt;
String[] PatternTxt;

/////////////////////////////////////////////////////////////////////////// TEXT VARIABLES

PFont FontBigCaslon48;

void setup() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP STARTS

  size(900, 300);
  println(totalMem()); //////////// Memory Management

  BankTxt = new String[16]; 
  BankTxt[0]="A"; /// mapped to Octatrack Banks - can be renamed to track titles e.g "A" -> "disoedd"
  BankTxt[1]="B"; 
  BankTxt[2]="C"; 
  BankTxt[3]="D"; 
  BankTxt[4]="E"; 
  BankTxt[5]="F"; 
  BankTxt[6]="G"; 
  BankTxt[7]="H"; 
  BankTxt[8]="I"; 
  BankTxt[9]="J"; 
  BankTxt[10]="K"; 
  BankTxt[11]="L"; 
  BankTxt[12]="M"; 
  BankTxt[13]="N"; 
  BankTxt[14]="O"; 
  BankTxt[15]="P";

  PatternTxt = new String[16]; /// 6 for now = all of Bank A
  PatternTxt[0]="1"; ///  Octatrack Patterns - A1-P16 = 16 x 16 = 256 (0-255) for text to appear subsequently? array really necessary?
  PatternTxt[1]="2"; 
  PatternTxt[2]="3"; 
  PatternTxt[3]="4"; 
  PatternTxt[4]="5"; 
  PatternTxt[5]="6"; 
  PatternTxt[6]="7"; 
  PatternTxt[7]="8"; 
  PatternTxt[8]="9"; 
  PatternTxt[9]="10"; 
  PatternTxt[10]="11"; 
  PatternTxt[11]="12"; 
  PatternTxt[12]="13"; 
  PatternTxt[13]="14"; 
  PatternTxt[14]="15"; 
  PatternTxt[15]="16";

  FontBigCaslon48 = createFont("BigCaslon-Medium-48.vlw", 14);

  oscP5 = new OscP5(this, 10000);
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP CLOSE

void draw() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP START
  background (255);
  //textFont(FontBigCaslon48);

  if (frameCount % 10 == 0) { ////////////////////////////////////// Memory Management STARTS
    int percent = (int)(100*(double)usedMem()/totalMem());
    // println("Visual Processing Memory Usage:" + percent ) ; 
  } // Memory Management CLOSES

  BankTransparencyIn += BankfadeDirectionIn;
  BankTransparencyOut += BankfadeDirectionOut;

  if (BankTransparencyIn > maxFade) {
    BankTransparencyIn = maxFade;
    BankfadeDirectionIn = 0; // stop
  }

  if (BankTransparencyOut < 0) {
    BankTransparencyOut = 0;
    BankfadeDirectionOut = 0; // stop
  }

  for (int i = 0; i < 16; i++) {   ///////////////////////////////////// Bank Conditional Start
    fill(0);
    // show >
    if (Bank == i) {
      text(">", width/2-10, (height/3-55)+i*12);
    }

    // make transparency
    if (newNumber == i) {
      fill(0, BankTransparencyIn);
    }
    if (prevNumber == i) {
      fill(0, BankTransparencyOut);
    }
    text(BankTxt[i], width/2, (height/3-55)+i*12);

    for (int j = 0; j <= 16; j++) { ///////// Nested Pattern Conditional Start
      if (Pattern == j) {
        fill(0);
        text(PatternTxt[j], width/1.6, height/3);
      }
    }    //////////////////////////////////// Nested Pattern Conditional Close
  } /////////////////////////////////////////////////////////////////// Bank Conditional Close
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP CLOSE

void oscEvent(OscMessage theOscMessage) { //////////////////////////////////////////////////////////////////////// OSC MESSAGES FROM IPAD LEMUR INTERFACE

  if (theOscMessage.checkTypetag("i")) { 

    if (theOscMessage.checkAddrPattern("/program/bank")==true) {

      if (Bank!=-1) {
        prevNumber = Bank;
      }

      // set new number /// but not to be a random int, but rather intValue of the OscMessage - I'm so stuck
      Bank = theOscMessage.get(0).intValue(); 

      println("Bank: ", Bank+1);

      newNumber=Bank;

      // manage transparencies !!!!!!!!!! 
      BankTransparencyIn = 0; // fade in
      BankTransparencyOut = maxFade; // fade out

      BankfadeDirectionIn = 1; // fade in
      BankfadeDirectionOut = -1;  // fade out
    } else if (theOscMessage.checkAddrPattern("/program/pattern") ) { 
      Pattern = theOscMessage.get(0).intValue();
      println("Pattern: ", Pattern+1);
    }
  }  

  if (theOscMessage.checkTypetag("f")) { 
    float val = theOscMessage.get(0).floatValue();  
    println(""+theOscMessage.addrPattern(), ""+val+ "");
  }
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// OSC MESSAGES SECTION CLOSE

public long totalMem() { /////////////////////////////////////////////////////////////////////////////////////////////// MEMORY MANAGEMENT FUNCTIONS START
  return Runtime.getRuntime().totalMemory();
}

public long usedMem() {
  return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
}

// ------------------------------------------------------------------------

void keyPressed() {
  // set new number

  if (key >= '0' && key <= '9') {

    // store old number
    if (Bank!=-1) {
      prevNumber = Bank;
    }
    // set new 
    Bank = int (str (key));

    /////
    newNumber = Bank;
    /////

    // manage transparencies !!!!!!!!!! 
    BankTransparencyIn = 0; // fade in
    BankTransparencyOut = maxFade; // fade out

    BankfadeDirectionIn = 1; // fade in
    BankfadeDirectionOut = -1;  // fade out
  }//if
}//func 
//

Hi,
Thanks again. Your keypress sketch works 100% :slight_smile: a new BankTxt fades in, and the previous bank fades out-

However when I follow the principle for the OSC message the new BankTxt cuts in (no fadein) while the previous BankTxt still does still fade out. I’m think I’m losing my mind!!

//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT LIBRARIES
final int maxFade=255; 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT OSC

import oscP5.*;
import netP5.*;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES
 
/////////////////////////////////////////////////////////////////////////// OSC VARIABLES

OscP5 oscP5; 

// Define 2 variables to store the bank transparency values
float BankTransparencyOut = 0; 
float BankTransparencyIn = 0;

// Define a variable to store the bank fade direction (1 for fade in, -1 for fade out)
int BankfadeDirectionIn = 1;
int BankfadeDirectionOut = 1;

int Bank = -1; // -1 means NONE  nb/ currentBankNumber
int prevNumber=-1; 
int newNumber=-1; 

int Pattern = 0; 
String[] BankTxt;
String[] PatternTxt;

/////////////////////////////////////////////////////////////////////////// TEXT VARIABLES

PFont FontBigCaslon48;

void setup() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP STARTS
  
  size(300,300);
  //println(totalMem()); //////////// Memory Management
  
  BankTxt = new String[16]; 
    BankTxt[0]="A"; /// mapped to Octatrack Banks - can be renamed to track titles e.g "A" -> "disoedd"
    BankTxt[1]="B"; 
    BankTxt[2]="C"; 
    BankTxt[3]="D"; 
    BankTxt[4]="E"; 
    BankTxt[5]="F"; 
    BankTxt[6]="G"; 
    BankTxt[7]="H"; 
    BankTxt[8]="I"; BankTxt[9]="J"; BankTxt[10]="K"; BankTxt[11]="L"; BankTxt[12]="M"; BankTxt[13]="N"; BankTxt[14]="O"; BankTxt[15]="P";
    
  PatternTxt = new String[16]; /// 6 for now = all of Bank A
    PatternTxt[0]="1"; ///  Octatrack Patterns - A1-P16 = 16 x 16 = 256 (0-255) for text to appear subsequently? array really necessary?
    PatternTxt[1]="2"; 
    PatternTxt[2]="3"; 
    PatternTxt[3]="4"; 
    PatternTxt[4]="5"; 
    PatternTxt[5]="6"; 
    PatternTxt[6]="7"; 
    PatternTxt[7]="8"; 
    PatternTxt[8]="9"; PatternTxt[9]="10"; PatternTxt[10]="11"; PatternTxt[11]="12"; PatternTxt[12]="13"; PatternTxt[13]="14"; PatternTxt[14]="15"; PatternTxt[15]="16";
  
oscP5 = new OscP5(this,10000);
        
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP CLOSE

void draw() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP START
  background (255);
  //textFont(FontBigCaslon48);
  
  BankTransparencyIn += BankfadeDirectionIn;
  BankTransparencyOut += BankfadeDirectionOut;

  if (BankTransparencyIn > maxFade) {
    BankTransparencyIn = maxFade;
    BankfadeDirectionIn = 0; // stop
  }

  if (BankTransparencyOut < 0) {
    BankTransparencyOut = 0;
    BankfadeDirectionOut = 0; // stop
  }
  
    for (int i = 0; i < 16; i++) {   ///////////////////////////////////// Bank Conditional Start
    fill(0);
    // show >
    if (Bank == i) {
      text(">", width/2-10, (height/3-55)+i*12);
    }

    // make transparency
    if (newNumber == i) {
      fill(0, BankTransparencyIn);
    }
    if (prevNumber == i) {
      fill(0, BankTransparencyOut);
    }
    text(BankTxt[i], width/2, (height/3-55)+i*12);

    for (int j = 0; j <= 16; j++) { ///////// Nested Pattern Conditional Start
      if (Pattern == j) {
        fill(0);
        text(PatternTxt[j], width/1.6, height/3);
      }
    }    //////////////////////////////////// Nested Pattern Conditional Close
    
  } /////////////////////////////////////////////////////////////////// Bank Conditional Close
  
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP CLOSE

void oscEvent(OscMessage theOscMessage) { //////////////////////////////////////////////////////////////////////// OSC MESSAGES FROM IPAD LEMUR INTERFACE

    if (Bank >= 0 && Bank <= 16) {

    // store old number
    if (Bank!=-1) {
      prevNumber = Bank;
    }
    // set new 
    Bank = int (Bank);

    newNumber = Bank;

    // manage transparencies !!!!!!!!!! 
    BankTransparencyIn = 0; // fade in
    BankTransparencyOut = maxFade; // fade out

    BankfadeDirectionIn = 1; // fade in
    BankfadeDirectionOut = -1;  // fade out
  }
  
  if (theOscMessage.checkAddrPattern("/program/bank")==true){
    
    Bank = theOscMessage.get(0).intValue(); 
    println("Bank: ", Bank+1);
    
  } else if (theOscMessage.checkAddrPattern("/program/pattern")==true){ 

  Pattern = theOscMessage.get(0).intValue();
  println("Pattern: ", Pattern+1); }

if(theOscMessage.checkTypetag("f")) { float val = theOscMessage.get(0).floatValue();  println(""+theOscMessage.addrPattern(), ""+val+ ""); }
      
} // OSC MESSAGES SECTION CLOSE


this must be AFTER Bank = theOscMessage.get(0).intValue();

awesome!! You diamond. We’re getting there I think.
A final bit of the puzzle - how might I only show the current Bank while making all others transparent?

1 Like

check out this new version

use keys 0…9



//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT LIBRARIES
final int maxFade=255; 
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// IMPORT OSC

import oscP5.*;
import netP5.*;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// GLOBAL VARIABLES

/////////////////////////////////////////////////////////////////////////// OSC VARIABLES

OscP5 oscP5; 

// Define 2 variables to store the bank transparency values
float BankTransparencyOut = 0; 
float BankTransparencyIn = 0;

// Define a variable to store the bank fade direction (1 for fade in, -1 for fade out)
int BankfadeDirectionIn = 1;
int BankfadeDirectionOut = 1;

int Bank = 0; // -1 means NONE  nb/ currentBankNumber
int prevNumber=-1; 
int newNumber=-1; 

int Pattern = 0; 
String[] BankTxt;
String[] PatternTxt;

/////////////////////////////////////////////////////////////////////////// TEXT VARIABLES

PFont FontBigCaslon48;

void setup() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP STARTS

  size(300, 300);
  //println(totalMem()); //////////// Memory Management

  BankTxt = new String[16]; 
  BankTxt[0]="A"; /// mapped to Octatrack Banks - can be renamed to track titles e.g "A" -> "disoedd"
  BankTxt[1]="B"; 
  BankTxt[2]="C"; 
  BankTxt[3]="D"; 
  BankTxt[4]="E"; 
  BankTxt[5]="F"; 
  BankTxt[6]="G"; 
  BankTxt[7]="H"; 
  BankTxt[8]="I"; 
  BankTxt[9]="J"; 
  BankTxt[10]="K"; 
  BankTxt[11]="L"; 
  BankTxt[12]="M"; 
  BankTxt[13]="N"; 
  BankTxt[14]="O"; 
  BankTxt[15]="P";

  PatternTxt = new String[16]; /// 6 for now = all of Bank A
  PatternTxt[0]="1"; ///  Octatrack Patterns - A1-P16 = 16 x 16 = 256 (0-255) for text to appear subsequently? array really necessary?
  PatternTxt[1]="2"; 
  PatternTxt[2]="3"; 
  PatternTxt[3]="4"; 
  PatternTxt[4]="5"; 
  PatternTxt[5]="6"; 
  PatternTxt[6]="7"; 
  PatternTxt[7]="8"; 
  PatternTxt[8]="9"; 
  PatternTxt[9]="10"; 
  PatternTxt[10]="11"; 
  PatternTxt[11]="12"; 
  PatternTxt[12]="13"; 
  PatternTxt[13]="14"; 
  PatternTxt[14]="15"; 
  PatternTxt[15]="16";

  oscP5 = new OscP5(this, 10000);
} ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// SET-UP CLOSE

void draw() { //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP START
  background (255);
  //textFont(FontBigCaslon48);

  BankTransparencyIn += BankfadeDirectionIn;
  BankTransparencyOut += BankfadeDirectionOut;

  if (BankTransparencyIn > maxFade) {
    BankTransparencyIn = maxFade;
    BankfadeDirectionIn = 0; // stop
  }

  if (BankTransparencyOut < 0) {
    BankTransparencyOut = 0;
    BankfadeDirectionOut = 0; // stop
  }

  // for (int i = 0; i < 16; i++) {   ///////////////////////////////////// Bank Conditional Start
  fill(0);
  // show -------------------------------------------------------------------------------------------------
  //if (Bank == i) {
  //  text(">", width/2-10, (height/3-55)+i*12);
  //}

  // make transparency
  //    if (newNumber == i) {
  fill(0, BankTransparencyIn);
  //  }
  if (newNumber!=-1)
    text(BankTxt[Bank], width/2+12, (height/3-55)+2*12);

  // if (prevNumber == i) {
  fill(0, BankTransparencyOut);
  // }
  if (prevNumber!=-1)
    text(BankTxt[prevNumber], width/2-12, (height/3-55)+2*12);

  for (int j = 0; j <= 16; j++) { ///////// Nested Pattern Conditional Start
    if (Pattern == j) {
      fill(0);
      text(PatternTxt[j], width/1.6, height/3);
    }
  }    //////////////////////////////////// Nested Pattern Conditional Close
  // } /////////////////////////////////////////////////////////////////// Bank Conditional Close
} /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// DRAW LOOP CLOSE

void oscEvent(OscMessage theOscMessage) { //////////////////////////////////////////////////////////////////////// OSC MESSAGES FROM IPAD LEMUR INTERFACE

  if (Bank >= 0 && Bank <= 16) {

    // store old number
    if (Bank!=-1) {
      prevNumber = Bank;
    }
    // set new 
    Bank = int (Bank);

    //  newNumber = Bank;

    // manage transparencies !!!!!!!!!! 
    BankTransparencyIn = 0; // fade in
    BankTransparencyOut = maxFade; // fade out

    BankfadeDirectionIn = 1; // fade in
    BankfadeDirectionOut = -1;  // fade out
  }

  if (theOscMessage.checkAddrPattern("/program/bank")==true) {

    Bank = theOscMessage.get(0).intValue(); 
    println("Bank: ", Bank+1);

    newNumber = Bank;
  } else if (theOscMessage.checkAddrPattern("/program/pattern")==true) { 

    Pattern = theOscMessage.get(0).intValue();
    println("Pattern: ", Pattern+1);
  }

  if (theOscMessage.checkTypetag("f")) { 
    float val = theOscMessage.get(0).floatValue(); 
    println(""+theOscMessage.addrPattern(), ""+val+ "");
  }
  //
} // OSC MESSAGES SECTION CLOSE

// ------------------------------------------------------------------------

void keyPressed() {
  // set new number

  if (key >= '0' && key <= '9') {

    // store old number
    if (Bank!=-1) {
      prevNumber = Bank;
    }
    // set new 
    Bank = int (str (key));

    /////
    newNumber = Bank;
    /////

    // manage transparencies !!!!!!!!!! 
    BankTransparencyIn = 0; // fade in
    BankTransparencyOut = maxFade; // fade out

    BankfadeDirectionIn = 1; // fade in
    BankfadeDirectionOut = -1;  // fade out
  }//if
}//func 
//


//

1 Like

That’s totally awesome of you - just what the doctor ordered!
I’ve tweaked it a little, and in practice what seems to work most smoothly for live performance turns out to be simpler. It seems so elegant to me, and much credit, props and thanks go to you. The best Christmas present ever! I was so frustrated!! Thanks you so much for your time and input - you rock!

Here’s what we got to… :slight_smile: :slight_smile: :slight_smile:

// Live AV sketch. Made with the invaliable assistance of the Processing Community http://discourse.processing.org
// Shouts to Abel Wondafrash, Chrisir, sableRaph,

// IMPORT LIBRARIES

// IMPORT OSC

import oscP5.*;
import netP5.*;

// GLOBAL VARIABLES
 
// IMAGE VARIABLES

final int BankMaxFade=255; 
final int PatternMaxFade=255; 

float BankTransparencyOut = 0; 
float BankTransparencyIn = 0;
int BankfadeDirectionIn = 1;
int BankfadeDirectionOut = 1;

float PatternTransparencyOut = 0; 
float PatternTransparencyIn = 0;
int PatternfadeDirectionIn = 1;
int PatternfadeDirectionOut = 1;

// OSC VARIABLES

OscP5 oscP5; 

int Bank = 0; 
int BankPrevNumber=-1; 
int BankNewNumber=1; 

int Pattern = 0; 
int PatternPrevNumber=-1; 
int PatternNewNumber=1; 

// TEXT VARIABLES

PFont FontBigCaslon48;

String[] BankTxt;
String[] PatternTxt;

void setup() { // SET-UP STARTS
  
  size(1024,768);
  println(totalMem()); // Memory Management
  
  BankTxt = new String[16]; /// mapped to Octatrack Banks - can be renamed to track titles e.g "A" -> "disoedd"
    BankTxt[0]="Abnormality"; 
    BankTxt[1]="Basilar"; 
    BankTxt[2]="Cochlea"; 
    BankTxt[3]="Decay"; 
    BankTxt[4]="Eardrum"; 
    BankTxt[5]="Frequency"; 
    BankTxt[6]="Grouping"; 
    BankTxt[7]="Hearing"; 
    BankTxt[8]="Instruments"; 
    BankTxt[9]="Judgement"; 
    BankTxt[10]="Korrektion"; 
    BankTxt[11]="Labyrinth"; 
    BankTxt[12]="Malleus"; 
    BankTxt[13]="Nerve"; 
    BankTxt[14]="Organ"; 
    BankTxt[15]=" Pain | Perception | Periodicity | Pressure | Pulse";
    
  PatternTxt = new String[16]; /// 16 for now = all of Bank A
    PatternTxt[0]="1"; ///  Octatrack Patterns - A1-P16 = 16 x 16 = 256 (0-255) for text to appear subsequently? array really necessary?
    PatternTxt[1]="2"; 
    PatternTxt[2]="3"; 
    PatternTxt[3]="4"; 
    PatternTxt[4]="5"; 
    PatternTxt[5]="6"; 
    PatternTxt[6]="7"; 
    PatternTxt[7]="8"; 
    PatternTxt[8]="9"; 
    PatternTxt[9]="10"; 
    PatternTxt[10]="11"; 
    PatternTxt[11]="12"; 
    PatternTxt[12]="13"; 
    PatternTxt[13]="14"; 
    PatternTxt[14]="15"; 
    PatternTxt[15]="16";
  
FontBigCaslon48 = loadFont("BigCaslon-Medium-48.vlw");
oscP5 = new OscP5(this,10000);    

} // SET-UP CLOSE

void draw() { // DRAW LOOP START
 
  background (255);
  textFont(FontBigCaslon48);
  
    if(frameCount % 10 == 0){ // Memory Management STARTS
    
    int percent = (int)(100*(double)usedMem()/totalMem());
    //println("Visual Processing Memory Usage:", percent + "%");
    
  } // Memory Management CLOSES
  
  // Bank Start
  
  BankTransparencyIn += BankfadeDirectionIn;
  BankTransparencyOut += BankfadeDirectionOut;

  if (BankTransparencyIn > BankMaxFade) { BankTransparencyIn = BankMaxFade; BankfadeDirectionIn = 0; }
  if (BankTransparencyOut < 0) {  BankTransparencyOut = 0;BankfadeDirectionOut = 0; }
   
  fill(0, BankTransparencyIn);

  if (BankNewNumber!=-1)
    text(BankTxt[Bank], width/2, height/3); // HERE GOES OUR BANK CLASS
    fill(0, BankTransparencyOut);

   // Bank Close 

  // Pattern Start
    
  PatternTransparencyIn += PatternfadeDirectionIn;
  PatternTransparencyOut += PatternfadeDirectionOut;

  if (PatternTransparencyIn > PatternMaxFade) { PatternTransparencyIn = PatternMaxFade; PatternfadeDirectionIn = 0; }
  if (PatternTransparencyOut < 0) { PatternTransparencyOut = 0; PatternfadeDirectionOut = 0; }
  
  fill(0, PatternTransparencyIn);
  
  if (PatternNewNumber!=-1)
    text(PatternTxt[Pattern], width/2, height/3 + 48); // HERE GOES OUR Pattern CLASS
    fill(0, PatternTransparencyOut);
 
    // Pattern Close
  
} // DRAW LOOP CLOSE

void oscEvent(OscMessage theOscMessage) { // OSC FUNCTION FROM IPAD TOUCHOSC INTERFACE

  if (theOscMessage.checkAddrPattern("/program/bank")==true){
    
    if (Bank >= 0 && Bank <= 16) { /// BANKS FADE IN AND OUT ON CHANGE - START

    if (Bank!=-1) { // store old Bank
    BankPrevNumber = Bank;
    }
    Bank = int (Bank); // set new Bank

    BankTransparencyIn = 0; 
    BankTransparencyOut = BankMaxFade; 
    BankfadeDirectionIn = 1; 
    BankfadeDirectionOut = -1;  
    
  }  // BANKS FADE IN AND OUT ON CHANGE - CLOSE
  
    Bank = theOscMessage.get(0).intValue(); 
    BankNewNumber = Bank;
    println("Bank: ", Bank+1);
  
  } else if (theOscMessage.checkAddrPattern("/program/pattern")==true){ 
    
 if (Pattern >= 0 && Pattern <= 16) { //PATTTERNS FADE IN AND OUT ON CHANGE - START

    if (Pattern!=-1) { // store old Pattern 
    PatternPrevNumber = Pattern;
    }
    Pattern = int (Pattern); // set new Pattern 

    PatternTransparencyIn = 0; 
    PatternTransparencyOut = PatternMaxFade; 
    PatternfadeDirectionIn = 1; 
    PatternfadeDirectionOut = -1;  
    
  }  // PATTERNS FADE IN AND OUT ON CHANGE - CLOSE

  Pattern = theOscMessage.get(0).intValue();
  PatternNewNumber = Pattern;
  println("Pattern: ", Pattern+1); }

if(theOscMessage.checkTypetag("f")) { float val = theOscMessage.get(0).floatValue();  println(""+theOscMessage.addrPattern(), ""+val+ ""); }
      
} /// OSC MESSAGES FUNCTION CLOSE

public long totalMem() { // MEMORY MANAGEMENT FUNCTION START

  return Runtime.getRuntime().totalMemory();
}
 
public long usedMem() {
  return Runtime.getRuntime().totalMemory() - Runtime.getRuntime().freeMemory();
  
} // MEMORY MANAGEMENT FUNCTION CLOSE
1 Like

Happy and joyful Christmas to you!