xxxxxxxxxx
40
function setup() {
createCanvas(400, 400);
textAlign(CENTER, CENTER);
// Set up mic
mic = new p5.AudioIn();
mic.start(); // Turn on mic
// Set up effects
delay = new p5.Delay();
filter = new p5.Filter('lowpass');
reverb = new p5.Reverb();
convolver = new p5.Convolver();
// Load an impulse response into the convolver
convolver.addImpulse('path/to/your/impulse/response.wav');
// Set up recorder
recorder = new p5.SoundRecorder();
recorder.setInput(mic); // Connect mic to recorder
// Filter setup
mic.connect(filter);
// Delay setup
filter.connect(delay);
delay.process(filter, 0.5, 0.5, 2300); // Delay time 0.5s, feedback 0.5, filter frequency 2300Hz
// Reverb setup
delay.connect(reverb);
reverb.set(3, 2); // 3 seconds reverb time, 2 seconds decay rate at 0 Hz
// Connect reverb to convolver
reverb.connect(convolver);
// Background and text
background('green');
text('Press any key to record.', width / 2, height / 2);
}