Traducción de sonidos a texto en Processing

Este código muestra un texto por la consola cuando escucha sonidos a través del micrófono.

import ddf.minim.*;
import ddf.minim.analysis.*;

FFT fft;
Minim minim;
AudioInput audioIn;

String alphabet=”abcdefghijklmnopqrstuvwxyz”;
char[] lista=new char[alphabet.length()+2];

void setup() {
size(400, 400);

minim = new Minim(this);
audioIn = minim.getLineIn(Minim.STEREO, 512);
fft = new FFT(audioIn.bufferSize(), audioIn.sampleRate());
fft.forward(audioIn.mix);

lista[0]=’ ‘;
lista[1]=’ ‘;

for(int i=2;i<lista.length;i++){
lista[i]=alphabet.charAt(i-2);
}
}

void draw(){

background(0);
fft.forward(audioIn.mix);
//println(audioIn.mix.level());

stroke(255);
float volume=audioIn.mix.level()*1000;

line(0,0,width,volume);

print(lista[getfrequency(volume)]);
}

int getfrequency(float freq){//nos convierte una freq de 124.5 a 1, o 234.2 a 2
int stepfreq=int(freq);
float auxfreq=stepfreq/100.0;
stepfreq=int(auxfreq);
return stepfreq;
}
Manual de la librería de sonido minim.

Advertisements

One thought on “Traducción de sonidos a texto en Processing

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s