Sammie Kim – Project 10 – Sonic Sketch

sketch

//Sammie Kim
//Section D
//sammiek@andrew.cmu.edu
//Project 10 - Sonic Sketch

//Global variables
var facesPic;
var laughingSound;
var cryingSound;
var surprisedSound;
var angrySound;

function preload() {
    //loading image through Imgur
    var facesURL = "https://i.imgur.com/1fPz3CY.jpg";
    facesPic = loadImage(facesURL);
    //loading sound from freesound.org
    laughingSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/laughing.wav");
    cryingSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/crying.wav");
    surpriseSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/surprise.wav");
    angrySound = loadSound("https://courses.ideate.cmu.edu/15-104/f2019/wp-content/uploads/2019/11/angry.wav");
}

function setup() {
    createCanvas(460, 200);
    background(255);
    useSound();
}

function soundSetup() {
    // setup for audio generation
    //setting volume to one for each sound
    laughingSound.setVolume(1);
    cryingSound.setVolume(1);
    surpriseSound.setVolume(1);
    angrySound.setVolume(1);
}

function draw() {
    //drawing out the image on the canvas
    background(255);
    image(facesPic, 0, 0);
}

function mousePressed() {
    //making each sound play and pause based on mouse location on canvas
    if (mouseX > 0 & mouseX < 140 ) {
        surpriseSound.play();
        } else {
        surpriseSound.pause();
        }
    if (mouseX > 140 & mouseX < 230) {
        cryingSound.play();
        } else {
        cryingSound.pause();
        }
    if (mouseX > 230 & mouseX < 336) {
        angrySound.play();
        } else {
        angrySound.pause();
        }
    if (mouseX > 336 & mouseX < width) {
        laughingSound.play();
        } else {
        laughingSound.pause();
        }
}

For this project, I wanted to incorporate sounds that show the emotions of each minion ( happy, sad, surprised, and angry). It took a while to get used to working with terminal and preloading sounds, but I feel I got a better grasp now.

Leave a Reply