/** * displays strings from supercollider on the screen * * * rtwomey@u.washington.edu * */ import oscP5.*; OscP5 oscP5; PFont fontA; final int FONT_SIZE=200; final color BG1=#000000;//#FFFFFF; final color TXT1=#FFFFFF;//#000000; final color BG2=#FFFFFF; final color TXT2=#000000;//#000000; final int margin = 30; int fadePrompt=0; int fadeModel=0; String prompt=""; String model=""; void setup() { size(1024, 1300);//1280, 1024); //size(screen.width, screen.height); background(BG1); smooth(); // Load the font. Fonts must be placed within the data // directory of your sketch. A font must first be created // using the 'Create Font...' option in the Tools menu. // Uncomment the following two lines to see the available fonts //String[] fontList = PFont.list(); //println(fontList); textAlign(CENTER, CENTER); fontA = createFont("Helvetica-Bold", 255); textFont(fontA, FONT_SIZE); /* start oscP5, listening for incoming messages at port 12000 */ oscP5 = new OscP5(this, 12000); } void drawPrompt(String prompt, int fade) { fill(BG1); rect(0, 0, width, height/2); fill(TXT1, fade); text(prompt, margin, margin, width-2*margin, (0.5*height)-2*margin); } void drawModel(String model, int fade) { fill(BG2); rect(0, height/2, width, height/2); fill(TXT2, fade); text(model, margin, (height*0.50)+margin, width-2*margin, (0.5*height)-2*margin); } /* incoming osc message are forwarded to the oscEvent method. */ void oscEvent(OscMessage theOscMessage) { /* print the address pattern and the typetag of the received OscMessage */ // println("### received an osc message."); // println(" addrpattern: "+theOscMessage.addrPattern()); // println(" typetag: "+theOscMessage.typetag()); String addrpat = theOscMessage.addrPattern(); String strval = theOscMessage.get(0).stringValue(); //println(theOscMessage.toString()); //theOscMessage.print(); //theOscMessage.printData(); if (match(addrpat, "/promptfile")!=null) { println("Received: "+strval); prompt=strval; fadePrompt=128; //drawPrompt(strval); } if (match(addrpat, "/modelfile")!=null) { println("Received: "+strval); model=strval; fadeModel=192; //drawResponse(strval); } } void draw() { if (fadePrompt>0) { drawPrompt(prompt, fadePrompt); //fadePrompt--; }; if (fadeModel>0) { drawModel(model, fadeModel); //fadeModel--; }; }