Hello, My goal is to play a random audio file using the trigger function. If I call a.trigger() file a is played but if I would like to call a random file between (a - z) how would i do that ? I have do it this way :
String[] audio = { "a", "b", "c" }; int index = int(random(audio.length));
audio[index].trigger();
But the following error is returned : The function trigger() does not exist.
Below is the rest of my code and I am using analog inputs running on the Arduino in the Arduino environment to trigger this sketch in processing.
import processing.serial.*; import ddf.minim.*;
AudioSample a; AudioSample b; AudioSample c;
Minim minim; int linefeed = 10; Serial myPort; int sensorValue = 0;
void setup() { println(Serial.list()); myPort = new Serial(this, Serial.list()[1], 9600); minim = new Minim(this); a = minim.loadSample("yes.wav", 2048); b = minim.loadSample("no.wav", 2048); c = minim.loadSample("maybe.wav", 2048); }
void draw() { String[] audio = { "a", "b", "c" }; int index = int(random(audio.length)); stroke(255);