Sound processing IN and OUT issues

Hi everyone, I am having some problems with my code, and maybe someone could help me.

I am doing a code where I use sensors to start audio playback and to start some sound effects. When I separate the codes - audio playback code and sound effects code - they work perfectly, but together, the sound effects part doesn’t work. Regarding the sound effects, they are to be used over the input of a micro and not over audio reproduction.
Thanks in advance.

My code:

import javafx.scene.layout.Background;
import processing.serial.*;
import processing.sound.*;
import cc.arduino.*;
import ddf.minim.*;

Minim minim;//leitor de audio

//player e criar a lista de faixas
AudioPlayer player;
String[] viagens = {
  "1.mp3", "2.mp3", "3.mp3", "4.mp3", "5.mp3"
}
;
int current=0;
//abrir canal de micro e efeito de delay reverb e whitenoise
AudioIn in;
Delay delay;
Reverb reverb;
Arduino arduino;

//definir as portas de cada sensor
int sensorPin1 = 8;
int sensorPin2 = 9;
int sensorPin3 = 10;
int sensorPin4 = 11;
int sensorPin5 = 12;





void setup() {
  size(1200, 700);
  background(random(255));
  frameRate(10);

  // Modify this line, by changing the "0" to the index of the serial
  // port corresponding to your Arduino board (as it appears in the list
  // printed by the line above).
  arduino = new Arduino(this, Arduino.list()[2], 57600);

  // Alternatively, use the name of the serial port corresponding to your
  // Arduino (in double-quotes), as in the following line.
  //arduino = new Arduino(this, "/dev/tty.usbmodem621", 57600);

  // Set the Arduino digital pins as inputs.
  //for (int i = 0; i <= 13; i++)
  arduino.pinMode(sensorPin1, Arduino.INPUT);
  arduino.pinMode(sensorPin2, Arduino.INPUT);
  arduino.pinMode(sensorPin3, Arduino.INPUT);
  arduino.pinMode(sensorPin4, Arduino.INPUT);
  arduino.pinMode(sensorPin5, Arduino.INPUT);

  // Create an array of empty soundfiles
  minim = new Minim(this);
  
 int zardSon = int(random(viagens.length));
 String son = viagens[zardSon];
 player = minim.loadFile(son);
 player.pause();
 background(0);
 
    // create the input stream
  in = new AudioIn(this, 0);

  // create a delay effect
  delay = new Delay(this);
    
  // Patch the delay
  delay.process(in, 5);
  delay.time(0.9);
  
  //patch the reverb
  reverb = new Reverb(this);
reverb.room(0.9);
  reverb.damp(0.9);
  reverb.wet(0.7);

  
in.play();

}
void draw() {
  //read a digital value from the sensor pin
  int val = arduino.digitalRead(sensorPin1);
  int val1 = arduino.digitalRead(sensorPin2);
  int val2 = arduino.digitalRead(sensorPin3);
  int val3 = arduino.digitalRead(sensorPin4);
  int val4 = arduino.digitalRead(sensorPin5);


  //change the background accordingly
  
  if (val == Arduino.HIGH) {
    // se não está a tocar, começa a tocar
    if (!player.isPlaying())
    {
       
       int zardSon = int(random(viagens.length));
      String son = viagens[zardSon];
     player = minim.loadFile(son);
      player.play();
       player.setVolume(0.2);
    } 
    // caso contrário faz-se rewind
 
    background(100,0,0);
  } 
  // se não houver sinal o background fica a negro
  else background(0);
  
  if  (val1 == Arduino.HIGH) {
    player.pause();
    
    background(51);
  } 
  if (val2 == Arduino.HIGH) {  
     
     reverb.process(in);
    
   } 
   if (val3 == Arduino.HIGH) {
    
     delay.process(in);
 
 }
     
     if (val4 == Arduino.HIGH) {       
       delay.stop();
 
  reverb.stop();

       
  
        
   }
  else background(0);

}

Hi @Travasso. Is there a reason you are using both Minim and Processing Sound? In general it’s not a best practice to mix sound libraries as they can compete for resources, but it can work. I can actually get both working based on your example, except I don’t have an Arduino to test the serial port. That may be the source of your problem. Have you tried playing back your audio files using Processing Sound instead?

Hi Robert, thanks for you help.
Actually I solved the problem creating two channels In.

Arduino in, in1;

And using the effects on those different channels.

My point is to play an instrument with the audio and process my instrument with the effects triggered through the sensors.