10: Sonic Story

The sonic story is a person sleeping throughout the day. He never wakes up, despite the sounds of the day and night. During the daytime, birds chirp and others are awake, and during the nighttime, the person is snoring and crickets are chirping.

sketchDownload="">
var sun;
var moon;
var crow;
var awake;
var nightSounds;
var snores;
var frameCounter = 0;
var sunset = 0;
var x = -200;
function preload () {
    moon = loadImage("https://i.imgur.com/jmfcmVw.png");
    sun = loadImage("https://i.imgur.com/on477my.png");
    morning = loadImage("https://i.imgur.com/xGVPDr2.png");
    night = loadImage("https://i.imgur.com/3XAUSES.png");

    crow = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/435507__benjaminnelan__rooster-crow-2.wav")
    awake = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/401338__ckvoiceover__yawning.wav");
    chirp = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/birdsound-1.wav");
    nightSounds = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/200167__ebonny__cicadas.wav");
    snores = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/409015__marisca16__old-man-snoring.wav");

}

function setup() {
    createCanvas(600, 400);
    frameRate(15);
    useSound();
}

function soundSetup() {
        crow.setVolume(0.3);
        awake.setVolume(0.4);
        chirp.setVolume(0.5);
        nightSounds.setVolume(0.9);
        snores.setVolume(0.5);
}


function draw() {
    imageMode(CENTER);

    if (sunset % 2 == 0) { //sunrise
        background(190, 230, 244);
        push();
        translate(115 + x, -50);
        image(sun, 200, 200, 600, 400);
        pop();
        image(morning, 300, 200, 600, 400);
    } else {

        background(46, 38, 86); //nighttime
        push();
        translate(115 + x, -50);
        image(moon, 200, 200, 600, 400);
        pop();
        image(night, 300, 200, 600, 400);
    }

    if (x == 300) {
        x = -200;
        sunset ++;
    }

    x += 5;


//morning
    if (x == -100 & sunset % 2 == 0) {
        crow.play();
    }
    if (x == -100 & sunset % 2 == 0) {
        chirp.play();
    }
    if (x == -100 & sunset % 2 == 0) {
        awake.play();
    }
//night
    if (x == -100 & sunset % 2 == 1) {
        nightSounds.play();
    }
    if (x == -100 & sunset % 2 == 1) {
        snores.play();
    }
}

I used 6 sounds. I used crowing, birds chirping, and someone yawning for the daytime sounds, and used snoring and crickets for the nighttime sounds. The biggest challenge was finding a way to align the sounds with the daytime and nighttime, and ended up using the x width and a counter to track if it is daytime or nighttime.

Leave a Reply