please format code with </> button * homework policy * asking questions
I’m trying to get audio output from processing after receiving input from an arduino. I was just trying to test the processing code without the Arduino and found the gain does not increase part 6.026dB for any mp3 I tried. The setVolume method doesn’t work at all for me. I haven’t tried it on windows just MacOS.
Is there a way around the decibel cap or a better way to set volume?
import ddf.minim.*;
import ddf.minim.AudioPlayer;
import processing.serial.*;
Minim minim;
AudioPlayer middleCNote;
boolean start_audio = true;
boolean playing = true;
boolean stop_audio = false;
void setup () {
size(480, 360);
myPort = new Serial(this, Serial.list()[0], 38400); // also make sure baud rate matches Arduino
bg = loadImage("keyboard.jpg");
minim = new Minim(this);
middleCNote = minim.loadFile("do-80236.mp3");
}
void draw() {
background(bg);
if (start_audio) {
middleCNote.setGain(12);
middleCNote.play();
//middleCNote.setVolume(volume);
println(middleCNote.getGain());
} else if (stop_audio) {
middleCNote.pause();
middleCNote.rewind();
}
if (playing == true) {
fill(200, 0, 0);
ellipse(30, 260, 20, 20);
}
}
void serialEvent (Serial myPort) {
if ( myPort.available() > 0) {
String arduinoASCII = myPort.readStringUntil('\n');
String[] asci_list = split(arduinoASCII, ' '); //expecting two arguments so split by ' ' delimiter
print("out: ");
print(arduinoASCII);
if (!playing && float(asci_list[0]) == 1) {
playing = true;
start_audio = true;
} else if (float(asci_list[0])==0) {
playing = false;
}
if (asci_list[0].equals("NaN") == false) {
volume =float(asci_list[1]);
}
}
}