import rita.*; import pitaru.sonia_v2_9.*; import processing.core.PApplet; Sample[] samples; PGrammar grammar; String[] files; boolean playing; int current = 0; PImage img; void setup() { size(1024, 768); background(32); grammar = new PGrammar(this, "creeley-grammar.g"); img = loadImage("pt_background-image.jpg"); Sonia.start(this); println("Click window to begin..."); } void draw() { background(img); // nothing playing, wait for mouse-click if (playing == false) return; // something ended, what to do next? if (samples[current].isPlaying() == false) { // was it the last line that just ended? if (current == samples.length-1) { // if so, go back to witing for mouse click println("Click mouse for next poem..."); playing = false; return; } // otherwise lets start the next line current++; samples[current].play(); println("Playing: "+files[current]); } } void stop() { Sonia.stop(); } void mouseClicked() { String soundpoem = grammar.expand(); //println("POEM: "+soundpoem); files = soundpoem.split(" "); samples = new Sample[files.length]; for (int i = 0; i < files.length; i++) { String audiofile = files[i]+".wav"; //println("loading "+audiofile); samples[i] = new Sample(audiofile); // println(files[i]); } // start the firt line playing current = 0; samples[current].play(); println("Playing: "+files[current]); playing = true; }