Merci de m’avoir répondu! Désolé, je connais encore mal le site.
Merci pour le conseil je vais suivre cela étape par étape. J’aimerai juste savoir comment est-ce que je map un fichier audio ou le son sur une vidéo. J’ai vu plusieurs manières:
float dB = map(mouseX, 0, width, -6, 6);
gain.setValue(dB);
Ou
float amplitude = map(mouseY, 0, height, 0.4, 0.0);
s.volume(amplitude);
}
Voici mon code mais je pense qu’il n’est pas bon du tout
import processing.serial.;
import ddf.minim.;
import ddf.minim.effects.;
import ddf.minim.ugens.;
Minim minim;
AudioOutput output;
FilePlayer groove;
LowPassFS lpf;
int lf = 10; // Linefeed in ASCII
String myString = null;
Serial myPort; // The serial port
int sensorValue = 0;
void setup() {
// Open the port you are using at the rate you want:
myPort = new Serial(this, Serial.list()[2], 9600);
myPort.clear();
// Throw out the first reading, in case we started reading
// in the middle of a string from the sender.
myString = myPort.readStringUntil(lf);
myString = null;
// we pass this to Minim so that it can load files from the data directory
minim = new Minim(this);
// loadFile will look in all the same places as loadImage does.
// this means you can find files that are in the data folder and the
// sketch folder. you can also pass an absolute path, or a URL.
// Change the name of the audio file here and add it by clicking on “Sketch —> Import File”
output = minim.getLineOut();
groove = new FilePlayer( minim.loadFileStream(“groove.mp3”) );
// make a low pass filter with a cutoff frequency of 100 Hz
// the second argument is the sample rate of the audio that will be filtered
// it is required to correctly compute values used by the filter
lpf = new LowPassFS(100, output.sampleRate());
groove.patch( lpf ).patch( output );
groove.loop();
}
void draw() {
// check if there is something new on the serial port
while (myPort.available() > 0) {
// store the data in myString
myString = myPort.readStringUntil(lf);
// check if we really have something
if (myString != null) {
myString = myString.trim(); // let’s remove whitespace characters
// if we have at least one character…
if(myString.length() > 0) {
println(myString); // print out the data we just received
// if we received a number (e.g. 123) store it in sensorValue, we sill use this to change the volume.
try {
sensorValue = Integer.parseInt(myString);
for ( int sensorValue = 0; sensorValue < output.bufferSize() - 1; i++ ){
float x1 = map(sensorValue, 0, output.bufferSize(), 0, 10);
float x2 = map(sensorValue+1, 0, output.bufferSize(), 0, 10);
}
} catch(Exception e){}
if(myString.equals("T")){
if(
}
}
}
}
}
}