xxxxxxxxxx
let song1;
let song2;
let song3;
let scene = 1;
let image1;
let webcam;
let image_number;
let amp;
let level = 0.5;
let image2;
let image3;
var rateSlider
function preload() {
// MUSIC
song1 = loadSound('I Am Woman.mp3');
song2 = loadSound('Aint Nobody.mp3');
song3 = loadSound('Respect.mp3');
// IMAGES
image1 = loadImage('women.jpg');
image2 = loadImage('strong.jpeg');
image3 = loadImage('respected.jpg');
}
function setup() {
createCanvas(800, 600); // Larger canvas to display the images
//SLIDER
rateSlider = createSlider(-5,5,1,0.2)
imageMode(CENTER);
// Set initial image number
image_number = 1;
// AMPLITUDE
amp = new p5.Amplitude(); //load in all the data around my sound and volume
song1.play();
// Webcam setup
webcam = createCapture(VIDEO, { flipped: true });
webcam.hide();
}
function draw() {
background(250);
// Scene 1
if (scene == 1) {
image(image1, width/2, height/2); // Display image at the center of the canvas
fill(0);
circle(380, 300, 100);
noStroke();
image(webcam, 380, 300, 50, 50);
tint('transparent');
}
// Scene 2
if (scene == 2) {
image(image2, width/2, height/2); // Display image at the center of the canvas
}
// Scene 3
else if (scene == 3) {
image(image3, width/2, height/2); // Display image at the center of the canvas
}
}
function keyPressed() {
if (key == '1') {
scene = 1;
song1.play();
song2.stop();
song3.stop();
background(250, 0, 0); // background for key '1'
} else if (key == '2') {
scene = 2;
song1.stop();
song2.play();
song3.stop();
background(230,158,143); // background for key '2'
} else if (key == '3') {
scene = 3;
song1.stop();
song2.stop();
song3.play();
}
}