PLANTEXT – transspecies affective language translator // sourcecode

This is the first part of source code for PLANTEXT – transspecies affective language translator. Plants, bodies, stones and universe can speak in English now!

To run it you need to download necessary libraries aswell as and Java Developers Kit and compile all classes. This is the first one. Simple… isn’t? Say in touch!

This class is the core of the machine that can let you to get the signal from the any living tissue and in the next steps we will do utilise it!

 

package plantext;

import guru.ttslib.TTS;
import java.util.ArrayList;
import processing.core.PApplet;
import ddf.minim.AudioInput;
import ddf.minim.Minim;
import ddf.minim.analysis.FFT;

public class AudioMatrix {

private PApplet processingObject;
private ArrayList<String> matrix;
private Minim minim;
private AudioInput in;
private FFT fft;
private TTS tts;
private String keyWord;
private int bandToScan;
int valueOfSelectedFreqOFAffect;
AudioMatrix(PApplet p) {
processingObject = p;
minim = new Minim(processingObject);
in = minim.getLineIn();
fft = new FFT(in.bufferSize(), in.sampleRate());
tts = new TTS();
bandToScan = 35;
keyWord = “”;
matrix = new ArrayList<String>();
Messanger.setListening(false);
Messanger.setSpeaking(false);
}

public int getBandToScan() {
return bandToScan;
}

public void setBandToScan(int bandToScan) {
this.bandToScan = bandToScan;
}

public ArrayList<String> getmatrix(){
if (!Messanger.isListening()){Messanger.setListening(true); matrix.clear();; processingObject.thread(“matrixbuilder”); getmatrix();}
else{ try {Messanger.setListening(true); Thread.sleep(500);} catch (InterruptedException e) {e.printStackTrace();}
Messanger.setListening(false);}
return matrix;
}

public void matrixbuilder(){
try {Thread.sleep(1000);} catch (InterruptedException e) {e.printStackTrace();}
if (matrix==null){matrix = new ArrayList<String>();}
while (Messanger.isListening()){
matrix.add(Integer.toString(getBandMix(bandToScan))); try { Thread.sleep(10); } catch (InterruptedException e) { e.printStackTrace();}
}
}

public ArrayList<String> getmatrixtotranslate(){
if (!Messanger.isListening()){matrix.clear(); Messanger.setListening(true); processingObject.thread(“matrixbuilder”); getmatrix();}
else{ try {Thread.sleep(100);} catch (InterruptedException e) {e.printStackTrace();} Messanger.setListening(false);}
return matrix;
}

public void matrixbuildertotranslate(){
if (matrix==null){matrix = new ArrayList<String>();}
while (Messanger.isListening()){matrix.add(Integer.toString(getBandMix(bandToScan))); try {Thread.sleep(10);} catch (InterruptedException e) { e.printStackTrace(); }}
}

public int inmixget(int frqToGetFromTableOfCurrentFrrequenciesOfAffect) {
return (int) (in.mix.get(frqToGetFromTableOfCurrentFrrequenciesOfAffect)*100);
}

public int inmixget() {
return (int) (in.mix.get(1)*100);
}

public int getBandSize() {
return fft.specSize();
}

public int getBandMix(int frqToGetFromTableOfCurrentFrrequenciesOfAffect) {
int tmpintValueOfSelectedFreqOFAffect = valueOfSelectedFreqOFAffect;
fft.forward(in.mix);
if (frqToGetFromTableOfCurrentFrrequenciesOfAffect < fft.specSize()) {
valueOfSelectedFreqOFAffect = (int) ((fft
.getBand(frqToGetFromTableOfCurrentFrrequenciesOfAffect) * 10) % 100);
}
int diffValueOfSelectedFreqOFAffect;
if (tmpintValueOfSelectedFreqOFAffect>0){diffValueOfSelectedFreqOFAffect = valueOfSelectedFreqOFAffect – tmpintValueOfSelectedFreqOFAffect;}
else{diffValueOfSelectedFreqOFAffect = valueOfSelectedFreqOFAffect;}
return valueOfSelectedFreqOFAffect – diffValueOfSelectedFreqOFAffect;
}

public int getBandLeft(int frqToGetFromTableOfCurrentFrrequenciesOfAffect) {
int selectedFreqOFAffect = 0;
fft.forward(in.left);
if (frqToGetFromTableOfCurrentFrrequenciesOfAffect < fft.specSize()) {
selectedFreqOFAffect = (int) (((fft
.getBand(frqToGetFromTableOfCurrentFrrequenciesOfAffect) * 10) % 100));
}
return selectedFreqOFAffect;
}

public int getBandRight(int frqToGetFromTableOfCurrentFrrequenciesOfAffect) {
int selectedFreqOFAffect = 0;
fft.forward(in.right);
if (frqToGetFromTableOfCurrentFrrequenciesOfAffect < fft.specSize()) {
selectedFreqOFAffect = (int) (((fft
.getBand(frqToGetFromTableOfCurrentFrrequenciesOfAffect) * 10) % 100));
}
return selectedFreqOFAffect;
}

public int inRightGet(int i) {
return (int) in.right.get(i);
}

public int inLeftGet(int i) {
return (int) in.left.get(i);
}

public void speak(String textToSay) {
if(!Messanger.isListening()&&!Messanger.isSpeaking())
{
Messanger.setSpeaking(true);
switch (Messanger.getState()){
case 1:
Messanger.setMessage(“word stimulation process”);
break;
case 0:
Messanger.setMessage(“reading message: “+textToSay);
break;
}
tts.speak(textToSay);
Messanger.setSpeaking(false);
} else
{
Messanger.setMessage(“wait – i am listening…”);}
}

public void setStringToPrint(String linijkaDoWydrukowaniaNaEkranie) {
this.keyWord = linijkaDoWydrukowaniaNaEkranie;
}

public String getStringToPrint() {
return keyWord;
}
}

Comments

comments

editor

Michał Brzeziński - transhumanistic, and biosemiotic artist working with fauna flora and micro world, searching for affective language and life origins in matter, using medical media as EEG, GSR, USG interested in transspecies affective communication and sexual interfaces. Combining software and video biology. Creator of Galeria NT (2010). His wide, theory based, artistic and curatorial activity had animated theoretical discourse touching experimental film and video art as independent a-historical and matter-oriented aesthetic area. Curator working with galleries such as the Museum of Art in Łódź, Center for Contemporary Art Łaźnia in Gdańsk.

You may also like...

3 Responses

  1. FANTASTIC PROJECTS. thanks for sharing them.

  2. Thanks! Will you be uploading more info? I am familiar with @ProcessingOrg Do you have a tutorial about the sensors?

%d bloggers like this: