import pitaru.sonia_v2_9.*; int MAX = 6; //MAX holds the number of instances of words //declare array of wordss so that the code doesnt have to be written 15 times Text[] myText = new Text[MAX]; //square brackets declares the array and have to say how long the array is, so use MAX //declare the variable a to be used as font size int a; //declare a string array 2 words long and initialise the font String [] someWords = new String[6]; PFont thefont; void setup() { background(0); //load the font by naming it thefont = loadFont ("Bauhaus.vlw.gz"); //name the words in the array someWords[0] = "street"; someWords[1] = "people"; someWords[2] = "traffic"; someWords[3] = "houses"; someWords[4] = "skyscrapers"; someWords[5] = "planes"; size(400,400); Sonia.start(this); LiveInput.start(); //set colorMode colorMode(RGB,255,255,255,100); //fill array of text using "New" -- all words are random color, random x and y location } void draw() { //background(0); int meterData = int(LiveInput.getLevel()*1000); //println(meterData); if (meterData > 0){ a = meterData; } //for loop, first value is 0, assign to variable i. so i starts at the first position //in the array which is 0 and iterates (runs through) them in sequence //fill the instance in the array with some random values //for loop here to draw random text every loop for (int i = 0; i < MAX; i++) { color tempcolor = color(random(255),random(255),random(255), random(100)); //if else statement paints different words from array depending on live input level if (meterData < 50){ myText[i] = new Text(tempcolor,random(width),(a + height - a),someWords[0]); } else if (meterData > 100 && meterData < 150){ myText[i] = new Text(tempcolor,random(width),(a + height - a),someWords[1]); } else if (meterData > 150 && meterData < 200){ myText[i] = new Text(tempcolor,random(width),(a + height - a),someWords[2]); } else if (meterData > 200 && meterData < 250){ myText[i] = new Text(tempcolor,random(width),(a + height - a),someWords[3]); } else if (meterData > 250 && meterData < 300){ myText[i] = new Text(tempcolor,random(width),(a + height - a),someWords[4]); } else if (meterData > 300 && meterData< 350){ myText[i] = new Text(tempcolor,random(width),(a + height - a),someWords[5]); } } //for each word in the myText array, call the paint functions //call the for loop again because the last one in void setup ended with the curly brackets for (int i = 0; i < MAX; i++) { myText[i].paint(); } } //define the class Text colour, x and y pos and string class Text { color paintColour; float xpos; float ypos; String words; //construct the words Text(color _paintColour, float xp, float yp, String word) { paintColour = _paintColour; xpos = xp; ypos = yp; words = word; } //paint the words void paint() { fill(paintColour); noStroke(); textFont(thefont,a); text(words,xpos,ypos); } } public void stop(){ Sonia.stop(); }