// Jai Sawkar
// Section C
// jsawkar@andrew.cmu.edu
// Project 10 - Sonic Sketch
function preload() {
var facesURL = "https://i.imgur.com/3aPIhhm.jpg?" //picture of 4 people
famPic = loadImage(facesURL); //sets fam pic as the variable
hi1 = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/hi1.wav");
hi2 = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/hi2.wav");
hi3 = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/hi3.wav");
hi4 = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/hi4.wav");
}
function setup() {
createCanvas(580, 366);
useSound();
}
function soundSetup() {
//sets the volume so they do not play so loud it frightens people
hi1.setVolume(.5);
hi2.setVolume(.5);
hi3.setVolume(.5);
hi4.setVolume(.5);
}
function draw() {
//simply places the picture to fill the canvas
background(200);
image(famPic, 0, 0)
}
function mousePressed() {
// allows that if the mouse presses on person, it plays & pauses the associated song
if (mouseX > 0 & mouseX < 134){
hi1.play();
} else {
hi1.pause();
}
if (mouseX > 134 & mouseX < 314){
hi2.play();
} else {
hi2.pause();
}
if (mouseX > 314 & mouseX < 454){
hi3.play();
} else {
hi3.pause();
}
if (mouseX > 454 & mouseX < width){
hi4.play();
} else {
hi4.pause();
}
}
This week, I used sound to make a simple, yet interactive sketch of different people saying hi! I will say it took some time to play with how I to actually put sound in my sketch. After I did that, it took some time to then figure out how to reduce the volume of the sound files. Once all that was done, it was a matter of using previous skills to incorporate mouse-use into the sketch.