14 changed files with 53 additions and 0 deletions
@ -0,0 +1,53 @@ |
|||
import processing.serial.*; |
|||
import processing.sound.*; |
|||
|
|||
SoundFile[] soundfile = {null,null,null,null,null,null}; |
|||
|
|||
Serial myPort; |
|||
String dataIn = ""; |
|||
int linefeed = 10; |
|||
int currentLang = 0; |
|||
|
|||
String[] langs = {"NONE","Italian","English","Spanish","German","French"}; |
|||
|
|||
void setup() { |
|||
size(600, 400); |
|||
myPort = new Serial(this, "/dev/ttyUSB0", 9600); |
|||
for(int i=0; i<langs.length; i++) { |
|||
println("Loading language file: "+langs[i]+".aiff"); |
|||
soundfile[i] = new SoundFile(this, langs[i]+".aiff"); |
|||
} |
|||
|
|||
println("Ready!"); |
|||
} |
|||
|
|||
|
|||
void draw() { |
|||
background(0); |
|||
|
|||
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) { |
|||
|
|||
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<langs.length; i++) { |
|||
soundfile[i].stop(); |
|||
} |
|||
soundfile[currentLang].play(); |
|||
//println(dataIn+" - "+split[0]+" - "+split[1]+" -> "+currentLang); |
|||
} |
|||
} |
|||
} |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
Reference in new issue