Ver Mensaje Individual
  #5 (permalink)  
Antiguo 25/10/2013, 17:30
anthony20
 
Fecha de Ingreso: octubre-2013
Mensajes: 31
Antigüedad: 10 años, 7 meses
Puntos: 0
Respuesta: Uso excesivo de memoria ram

Cita:
Iniciado por MarronsDispatcher Ver Mensaje
Péganos aquí el fragmento que te da problemas y te intentaremos ayudar.
Aquí pego todo el código, desconozco que parte es la que da los problemas:

Parte 1:

Código:
import processing.serial.*;
import com.getflourish.stt.*;
import ddf.minim.*;
import javax.sound.sampled.*;
STT stt;
String result="home";;
Minim minim;
AudioPlayer sonido;


PImage img;
Serial myPort;  // The serial port
  int reproductor = 0;
  int reproducir = 0;
  int val;
  int entradax;
  int ases = 0;
  int xxxxxxxxxxxm1 = 0;
  int xxxxxxxxxxxm2 = 0;
  int contador1 = 0;
  int i = 0;
  int i2 = 0;
  int valor2 = 1;
  int posicion =0;
  int valorcodigo = 0;
  int testigo = 0; 
  int datosa[] = {0, 0, 0, 0, 0, 0, 0, 0, 0}; //_m1 indica datos de la ases 1
  int datosb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  int datosc[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  int datosd[] = {0, 0, 0, 0, 0, 0, 0, 0, 0};
  int datosaa[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0}; //_m1 indica datos de la ases 1
  int datosbb[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int datoscc[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int datosdd[] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
  int valor = 0;
  int valorr = 0;
  int valordato = 0;
  int posiciony = 15;
  int controlenvio = 0;
  String listado1[]={"0", "Perro", "Gato", "conejo", "Hola", "Cerdo", "Frun", "Fuego", "Agua", "Trabajo", "Buenos dias", "Calamidad", "Escudo", "Espada", "Minero", "Leñador", "Aldeano", "Caballero", "Tio", "Abuelo", "Aguador", "Herrero", "Pepeton", "Gastar", "Mañana", "Tarde", "Entrenar", "Salon", "Patio", "Cuadra", "Pantalon", "Mojar", "Estraer", "...", "Caracol", "Europa", "Africa", "Sala", "38"};
  int tiempossonidos[]= {0, 1200, 1600, 1000, 1250, 1000, 1250, 1350, 1200, 1200, 1250, 1100, 1150, 1050, 1100, 1290, 1400, 1800, 1400, 1250, 1200, 1100, 1280, 1000, 650, 1000, 1100, 1800, 1900, 2000, 1900, 1200, 1200, 700};
  int tiemposjjjjs[]={500, 500, 500, 500, 500, 500, 700, 650, 500, 600};
  long previousMillis = 0;
long milliss = 0;
long puertoactivo = 0;
int controltiempo=0;
int cambio =0;
int tiempo = 0;
int puntero = -1;
int controlr = 0;
int rtodo = 0;
void setup() {
  

  // List all the available serial ports
  println(Serial.list());
  // Open the port you are using at the rate you want:
  myPort = new Serial(this, Serial.list()[0], 9600);
  img = loadImage("asessProcessing.jpg");
  size(878, 439);
  minim = new Minim(this);
stt = new STT(this);
  stt.enableDebug();
  stt.setLanguage("es"); 
   stt.enableAutoRecord();
}

void draw() 
{
  // Expand array size to the number of bytes you expect
  image(img, 0, 0);
  byte[] inBuffer;

if ((millis()-puertoactivo)>12000) 
{
  
  puertoactivo = millis();
  sonido = minim.loadFile("puerto desconectado" + ".mp3");
  sonido.play();
  
}



 while (myPort.available() > 0) {
    char inByte = myPort.readChar();
    
    valordato = Character.digit(inByte, 10);
    
    
     if (inByte == '?') 
{
  puertoactivo = millis();
  inByte = 'a';
}
    
    
 
 if (inByte == '$') 
{
  contador1++;
  inByte = 'a';
  valorcodigo = 0;
  
  i=0;

}

if (contador1 == 1 && inByte != 'a') 
{
  ases= Character.digit(inByte, 10);
  
  controlenvio = 1;
  inByte = 'a';
  
    if (ases == 1) 
{
  resetases1();
}   

    if (ases == 2) 
{
  resetases2();
}    
 
}



  if (ases == 1) 
{
  
if (contador1 == 2 && inByte != 'a') 
{
  xxxxxxxxxxxm1 = Character.digit(inByte, 10);
 
  inByte = 'a';
}    
  
if (contador1 == 3 && inByte != 'a') 
{ 
   if (inByte == '/') 
{
 
  testigo = 1; 

  inByte = 'a';
}

  
  if (testigo == 0) 
{

  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  inByte = 'a';
 
 } 
  if (testigo == 1) 
{
   datosa[i] = valorcodigo;
   i++;
   valorcodigo = 0;
   testigo = 0;
   inByte = 'a';
 }
  
}  


if (contador1 == 4 && inByte != 'a') 
{ 
  
 if (inByte == '/') 
{
 
  testigo = 1; 
  inByte = 'a';
}


  if (testigo == 0) 
{
  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  inByte = 'a';
 } 
  if (testigo == 1) 
{
   datosb[i] = valorcodigo;
   i++;
   valorcodigo = 0;
   testigo = 0;
   inByte = 'a';
 }
  
}
  
  
if (contador1 == 5 && inByte != 'a') 
{ 
 
  if (inByte == '/') 
{
 
  testigo = 1; 
  inByte = 'a';
}
 
  
  if (testigo == 0) 
{
  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  
  inByte = 'a';
 } 
  if (testigo == 1) 
{
   datosc[i] = valorcodigo;
   i++;
   valorcodigo = 0;
   testigo = 0;
   inByte = 'a';
 }
  
}  


if (contador1 == 6 && inByte != 'a') 
{ 
 
  if (inByte == '/') 
{
 
  testigo = 1; 
  inByte = 'a';
}
  
  if (testigo == 0) 
{
  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  
  inByte = 'a';
 } 
  if (testigo == 1) 
{
   datosd[i] = valorcodigo;
   i++;
   testigo = 0;
   valorcodigo = 0;
   inByte = 'a';
 }
  
}  
  
  if (contador1 == 7) 
{ 
  contador1 = 0;
  testigo = 0;
  inByte = 'a';
  controlenvio = 0;
  reproductor = 1;


 } 
}

  if (ases == 2) 
{
  
if (contador1 == 2 && inByte != 'a') 
{
  xxxxxxxxxxxm2 = Character.digit(inByte, 10);
  
  inByte = 'a';
}    
  
if (contador1 == 3 && inByte != 'a') 
{ 
  
 
 
   if (inByte == '/') 
{
 
  testigo = 1; 
  inByte = 'a';
}

  
  if (testigo == 0) 
{
  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  inByte = 'a';
 
 } 
  if (testigo == 1) 
{
   datosaa[i] = valorcodigo;
   i++;
   valorcodigo = 0;
   testigo = 0;
   inByte = 'a';
 }
  
}  


if (contador1 == 4 && inByte != 'a') 
{ 
  
 if (inByte == '/') 
{
 
  testigo = 1; 
  inByte = 'a';
}


  if (testigo == 0) 
{
  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  inByte = 'a';
 } 
  if (testigo == 1) 
{
   datosbb[i] = valorcodigo;
   i++;
   valorcodigo = 0;
   testigo = 0;
   inByte = 'a';
 }
  
}
  
  
if (contador1 == 5 && inByte != 'a') 
{ 
 
  if (inByte == '/') 
{
 
  testigo = 1; 
  inByte = 'a';
}
 
  
  if (testigo == 0) 
{
  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  
  inByte = 'a';
 } 
  if (testigo == 1) 
{
   datoscc[i] = valorcodigo;
   i++;
   valorcodigo = 0;
   testigo = 0;
   inByte = 'a';
 }
  
}  


if (contador1 == 6 && inByte != 'a') 
{ 
 
  if (inByte == '/') 
{
 
  testigo = 1; 
  inByte = 'a';
}
  
  if (testigo == 0) 
{
  valordato = Character.digit(inByte, 10);
  valorcodigo = (valorcodigo*10)+valordato;
  
  inByte = 'a';
 } 
  if (testigo == 1) 
{
   datosdd[i] = valorcodigo;
   i++;
   testigo = 0;
   valorcodigo = 0;
   inByte = 'a';
 }
  
}  
  
  if (contador1 == 7) 
{ 
  contador1 = 0;
  testigo = 0;
  inByte = 'a';
  controlenvio = 0;
  reproductor = 1;

 }
}
}

  if (mouseX>150 && mouseX<300 && mouseY>25 && mouseY<125 && controlenvio == 0 && reproductor == 0) 
  {  
    fill(80, 162, 193);
    textSize(18);
    text("ases 1", 10, 15);
    text("Mxxxx pxxxxixxs: " + xxxxxxxxxxxm1, 10, 35);
    text("Pxxxxs pxxxs: ", 10, 60); 
    posiciony=posiciony+10;
    
    valor = datosb[i];
    while (valor!=0) 
  {  
    int valorr = datosa[i];
    text(listado1[valorr] + ". Cxxxxxd: " + datosb[i], 10, 55+posiciony);
    i++;
    posiciony=posiciony+15;
    valor = datosb[i];
  } 

     if (valor==0) 
  {  
     i=0;
    posiciony=posiciony+10;
     text("Sxxxxx pxxxx: ", 10, 55+posiciony);
     posiciony=posiciony+20;
     
     valor = datosd[i];
      while (valor!=0) 
  {  
    int valorr = datosc[i];
    text(listado1[valorr] + ". Cxxxxxxd: " + datosd[i], 10, 55+posiciony);
    i++;
    posiciony=posiciony+15;
    valor = datosd[i];
  } 
  
     i=0;
     posiciony=15;
  }  
 
  } 

if (mouseX>550 && mouseX<700 && mouseY>25 && mouseY<125 && controlenvio == 0 && reproductor == 0)
  {  
    fill(80, 162, 193);
    textSize(18);
    text("ases 2", 400, 15);
    text("Mxxxxs pxxxs: " + xxxxxxxxxxxm2, 400, 35);
    text("Pxxxxs pxxxxs: ", 400, 60); 
    posiciony=posiciony+10;
    
    valor = datosbb[i];
    while (valor!=0) 
  {  
    int valorr = datosaa[i];
    text(listado1[valorr] + ". Cxxxxxd: " + datosbb[i], 400, 55+posiciony);
    i++;
    posiciony=posiciony+15;
    valor = datosbb[i];
  } 

     if (valor==0) 
  {  
     i=0;
    posiciony=posiciony+10;
     text("Sxxxs pxxxs: ", 400, 55+posiciony);
     posiciony=posiciony+20;
     
     valor = datosdd[i];
      while (valor!=0) 
  {  
    int valorr = datoscc[i];
    text(listado1[valorr] + ". Cxxxxxd: " + datosdd[i], 400, 55+posiciony);
    i++;
    posiciony=posiciony+15;
    valor = datosdd[i];
  } 
  
     i=0;
     posiciony=15;
 
  }   
  } /// final de mouse
  
  
  
  if (rtodo != 0 && reproductor == 0)
  { 
   
   i=0;
   reproductor =1;
   ases =rtodo;
   rtodo++;
   
   
   sonido = minim.loadFile("señalescucha" + ".mp3");
    sonido.play();
   
   
   if (rtodo > 2) // 2 = jjjj totalde asess 
  {
   rtodo=0; 
  }
  }
  
  
    
  if (reproductor == 1 && controlenvio == 0)
  { 
    
    
    if (controltiempo == 0)
  {
    previousMillis = millis();
    controltiempo =1;
    }
     
     if (controltiempo == 1)
  {
    if (millis()- previousMillis > tiempo)
  {
    cambio = 1;
    controltiempo = 0;
    puntero++;
    tiempo =5000000;
   }
      controltiempo =1;
    }

Salu2s