xxxxxxxxxx
49
let font;
let mic;
function preload() {
font = loadFont("Identidad-ExtraBold.otf");
}
function setup() {
createCanvas(540, 540);
textFont(font);
textAlign(CENTER, CENTER);
// Initialize the microphone input
mic = new p5.AudioIn();
mic.start();
}
function draw() {
// Get the current microphone level
let micLevel = mic.getLevel();
background(255);
blendMode(DIFFERENCE);
for (let i = 0; i < 10; i++) {
push();
let xx = 100 + tan(frameCount + i * 200) * 0.02 * 0.5;
let yy = i * 150;
let distortionAmount = map(micLevel, 0, 1, -10, 10);
translate(xx / 4 + distortionAmount, yy);
// Adjust text size based on the microphone level
let textSizeValue = map(micLevel, 0, 1, 100, 900);
textSize(textSizeValue);
// Change text color when audio level hits a threshold
if (micLevel > 0.1) {
fill(255, 0, 0); // Red color
} else {
fill(200, 0, 200); // Default color
}
rotate(tan(frameCount * 0.03));
text("PLEASE STOP", 200, height / 20);
pop();
}
}