diff --git a/Processing/Processing.pde b/Processing/Processing.pde index 7f8e19c..d457be2 100644 --- a/Processing/Processing.pde +++ b/Processing/Processing.pde @@ -1,84 +1,92 @@ import processing.serial.*; import gohai.glvideo.*; import ddf.minim.*; +import ddf.minim.ugens.*; + +String[] langs = {"NONE","Italian","English","Spanish","German","French","Russian"}; +int langsN = langs.length; Minim minim; -AudioPlayer[] soundfile = {null,null,null,null,null,null,null}; +AudioOutput out; +AudioSample [] sample = new AudioSample[langsN]; GLMovie video; Serial myPort; String dataIn = ""; char linefeed = '\n'; int currentLang = 0; +int millis = 0; +boolean isPlaying = false; int ms = 0; -String[] langs = {"NONE","Italian","English","Spanish","German","French","Russian"}; - void setup() { - size(1024, 768, P2D); - + size(1920, 1080, P2D); + + myPort = new Serial(this, "/dev/ttyUSB0", 9600); minim = new Minim(this); - - for(int i=0; i= millis(); + if (video.available()) { video.read(); } image(video, 0, 0, width, height); - - if(soundfile[currentLang].isPlaying()) { + + if(isPlaying) { ms = ms < 255 ? ms+1 : 255; - /* - textAlign(LEFT, CENTER); - text("Playing",10,10); - */ } else { ms = ms > 0 ? ms-1 : 0; } tint(255, ms); - /* - float sw = textWidth(langs[currentLang]); - fill(255); - stroke(255); - textSize(16); - textAlign(CENTER, CENTER); - text("Selected language:", width/2, (height/2)-50); - textSize(22); - text(langs[currentLang], width/2, height/2); - */ -} - -void serialEvent(Serial thisPort) { + printLanguage(); if(myPort.available() > 0) { dataIn = myPort.readStringUntil(linefeed); if (dataIn != null) { String[] split = dataIn.split("\t"); - currentLang = parseInt(trim(split[1])); - for(int i=0; i 1 ? parseInt(trim(split[1])) : 0; + for(int i=0; i "+currentLang); + + millis = millis() + sample[currentLang].length(); + sample[currentLang].trigger(); + println("Speech " + langs[currentLang]); } } + + //println(sample[currentLang].length(), millis, millis()); +} + +void printLanguage() { + fill(255); + stroke(255); + textSize(16); + textAlign(CENTER, CENTER); + text("Selected language:", width/2, (height/2)-50); + textSize(22); + text(langs[currentLang], width/2, height/2); + + if(isPlaying) { + textAlign(LEFT, CENTER); + text("Playing",10,10); + } }