LO: NFTs

I read the Plagiarism Today article which discussed how copyright relates to NFTs. I really like the example used in the article that equates NFTs to limited edition posters. Having an NFT doesn’t mean no one else will have that art, and it doesn’t give the owner permission to use it for everything. An issue right now is that some people are selling art that they don’t have a copyright for. Should this be allowed? NFTs can be a cool source of revenue for artists, but if other people are selling their work that’s theft. Sites are attempting to regulate this kind of problem, but everything is so new and they haven’t had time to catch up. Similarly, courts haven’t implemented any laws around NFTs. Until that happens a huge amount of fraud could occur within NFT trading. Right now people are making a lot of money from NFTs, so it will be interesting to see how this trend continues to evolve.

https://www.plagiarismtoday.com/2021/03/16/nfts-and-copyright/

LO-11

The technological field has been and still is filled with a lot of stereotypes and biases surrounding people’s gender, race, or sexuality. It is a concrete fact that only 20% of professional computer scientists are women and only 5.8% of professional computer scientists are African American. Even though the 21st century US appears to be a progressive utopia, there’s still a lot of stigma around the technology and its developers. 

For this week’s Looking Outwards I chose an article by Meilan Solly called “Art Project Shows Racial Biases in Artificial Intelligence System”. This article addresses an issue of racial bias in the artificial intelligence tool ImageNet Roulette that was developed by artist Trevor Paglen and A.I. researcher Kate Crawford. What this tool was programmed to do is identify some characteristics of a person based on the photograph such as a photo of John F. Kennedy would be labeled “Politician” and a photo of Shakira would be labeled “Singer”. This tool seems to be impressive, right? But not everything is so simple, so perfect, so equal. When an African American young man, Tabong Kima, uploaded a photograph of himself and his friend to the tool, the ImageNet Roulette labeled him as “Wrongdoer, Offender”.  “I  might have a bad sense of humor, but I don’t think this is particularly funny”, said Kima on his Twitter page. The developers of the tool programmed descriptions such as dog, Boy Scout, or hairdresser, while others were rapist, adultress, loser, etc. The program seemed to identify white individuals largely in terms of occupation or other functional descriptors, but it classified those with darker skin solely by race and skin color: when an African American man uploaded a picture of himself the tool was only to describe him as “Black” and when an East Asian woman uploaded a photo of herself the tool described her as “Gook, Slant-eye”. The bias and racism here are seen crystal clear. 

This tool was taken off the Internet on September 27th, 2020, due to the existence of so many offensive and upsetting terms that were used to describe human beings. “We want to show how layers of bias and racism and misogyny move from one system to the next,” Paglen tells the New York Times’ Cade Metz. “The point is to let people see the work that is being done behind the scenes, to see how we are being processed and categorized all the time.” The creators of the tool told the press that the point of this project was to show the bias towards the race but my question would be just: Why? What for? Not everyone knew the point of this tool so it upset and offended a lot of people on the Internet when racist slurs popped up as their descriptions. This article pointed out how ImageNet Roulette was wrong and how it only increased the stigma around race and technology rather than got rid of it. The bias obviously exists and we shouldn’t prove it by creating more racist technology – we should fix it!

How artificial intelligence classified Julia Carrie Wong’s headshot. Photograph: ImageNet Roulette

https://www.smithsonianmag.com/smart-news/art-project-exposed-racial-biases-artificial-intelligence-system-180973207/

Solly, M. (2019, September 24). Art Project Shows Racial Biases in Artificial Intelligence System. Smithsonian.com. Retrieved November 13, 2021, from https://www.smithsonianmag.com/smart-news/art-project-exposed-racial-biases-artificial-intelligence-system-180973207/. 

Looking Outwards 11: Societal Impacts of Digital Art

In Sebastian Smee’s article, “Beeple’s digital ‘artwork’ sold for more than any painting by Titian or Raphael. But as art, it’s a great big zero.“, discusses the recent uprising of NFTs. An NFT is a digital file that allows people to bid and claim ownership over it. The article criticizes how the value of NFTs is not from the work itself but rather from market manipulation. For instance, graphic designer Beeple recently sold his work “Everydays: The First 5000 Days” for an insanely high price of $69.3 million when the piece was actually just a collage of colorful images. This goes to show the extent to which people are willing to go for the hype and how drastically the market for artwork has changed.

“Everydays: The First 5000 Days” is a digital file by the artist Beeple, who has been posting images every day since 2007. (Christie’s Images Limited 2020)

Project 10: Sonic Story

CLICK ON CANVAS TO START!

 
sonic story wordpress
var pan1; // pan
var pan2; // pan with flame
var egg1; // whole egg
var egg2; // cracked egg 
var egg3; // raw egg
var egg4; // cooked egg 
var bacon1; // raw bacon
var bacon2; // cooked bacon
var plate; 

var pansound;
var stove;
var fridge;
var crackegg;
var fryegg;
var bacon;
var tada;

var counter = false;
var count = 0;

function preload() {
    // images
    pan1 = loadImage("https://i.imgur.com/k8FOFKN.png");
    pan2 = loadImage("https://i.imgur.com/A5D1YD7.png");
    egg1 = loadImage("https://i.imgur.com/bTLCEPN.png");
    egg2 = loadImage("https://i.imgur.com/W6aWzCk.png");
    egg3 = loadImage("https://i.imgur.com/ptjZjee.png");
    egg4 = loadImage("https://i.imgur.com/f0iTWaq.png");
    bacon1 = loadImage("https://i.imgur.com/JllJSKp.png");
    bacon2 = loadImage("https://i.imgur.com/KaqJr4l.png");
    plate = loadImage("https://i.imgur.com/OKZWSey.png");

    // sounds 
    pansound = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/pansound.wav");
    stove = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/stove.wav");
    fridge = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/fridge.wav");
    crackegg = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/crackegg.wav");
    fryegg = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/fryegg.wav");
    bacon = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/bacon.wav");
    tada = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/tada.wav");
}


function setup() {
    createCanvas(400, 400);
    frameRate(1);
    pan1.resize(200, 0);
    pan2.resize(200, 0);
    egg1.resize(40, 0);
    egg2.resize(80, 0);
    egg3.resize(80, 0);
    egg4.resize(80, 0);
    bacon1.resize(40, 0);
    bacon2.resize(90, 0);
    plate.resize(200, 0);
    useSound();
}

function soundSetup() { 
    pansound.setVolume(5);
    stove.setVolume(5);
    fridge.setVolume(5);
    crackegg.setVolume(5);
    fryegg.setVolume(5);
    bacon.setVolume(5);
    tada.setVolume(5);
}


function draw() {
    background(247, 220, 224); // light pink background 
    // story line: this is basically a short clip of making breakfast. There are a lot of kitchen and cooking sounds incorporated to show each step of frying an egg and bacon. 

    if (counter == true) {
        count += 1;
    }

    // taking out pan 
    if (count > 0 & count <= 2) {
        image(pan1, 110, 230);
        pansound.play();
    }

    // turn on stove 
    if (count >= 2 & count < 4) {
        pansound.stop();
        image(pan2, 110, 230); // switch to pan with flames 
        stove.play();
    }

    // taking out egg
    if (count >= 4 & count < 5) {
        stove.stop();
        image(pan2, 110, 230);
        image(egg1, 170, 200);
        fridge.play();
    }

    // cracking egg 
    if (count >= 5 & count < 6) {
        fridge.stop();
        image(pan2, 110, 230);
        image(egg2, 150, 200);
        crackegg.play();

    }

    // raw egg in pan 
    if (count >= 6 & count < 9) {
        crackegg.stop();
        image(pan2, 110, 230);
        image(egg3, 155, 285);
        fryegg.play();
    }

    // egg sizzling -> cooked 
    if (count >= 9 & count < 12) {
        image(pan2, 110, 230);
        image(egg4, 155, 285);
    }

    // taking out bacon 
    if (count >= 12 & count < 13) {
        fryegg.stop();
        fridge.play();
        image(pan2, 110, 230);
        image(bacon1, 170, 200);
    }

    // bacon sizzling -> cooked
    if (count >= 13 & count < 15) {
        bacon.play();
        image(pan2, 110, 230);
        image(bacon2, 150, 285);
    }

    // bacon in plate w/ egg + TADA 
    if (count >= 15 & count < 16) {
        bacon.stop();
        tada.play();
        image(plate, 100, 230);
        image(bacon2, 130, 260);
        image(egg4, 180, 260);
    }
}

function mousePressed() {
    counter = true; // starts counting once click screen 
}

My sonic story is quite simple. It basically shows a breakfast of eggs and bacon being made. I drew all the graphics for the food, pan, flame, and plate. I used sounds like the fridge opening to represent taking out the ingredients. Other sounds like cracking the egg and the bacon sizzling are all to represent the cooking.

Sonic-Story

sketchDownload

//Yanina Shavialenka
//Section B

var walkImage = [];   // an array to store the images
var flying = []; //bird flying array images
var characters = [];
var birds = [];
var bg; //background image
var lightning; //lighting picture
var thunder; //thunder sound
var amb; //ambient sound
var chirp; //bird sound

function preload(){
    // These URLs are for the individual walk cycle images
    var filenames = [];
    filenames[0] = "https://i.imgur.com/14ifmej.png";
    filenames[1] = "https://i.imgur.com/r9GhjWn.png";
    filenames[2] = "https://i.imgur.com/A0L2KVp.png";
    filenames[3] = "https://i.imgur.com/JFE5CBm.png";
    filenames[4] = "https://i.imgur.com/14ifmej.png";
    filenames[5] = "https://i.imgur.com/r9GhjWn.png";
    filenames[6] = "https://i.imgur.com/A0L2KVp.png";
    filenames[7] = "https://i.imgur.com/JFE5CBm.png";
    filenames[8] = "https://i.imgur.com/14ifmej.png";
    filenames[9] = "https://i.imgur.com/r9GhjWn.png";
    filenames[10] = "https://i.imgur.com/A0L2KVp.png";
    filenames[11] = "https://i.imgur.com/JFE5CBm.png";

    // These URLs are for the individual bird cycle images
    var file = [];
    file[0] = "https://i.imgur.com/82McfxQ.png";
    file[1] = "https://i.imgur.com/OMNJ7z2.png";
    file[2] = "https://i.imgur.com/ZP2mduv.png";
    file[3] = "https://i.imgur.com/2ly1P4T.png";
    file[4] = "https://i.imgur.com/5VNmIMy.png";
    file[5] = "https://i.imgur.com/KjJmaEd.png";
    file[6] = "https://i.imgur.com/036LD8g.png";
    file[7] = "https://i.imgur.com/OPD7VfW.png";
    file[8] = "https://i.imgur.com/Rt8p00H.png";

    // These for loops change the images to create a walking and flying effect
    for (var i = 0; i < filenames.length; i++) {
        walkImage[i] = loadImage(filenames[i]);
    }

    for (var i = 0; i < file.length; i++) {
        flying[i] = loadImage(file[i]);
    }

    //loads the images and sounds
    bg = loadImage("https://i.imgur.com/nqIhKWP.png");
    lightning = loadImage("https://i.imgur.com/6kvwrHw.gif");
    lightning.resize(150,0);
    thunder = loadSound("http://localhost:8000/thunder.wav");
    amb = loadSound("http://localhost:8000/amb.wav");
    chirp = loadSound("http://localhost:8000/bird.wav");
}

// Constructor for each walking character
function makeCharacter(cx, cy, cdx, cdy) {
    var c = { x: cx, y: cy, dx: cdx, dy: cdy,
             imageNum: 0,
             stepFunction: stepCharacter,
             drawFunction: drawCharacter
        }
    return c;
}

// Constructor for each blying bird
function makeBird(cx, cy, cdx, cdy) {
    var c = { x: cx, y: cy, dx: cdx, dy: cdy,
             imageNum: 0,
             stepFun: stepBird,
             drawFun: drawBird
        }
    return c;
}

function stepCharacter() {
    this.imageNum++;
    if(this.imageNum >= walkImage.length) {
       this.imageNum = 0;
    }
     
    this.x += this.dx; 
}

function stepBird() {
    this.imageNum++;
    if(this.imageNum >= flying.length) {
       this.imageNum = 0;
    }
     
    this.x += this.dx; 
}

//This function draws the corresponding image
function drawCharacter() {
    image(walkImage[this.imageNum],this.x,this.y);
}

function drawBird() {
    image(flying[this.imageNum],this.x,this.y);
}

//This function creates the canvas and makes the character
function setup() {
    createCanvas(612,408);
    frameRate(15);
    for (var i = 0; i < walkImage.length; i++) {
        walkImage[i].resize(150,0);
    }
    for (var i = 0; i < flying.length; i++) {
        flying[i].resize(50,0);
    }
    characters.push(makeCharacter(0,125,1,0));
    birds.push(makeBird(0,50,3,0));
    useSound(0);
}

function soundSetup() {
    thunder.setVolume(0.5);
    amb.setVolume(0.2);
    chirp.setVolume(0.1);
}

function draw() {
    background(bg);
    if(frameCount >= 100) {
        image(lightning,425,-10);
        image(lightning,-20,-10);
        thunder.play();
        tint(100);
        characters[0].stepFunction();
        characters[0].drawFunction();
        birds[0].stepFun();
        birds[0].drawFun();
        characters[0].dx = 4;
        birds[0].dx = 6;
    }
    else {
        characters[0].stepFunction();
        characters[0].drawFunction();
        birds[0].stepFun();
        birds[0].drawFun();
        amb.play();
        chirp.play();
    }
}

For me, this assignment was really challenging considering the fact that we did not spend a lot of time on the sound topic so I was really struggling and tried to come up with something interesting and easy at the same time. In my code I made a girl walk and a bird fly: I used a sound effect to represent the chirping of a bird and sounds of an outside world. Then, the lightning strikes and the thunder sound comes off with dark background.

I could not upload the file properly here because the thunder sound is more than WordPress accepts and thus the file was not able to get loaded onto here.

Project 10: Sonic Story

wpf-curves.js
//Patrick Fisher wpf@andrew.cmu.edu Assignment-10-project
var fireSound;
var earthSound;
var windSound;
var waterSound;
var rockxarray = []; //array for falling rocks
var rockyarray = [];
var dy = 12; //drop rate for rocks
var fireYPoints = []; //array for the points for drawing the fire 
var noiseParam = 0; //variable for noise function
var noiseStep = 0.05; //variable to change noiseParam
var windx = []; //wind sweep x array
var windy = []; //wind swee y array
var wind2x = [];
var wind2y = [];
var waterPoints = []; //array for the points for drawing the river
var oppoWaterPoints = [];
var framesC = 0; //frame count variable 

function preload() {
    fireSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/fireedit.wav");
    earthSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/earthedit.wav");
    windSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/windedit.wav");
    waterSound = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/wateredit.wav");
}


function setup() {
    createCanvas(500, 300);
    for(var i = 0; i <= 19; i++){ //establish rocks
        rockxarray[i] = random(0,500);
        rockyarray[i] = random(0,20);
    }
    for(var i = 0; i <= 120; i++){ //establishes fire
        fireYPoints[i] = map(noise(noiseParam),0,1,100,300);
        noiseParam += noiseStep
    }
    for(var i = 0; i <= 120; i++){ //establsihes water
        waterPoints[i] = map(noise(noiseParam),0,1,0,height/2);
        oppoWaterPoints[i] = map(waterPoints[i],0,height/2,height,height/2)
        noiseParam += noiseStep
    }

    for(var i = 0; i <= 19; i++){ //establish wind 1 array
        windy[i] = map(noise(noiseParam),0,1,100,300);
        windx[i] = map(noise(noiseParam),0,1,100,500);
        noiseParam += noiseStep
    }

    for(var i = 0; i <= 19; i++){ //establishes wind 2 array
        wind2y[i] = map(noise(noiseParam),0,1,100,300);
        while(wind2y[i] == windy[i]){
            wind2y[i] = map(noise(noiseParam),0,1,100,300);
        }
        wind2x[i] = map(noise(noiseParam),0,1,100,500);
        while(wind2x[i] == windx[i]){
            wind2x[i] = map(noise(noiseParam),0,1,100,300);
        }

        noiseParam += noiseStep
    }

    createDiv("p5.dom.js library is loaded.");
    //======== call the following to use sound =========
    useSound();
    frameRate(4);

}


function soundSetup() { // setup for audio generation
    fireSound.setVolume(0.5);
    earthSound.setVolume(0.5);
    waterSound.setVolume(0.5);
    windSound.setVolume(0.5);
}


function draw() {
    background(40);
    if(framesC == 0){ //does the earth section
        earthSound.play();

    }
    if(framesC < 28){
        earthDraw();

    }

    if(framesC == 28){ //does the fire section
        fireSound.play();

    }
    if(framesC >= 28 & framesC < 56){
        fireDraw();
    }

    if(framesC == 56){ //does the wind section
        windSound.play();
    }
    
    if(framesC >= 56 & framesC < 84){ 
        windDraw();
    }

    

    if(framesC == 84){ //does the water section
        background(40);
        waterSound.play();
    }
    if(framesC >= 84 & framesC < 112){

        waterDraw();
    }

    if(framesC == 112){ //ends the program
        background(0);
        noLoop();
    }



    framesC ++;
} 

function waterDraw() { // draws the water
    
    push();
    noStroke();
    fill(158,196,226);
    waterPoints.shift(); //removes the last entry in the array to make room for the next one
    waterPoints.push(map(noise(noiseParam),0,1,0,height/2));
    oppoWaterPoints.shift();
    oppoWaterPoints.push(map(waterPoints[120],0,height/2,height,height/2))
    beginShape(); //begins drawing the mountain
    for(i = 0; i <= 120; i++){    //for loop that makes the peaks     
        vertex(i*5,waterPoints[i]);
        vertex(i*5,oppoWaterPoints[i]);
    }
    endShape(CLOSE);
    noiseParam += noiseStep;
    pop();

}

function fireDraw() { //draws the fire

    push();
    noStroke();
    fill(248,103,19);
    beginShape(); //begins drawing the fire
    vertex(0,height);
    for(i = 0; i <= 120; i++){    //for loop that makes the fire     
        vertex(i*5,fireYPoints[i]);
    }
    vertex(width,height);
    endShape(CLOSE);

    for(var i = 0; i <= 120; i++){ //for loop that initrially fills the array
        fireYPoints[i] = map(noise(noiseParam),0,1,100,300);
        noiseParam += noiseStep
    }
    pop();

}

function earthDraw() { //draws the rocks

    for(var i = 0; i <= 19; i++){
        fill(87,64,52);
        ellipse(rockxarray[i],rockyarray[i],random(5,10,random(5,10))); //draws the rocks, the randomness makes them "tumble"
        rockyarray[i] += dy; //moves the rocks down
    }   
}

function windDraw() { //draws the wind

    push();
    strokeWeight(5);
    stroke(190,239,143);

    for(var i = 0; i <= 9; i++) {
        line(windx[i],windy[i],windx[i+1],windy[i+1]); //draws the wind
    }
    windx.push(random(100,500)); //shifts the array and adds new points
    windy.push(random(100,300));
    windx.shift();
    windy.shift();

    for(var i = 0; i <= 9; i++) {
        line(wind2x[i],wind2y[i],wind2x[i+1],wind2y[i+1]);
    }
    wind2x.push(random(100,500));
    wind2y.push(random(100,300));
    wind2x.shift();
    wind2y.shift();
    
}

I was inspired by the intro to a certain children’s cartoon. My sounds are earth, fire, air, and water. It was surprisingly difficult to find quality sounds of some of these, and I had a lot of trouble with the web server stuff.

Sonic Story

sketch

Fishies! For this week’s project, I wade an infinite animation of a fish eating a fish eating a fish eating a… the colors are randomly generated and there are two pitches playing the jaws theme, and chomping and background underwater sounds from freesounds.org. Enjoy!!


function setup() {
    createCanvas(400, 200);
    useSound();
    frameRate(4);
    background('lightblue');
    chooseColor1();
    chooseColor2();
}


function soundSetup() {
    osc = new p5.Oscillator();
    osc.amp(1);
    osc.setType('sine');
    osc.start();
}

function preload() {
    chomp = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/Chomp.wav");
    bg = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/bg.wav");
    bg.setVolume(0.75);
    chomp.setVolume(0.5);
}

var r;
var g;
var d;
var col1;
var col2;

function chooseColor1(){
    r = random(100,255);
    g = 140;
    b = random(100,255);
    col1 = color(r,g,b);
}

function chooseColor2(){
    r = random(100,255);
    g = 140;
    b = random(100,255);
    col2 = color(r,g,b);
}

function drawFish1(x, y, s, c, mouthClosed, lookingFord) {
    push();
    translate(x, y);
    scale(s);
    strokeCap(SQUARE)
    strokeWeight(1);

    var fil = color(red(c)+20, green(c)+20, blue(c)+20);

    if (mouthClosed == true) {
        //top half of fish (colored w/ c)
        //fill
        stroke(fil);
        fill(fil);
        triangle(-17, -5, -12,-2, -17, -1);
        rect(-17, -1, 7, 3);
        rect(-16, 2, 3, 1);
        rect(-6,-5, 16, 5);
        line(-6, -2, -10,-2);
        line(-6, -3, -8,-3);
        line(10, -2, 17, -2);
        line(10, -3, 14, -3);

        //outline
        stroke(c);
        line(-17, 2, -17, -6);
        point(-16,-6);
        point(-15,-5);
        point(-14,-4);
        point(-13,-3);
        point(-12,-2);
        point(-11,-2);
        point(-10,-3);
        point(-9,-3);
        point(-8,-4);
        point(-7,-4);
        line(-6,-5, -2, -5);

        //fin
        stroke(fil);
        rect(-1, -8, 4, 4);
        triangle(-1, -7,-3, -5, -1, -5);
        line(3, -6, 5, -6);

        stroke(c);
        point(-4, -6);
        point(-3, -7);
        line(-2, -8, 3, -8);
        point(3, -7);
        point(4, -7);
        point(5, -6);

        line(2,-5, 10, -5);
        point(11,-4);
        point(12,-4);
        point(14,-3);
        point(15,-3);
        line(16,-2, 18, -2);

        //bottom half of fish
        //finn fill
        stroke(240);
        fill(240);
        rect(-5, 4, 4, 2);

        stroke(220);
        point(-16, 4);
        point(-15, 4);
        line(-14, 3, -10, 3);
        line(-10, 4, -6, 4);
        line(-6, 5, 0, 5);

        //fin
        stroke(220)
        point(-6,5);
        point(-7,5);
        point(-7, 6);
        line(-6, 7, -2, 7);
        line(-2, 6, 10, 6)

        stroke(240);
        line(11, 5, 0, 5);
        line(12, 5, 0, 5);
        line(13, 4, -5, 4);
        line(14, 3, -10, 3);
        line(15, 2, -10, 2);
        line(16, 1, -10, 1);
        line(17, 0, -10, 0);
        line(18, -1, -10, -1);

        //gills
        stroke(204,194,194);
        point(0,2);
        point(1,1);
        point(2,2);
        point(3,1);
        point(4,2);
        point(5,1);
        point(6,2);

        stroke(220);
        point(10, 5);
        point(11, 5);
        point(12, 4);
        point(13, 3);
        point(14, 2);
        point(15, 1);
        point(16, 0);
        point(17, -1);



        //eye
        fill(255);
        stroke(255);
        rect(9, -1, 4, 2);
        rect(10, -2, 2, 4);
        stroke(0);
        //if (lookingFord) {
            point(11,0);
        //} else if (!lookingFord) {
        //    point(10, -1);
        //}

        pop();
    } else {
        //top half of fish (colored w/ c)
        stroke(fil);
        fill(fil);
        triangle(-17, -5, -12,-2, -17, -1);
        rect(-17, -1, 7, 3);
        rect(-16, 2, 3, 1);
        rect(-6,-5, 16, 5);
        line(-6, -2, -10,-2);
        line(-6, -3, -8,-3);
        line(10, -2, 17, -2);
        line(10, -3, 14, -3);

        stroke(c);
        line(-17, 2, -17, -6);
        point(-16,-6);
        point(-15,-5);
        point(-14,-4);
        point(-13,-3);
        point(-12,-2);
        point(-11,-2);
        point(-10,-3);
        point(-9,-3);
        point(-8,-4);
        point(-7,-4);
        line(-6,-5, -2, -5);

        //fin
        stroke(fil);
        rect(-1, -8, 4, 4);
        triangle(-1, -7,-3, -5, -1, -5);
        line(3, -6, 5, -6);

        stroke(c);
        point(-4, -6);
        point(-3, -7);
        line(-2, -8, 3, -8);
        point(3, -7);
        point(4, -7);
        point(5, -6);

        line(2,-5, 10, -5);
        point(11,-4);
        point(12,-4);
        point(14,-3);
        point(15,-3);
        line(16,-2, 18, -2);

        //bottom half of fish
        //finn fill
        stroke(240);
        fill(240);
        rect(-5, 4, 4, 2);

        stroke(220);
        point(-16, 4);
        point(-15, 4);
        line(-14, 3, -10, 3);
        line(-10, 4, -6, 4);
        line(-6, 5, 0, 5);

        //fin
        stroke(220)
        point(-6,5);
        point(-7,5);
        point(-7, 6);
        line(-6, 7, -2, 7);
        line(-2, 6, 10, 6)

        stroke(240);
        line(11, 5, 0, 5);
        line(13, 5, 0, 5);
        line(16, 4, -5, 4);
        line(17, 3, -10, 3);
        line(14, 2, -10, 2);
        line(13, 1, -10, 1);
        line(12, 0, -10, 0);
        line(18, -1, -10, -1);

        stroke(204,194,194);
        point(0,2);
        point(1,1);
        point(2,2);
        point(3,1);
        point(4,2);
        point(5,1);
        point(6,2);

        stroke(220);
        point(10, 5);
        point(11, 5);
        point(12, 5);
        point(13, 4);
        point(14, 4);
        point(15, 4);
        point(16, 3);
        point(17, 3);

        //eye
        fill(255);
        stroke(255);
        rect(9, -1, 4, 2);
        rect(10, -2, 2, 4);
        stroke(0);
        point(11,0);

        pop();
    }
}

function drawFish2(x, y, s, c, mouthClosed, lookignFord) {
    push();
    translate(x, y);
    scale(s);
    strokeCap(SQUARE)
    strokeWeight(1);

    var fil = color(red(c)+20, green(c)+20, blue(c)+20);

    if (mouthClosed == true) {
        //top half of fish (colored w/ c)
        stroke(fil);
        fill(fil);
        triangle(-15, -5, -12,-2, -15, -1);
        rect(-15, -1, 7, 3);
        rect(-14, 2, 3, 1);
        rect(-6,-5, 16, 5);
        line(-6, -2, -8,-2);
        line(-6, -3, -6,-3);
        line(10, -2, 17, -2);
        line(10, -3, 14, -3);

        stroke(c);
        line(-15, 2, -15, -4);
        //point(-16,-6);
        point(-15,-5);
        point(-14,-4);
        point(-13,-3);
        point(-12,-2);
        point(-11,-2);
        point(-10,-3);
        point(-9,-3);
        point(-8,-4);
        point(-7,-4);
        line(-6,-5, -2, -5);

        //fin
        stroke(fil);
        rect(-1, -8, 4, 4);
        triangle(-1, -7,-3, -5, -1, -5);
        line(3, -6, 5, -6);

        stroke(c);
        point(-4, -6);
        point(-3, -7);
        line(-2, -8, 3, -8);
        point(3, -7);
        point(4, -7);
        point(5, -6);

        line(2,-5, 10, -5);
        point(11,-4);
        point(12,-4);
        point(14,-3);
        point(15,-3);
        line(16,-2, 18, -2);

        //bottom half of fish
        //finn fill
        stroke(240);
        fill(240);
        rect(-5, 4, 4, 2);

        stroke(220);
        point(-16, 4);
        point(-15, 4);
        line(-14, 3, -10, 3);
        line(-10, 4, -6, 4);
        line(-6, 5, 0, 5);

        //fin
        stroke(220)
        point(-6,5);
        point(-7,5);
        point(-7, 6);
        line(-6, 7, -2, 7);
        line(-2, 6, 10, 6)

        stroke(240);
        line(11, 5, 0, 5);
        line(12, 5, 0, 5);
        line(13, 4, -5, 4);
        line(14, 3, -10, 3);
        line(15, 2, -10, 2);
        line(16, 1, -10, 1);
        line(17, 0, -10, 0);
        line(18, -1, -10, -1);

        stroke(204,194,194);
        point(0,2);
        point(1,1);
        point(2,2);
        point(3,1);
        point(4,2);
        point(5,1);
        point(6,2);

        stroke(220);
        point(10, 5);
        point(11, 5);
        point(12, 4);
        point(13, 3);
        point(14, 2);
        point(15, 1);
        point(16, 0);
        point(17, -1);



        //eye
        fill(255);
        stroke(255);
        rect(9, -1, 4, 2);
        rect(10, -2, 2, 4);
        stroke(0);
        //if (lookingFord) {
            point(11,0);
        //} else if (!lookingFord) {
        //    point(10, -1);
        //}

        pop();
    } else {
        //top half of fish (colored w/ c)
        stroke(fil);
        fill(fil);
        triangle(-17, -5, -12,-2, -17, -1);
        rect(-17, -1, 7, 3);
        rect(-16, 2, 3, 1);
        rect(-6,-5, 16, 5);
        line(-6, -2, -10,-2);
        line(-6, -3, -8,-3);
        line(10, -2, 17, -2);
        line(10, -3, 14, -3);

        stroke(c);
        line(-17, 2, -17, -6);
        point(-16,-6);
        point(-15,-5);
        point(-14,-4);
        point(-13,-3);
        point(-12,-2);
        point(-11,-2);
        point(-10,-3);
        point(-9,-3);
        point(-8,-4);
        point(-7,-4);
        line(-6,-5, -2, -5);

        //fin
        stroke(fil);
        rect(-1, -8, 4, 4);
        triangle(-1, -7,-3, -5, -1, -5);
        line(3, -6, 5, -6);

        stroke(c);
        point(-4, -6);
        point(-3, -7);
        line(-2, -8, 3, -8);
        point(3, -7);
        point(4, -7);
        point(5, -6);

        line(2,-5, 10, -5);
        point(11,-4);
        point(12,-4);
        point(14,-3);
        point(15,-3);
        line(16,-2, 18, -2);

        //bottom half of fish
        //finn fill
        stroke(240);
        fill(240);
        rect(-5, 4, 4, 2);

        stroke(220);
        point(-16, 4);
        point(-15, 4);
        line(-14, 3, -10, 3);
        line(-10, 4, -6, 4);
        line(-6, 5, 0, 5);

        //fin
        stroke(220)
        point(-6,5);
        point(-7,5);
        point(-7, 6);
        line(-6, 7, -2, 7);
        line(-2, 6, 10, 6)

        stroke(240);
        line(11, 5, 0, 5);
        line(13, 5, 0, 5);
        line(16, 4, -5, 4);
        line(17, 3, -10, 3);
        line(14, 2, -10, 2);
        line(13, 1, -10, 1);
        line(12, 0, -10, 0);
        line(18, -1, -10, -1);

        stroke(204,194,194);
        point(0,2);
        point(1,1);
        point(2,2);
        point(3,1);
        point(4,2);
        point(5,1);
        point(6,2);

        stroke(220);
        point(10, 5);
        point(11, 5);
        point(12, 5);
        point(13, 4);
        point(14, 4);
        point(15, 4);
        point(16, 3);
        point(17, 3);

        //eye
        fill(255);
        stroke(255);
        rect(9, -1, 4, 2);
        rect(10, -2, 2, 4);
        stroke(0);
        point(11,0);

        pop();
    }
}

var count = 0;
var mouthClosed;
var lookingFord;

function draw() {
    background('lightblue');

    if (count%32==0) {
        count = 0;
        col1 = col2;
        chooseColor2();
        osc.start();
        bg.play();
        bg.loop();
    }

    if (count > 8) {
        mouthClosed = true;
        osc.stop();
        //lookignFord = false;
    } else {
        mouthClosed = false;
        //lookignFord = true;
    }

    if (count <= 8) {
        if (count%2==0) {
            drawFish1(width/2, height/2, 3, col1, true);
            osc.freq(midiToFreq(52));
        } else if ((count+1)%2==0) {
            osc.freq(midiToFreq(53));
            drawFish2(width/2, height/2, 3, col1, true);
        }
    }

    var bigFishX = map(count, 0, 12, -200, 200);
    var bigFishS = map(count, 12, 24, 10, 3);

    if (count == 5) {
        chomp.play();
    }

    if (count <= 12) {
        if (count%2==0) {
            drawFish1(bigFishX, height/2, 10, col2, mouthClosed);
        } else if ((count+1)%2==0) {
            drawFish2(bigFishX, height/2, 10, col2, mouthClosed);
        }
    } if (count > 12 & count <= 24) {
        if (count%2==0) {
            drawFish1(width/2, height/2, bigFishS, col2, mouthClosed);
        } else if ((count+1)%2==0) {
            drawFish2(width/2, height/2, bigFishS, col2, mouthClosed);
        }
    } if (count > 24) {
        if (count%2==0) {
            drawFish1(width/2, height/2, 3, col2, mouthClosed);
        } else if ((count+1)%2==0) {
            drawFish2(width/2, height/2, 3, col2, mouthClosed);
        }
    }

    count += 1;
}

4. Project 10: Sonic Story

sketch – CopyDownload
// This program displays a game of cup pong.
// The 'characters' are the ball, cups, table, and water in the cups.
// When the ball bounces on different surfaces (on the floor, into a cup, etc.),
// it produces different sounds.
// One side wins when all of the cups are empty
//(or just a few if you change the 'win' variable in the draw function).

// sounds:
var watercup;
var emptycup;
var bouncefloor;
var throwing;
var gameover;


// objects:
var cup; // will have fields for cx, cy, and boolean isFull
var ball; // will have fields for x, y, dx, dy, and functions

// arrays:
var leftCups = [];
var rightCups = [];

function preload() {
    watercup = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/pong-sounds-with-liquid.wav");
    bouncefloor = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/bouncing-ping-pong-ball.wav");
    throwing = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/throwing-paper-in-trash.wav");
    gameover = loadSound("https://courses.ideate.cmu.edu/15-104/f2021/wp-content/uploads/2021/11/ending.wav");
}

// makes a cup object, always full to begin
function makeCup(cx, cy) {
    cup = {x:cx, y:cy, isFull: true, drawc: drawCup};
    return(cup);
}

// makes a ball object
function makeBall(cx, cy, dirx, diry) {
    ball = {x:cx, y:cy,
            dx:dirx, dy:diry,
            drawb: drawBall,
            throwb: throwBall,
            resetb: resetBall,
            leftright: true};
    return(ball);
}

function setup() {
    createCanvas(480, 300);
    frameRate(35);	// high framerate is better for this program
    useSound();
    rectMode(CENTER);

    // fill cup arrays:
    // set x and y positions to create pyramid shape.
    // the if statements create the rows for the pyramid
    for (var i=0; i<10; i++) {
        if (i<4) {
	    lcup = makeCup(width/10+10,	(i*20)+120);
            rcup = makeCup(9*width/10-10, (i*20)+120);
        }
        else if (i<7) {
	    lcup = makeCup(width/10+30,	(i*20)+50);
            rcup = makeCup(9*width/10-30, (i*20)+50);
        }
        else if (i<9) {
	    lcup = makeCup(width/10+50,	i*20);
            rcup = makeCup(9*width/10-50, i*20);
        }
        else {
	    lcup = makeCup(width/10+70,	height/2);
            rcup = makeCup(9*width/10-70, height/2);
        }
        leftCups.push(lcup);
        rightCups.push(rcup);
    }

    // create ping pong ball
    let dy = random(-4, 4);
    ball = makeBall(5, height/2, 5, dy);
}

function soundSetup() { // setup for audio generation
    watercup.setVolume(0.5);
    bouncefloor.setVolume(0.5);
    throwing.setVolume(0.5);
    gameover.setVolume(0.5);
}


function draw() {
    background(133, 94, 66);

    // draw the table
    drawTable();

    // draw the cups
    for (var c=0; c<leftCups.length; c++) {
        leftCups[c].drawc();
        rightCups[c].drawc();
    }

    // draw the ball
    ball.drawb();

    // throw the ball
    ball.throwb();

    // check for winner
    let checkl = 0;
    let checkr = 0;
    for (l=0; l<leftCups.length; l++) {
        if (leftCups[l].isFull == false) { checkl+=1 }
    }
    for (r=0; r<rightCups.length; r++) {
        if (rightCups[r].isFull == false) { checkr+=1 }
    }
    // when one side wins, display text and play sound
    // change 'win' value to see game over sooner:
    let win = 10;
    if (checkl == win|| checkr == win) {
        gameover.play();
        textAlign(CENTER, CENTER);
        textSize(25);
        fill(0);
        rect(width/2, height/2, width/2, 50, 10);
        fill(255);
        text('Game Finished!', width/2, height/2);
        noLoop();
    }


}

// draws a green table with offwhite diagonal lines:
function drawTable() {
    let linescol = color(250, 250, 225);
    let tcol = color(0, 100, 100);
    strokeWeight(7);
    stroke(linescol);
    fill(tcol);
    rect(width/2, height/2, 4*width/5, 4*height/5);
    line(width/10, height/10, 9*width/10, 9*height/10);
    line(width/10, 9*height/10, 9*width/10, height/10);
}

// draws individual cups based on x and y fields:
function drawCup() {
    let diam = 20;
    fill(200, 0, 0);	// red cup
    stroke(255);
    strokeWeight(2);
    circle(this.x, this.y, diam);
    // if the cup hasnt been hit, it has water in it:
    if (this.isFull == true) {
        noStroke();
        fill(0, 0, 200);	// blue water
        circle(this.x, this.y, diam/2);
    }
}

// draws the ball
function drawBall() {
    stroke(0);
    strokeWeight(.5);
    fill(250);
    circle(this.x, this.y, 10);
}

//throws the ball
function throwBall() {
    if (this.leftright==true) {		// going left to right
        if (this.x < width/2) {
            this.x += this.dx;
            this.y -= this.dy;
        } else {
            this.x += this.dx;
            this.y += (1.5*this.dy);
        }
        // remove the water if the ball goes into a full cup and reset ball placement
	// play water cup noise if cup is hit
        for (var j=0; j<rightCups.length; j++) {
            if (dist(rightCups[j].x, rightCups[j].y, this.x, this.y)<=7 &
		rightCups[j].isFull==true) {
	   	watercup.play();
                rightCups[j].isFull = false;
                this.resetb();
            }
        }
    } else {				// going right to left
        if (this.x > width/2) {
            this.x -= this.dx;
            this.y -= this.dy;
        }
        else {
            this.x -= this.dx;
            this.y += (1.5*this.dy);
        }
	// same code to remove water from hit cup
        for (var j=0; j<leftCups.length; j++) {
            if (dist(leftCups[j].x, leftCups[j].y, this.x, this.y)<=7 &
		leftCups[j].isFull==true) {
	   	watercup.play();
                leftCups[j].isFull = false;
                this.resetb();
            }
        }
    }
    // no cups are hit, reset the ball position & play floor bounce track
    if (this.x > width || this.x < 0 ) {
       	this.resetb();
        bouncefloor.play();
    }
}

//resets the ball to the next players starting position
function resetBall() {
    this.leftright = -this.leftright;
    if (this.leftright == true) {this.x=10}
    else {this.x =width-10}
    this.y = height/2;
    this.dy = random(-4, 4);
    // plays a 'whoosh' track for each throw
    throwing.play();
}

I chose to make a program that displays a game of water pong. The sounds I use are a ‘whoosh’ noise when a ball is thrown, a ‘clink’ sound if the ball goes into a full cup, a bouncing pingpong ball noise if the ball does not go into any full cups, and a bell noise if there is a winner. My code is randomized in a way that every game will be slightly different.

Project-10: Sonic Story

My Project

//Chuong Truong;
//cbtruong;
//cbtruong@andrew.cmu.edu;
//Section B;

//The Overall Story of this program is that of fall;
//Leaves are falling off of trees, the sun is getting whiter;
//The air is getting frostier;
//And the birds are seen more actively flying;
//I included no custom sound and instead wanted to portray a scene;
//That was described with a song;


//initial empty array that will hold leaf objects;
var leaves = [];
//variables for the sun's green and blue values which change;
var sunG = 238;
var sunB = 82;
//initial empty array for birds;
var birds = [];

//function of the leaf object that allows it to fall;
function leafFall (){
    //stops each leaf from falling off the canvas;
    //if it has not reached that point, it will continue to fall until it does;
    if (this.f == true){
        if (this.y > height-17){
            this.y = height-5;
        }
        else {
            this.y += random(30, 60);
        }
    }
    //if met, this condition causes the leaf to fall;
    //this randomization occurs to allow for the tree and leaves to be more lifelike;
    //as not all leaves fall off immediately;
    else if (floor(random(200)) == 25){
            this.y += random(30);
            this.x += random(-15, 15);
            this.f = true;

        }
    return this.y;
}

//function that draws the leaves;
function drawLeaf(){
    //this switch and case allows for color variance for the leaves;
    //the colors are those of fall;
    switch(this.col){
      case 0: fill(237, 164, 23); break;
      case 1: fill(167, 159, 15); break;
      case 2: fill(233, 134, 4); break;
      case 3: fill(223, 57, 8); break;
      case 4: fill(201, 30, 10); break;
    }
    rectMode(CENTER);
    push();
    translate(this.x, this.y);
    rotate(radians(45));
    rect(0, 0, 15, 15);
    pop();
}

//function that makes leaves;
function leaf(lx, ly, cPreset){
    //the leaf object constructor;
    l = {x: lx, y: ly, orgY: ly, col: cPreset, f: false, 
        drawFunction: drawLeaf, fallFunction: leafFall};
    return l;
}

function makeLeavesOnTrees (x, y){
    //for loops create the leaves on the trees themselves;
    //the leaves' x and y are dependent on the tree's x and y;
    //the first row is 17 and then decreases by 1 as the row gets closer to the tree's x;
    //as the row gets closer, the leaves' initial x and y increase;

    //this variable allows the leaves to center as each row of them becomes less;
    //it is initalized again to allow for the top row to be centered correctly;
    //like it was before the nested for loops below change it;
    var centeringX = 80;

    //the starting number of leaves for each row
    var leavesRowNum = 17;

    //these nested for loops creates the leaves and gives them their inital x and y;
    //the inner loop creates the leaves for each row, giving them the x, y, and colorPreset;
    //the outer loop controls the leaves' y, as it decreases, a new row will not only be drawn;
    //but that row's total number of leaves decreases, and the centering of them is centered;
    //the loops repeat until only 5 leaves are left and they are closest to the tree's x and y;
    for (var j = 120; j > -10; j-= 10){
        for (var i = 0; i < leavesRowNum; i++){
        var l = leaf(x-centeringX + i*10, y-j, floor(random(5)));
        leaves.push(l);
    }
    //the leaves row number decreases to make each row have less leaves;
    leavesRowNum--;
    //the centering is decreased to make sure the row, as it becomes less in number;
    //is centered correctly to the tree's x;
    centeringX -= 5;
    }
}

//this function creates bird objects;
function bird (bx, by){
    //bird object constructor;
    b = {x: bx, y: by, orgY: by, flyFunction: birdFly, drawFunction: drawBird};
    return b;
}

//function that allows the bird to fly;
function birdFly (){
    this.x -= 10;
    if (this.x < 0){
        this.x = width - 20;
    }
    if (this.y > this.orgY + 20 ){
        this.y -= 5;
    }
    else {
        this.y += 5;
    }
}

//this draws the bird;
function drawBird(){
    fill(36, 143, 190);
    circle(this.x, this.y, 20);
    fill(30);
    circle(this.x, this.y, 5);
    fill(131, 67, 51);
    triangle(this.x-15, this.y, this.x - 10, this.y - 2, this.x - 10, this.y+2);
    stroke(0);
    line(this.x - 15, this.y, this.x - 10, this.y);
    fill(16, 123, 170);
    push();
    rectMode(CORNER);
    translate(this.x, this.y);
    rotate(270);
    rect(0+5, 0 - 12, 15, 10);
    rect(0+5, 0 + 4, 15, 10);
    pop();
}


function setup() {
    createCanvas(700, 500);
    frameRate(10);
    useSound();
    frameRate(3);

    //calls the makeLeavesOnTree function to create the leaves pattern;
    //on each tree dependent on the trees' location;
    makeLeavesOnTrees(125, 390);
    makeLeavesOnTrees(350, 390);
    makeLeavesOnTrees(575, 390);

    //calls the bird function and creates the bird objects;
    for (var i = 0; i < 7; i++){
         var bD = bird(random(100, 600), random(70, 120));
         birds.push(bD);
    }
}
//I kept the same sound setup from the assignment because I liked the sounds;
function soundSetup() { 
    osc = new p5.Oscillator();
    osc.amp(0.25);
    osc.setType('sine');
    osc.start();
}


function draw() {
    //this creates the background of a blue sky and  green grass;
    background(154, 211, 222);
    noStroke();
    rectMode(CORNER);
    fill(24, 136, 39);
    rect(0, 475, 700, 5);
    fill(14, 146, 49);
    rect(0, 480, 700, 20);

    //calls the drawTree function to draw trees;
    drawTree(125, 390);
    drawTree(350, 390);
    drawTree(575, 390);
    
    //this for loop updates and draws each leaf in the leaves array;
    for (var i = 0; i < leaves.length; i++){
        var l = leaves[i];
        l.fallFunction();
        l.drawFunction();
    }
    
    //calls the clouds function to make clouds;
    drawClouds(125, 80);
    drawClouds(325, 130);
    drawClouds(525, 105);

    //draws the sun;
    //this if statement allows for the sun to slowly change colors;
    if (!(sunG == 250 & sunB == 193)){
        sunG += 1.2/5;
        sunB += 11.1/5;
    }
    noStroke();
    fill(255, sunG, sunB);
    circle(600, 75, 100);
    print(leaves.length);

    //draws the birds;
    for (var o = 0; o < birds.length; o++){
        var b = birds[o];
        b.flyFunction();
        b.drawFunction();
    }

    //I turned the code from the assignment into a function;
    musicPlayer(pitches, durations);
}

//function that draws the trees without the leaves;
function drawTree (x, y){
    fill(191, 75, 25);
    rectMode(CENTER);
    rect(x, y, 20, 205);
    push();
    translate(x - 40, y - 40);
    rotate(radians(-30));
    rect(0, 0, 10, 150);
    pop();
    push();
    translate(x + 40, y - 40);
    rotate(radians(30));
    rect(0, 0, 10, 150);
    pop();
    push();
    translate(x - 30, y - 70);
    rotate(radians(-30));
    rect(0, 0, 8, 100);
    pop();
    push();
    translate(x + 30, y - 70);
    rotate(radians(30));
    rect(0, 0, 8, 100);
    pop();
    push();
    translate(x - 20, y - 90);
    rotate(radians(-30));
    rect(0, 0, 5, 80);
    pop();
    push();
    translate(x + 20, y - 90);
    rotate(radians(30));
    rect(0, 0, 5, 80);
    pop();
    push();
    translate(x - 5, y - 100);
    rotate(radians(-30));
    rect(0, 0, 3, 60);
    pop();
    push();
    translate(x + 5, y - 100);
    rotate(radians(30));
    rect(0, 0, 3, 60);
    pop();
    rect(x, y - 105, 2, 40);
}

//this function creates the clouds and draws them;
function drawClouds (x, y){
    fill(243, 242, 231);
    ellipse(x, y, 80, 50);
    ellipse(x + 20, y + 10, 80, 40);
    ellipse(x - 40, y + 10, 80, 30);
    ellipse(x - 10, y + 20, 70, 50);
}

//I used the same code from the assignments to make the music;

//arrays for the pitches and durations;
//also count variables for the index and frameCount;
//finally, the boolean rest is added to account for rests in the music;

//I changed the pitches and went with a simple 1 beat per note;
var pitches = [ 64, 64, 62, 64, 64, 62, 0, 62, 64, 66, 65, 67, 65, 0,
  60, 60, 62, 66, 65, 64, 62, 68, 68, 65, 64, 62, 62 ];
var durations = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
var indexTracker = 0;
var frameCount = 0;
var rest = false;

//I turned the code that creates the music with different notes and beat durations into a function;
//the function takes a note array and a corresponding note duration array;
function musicPlayer (noteArray, noteDurationArray){

    //code for the piano to play;
    //this sets the frequencies of the oscillator to the MIDI pitches;
    osc.freq(midiToFreq(noteArray[indexTracker]));
    
    //checks for when the note's duration is over and acts accordingly;
    if (frameCount > noteDurationArray[indexTracker]){
        //this checks for whether the tune has been completely played;
        //if it has been, then the program and oscillator ends;
        if (indexTracker + 1 == noteArray.length) {
            //print(frameCount);
            //print(indexTracker);
            osc.stop();
            noLoop();
        }
        //if it has not been completely played, then the next note will play;
        //with the frameCount reset to 0;
        else {
        print(frameCount);
        indexTracker++;
        //after the indexTracker is increased;
        //it checks to see if the new note is a rest;
        //if it is, then it deals according;
        //it also turns on the oscillator after a rest;
        if (noteArray[indexTracker] != 0){
            if (rest == true) {
            osc.start();
            rest = false;
                }
            }
        else if (noteArray[indexTracker] == 0){
            rest = true;
            osc.stop();
            }
        }
        frameCount = 0;
    }
    else {
        frameCount++;
    }
    print(noteArray[indexTracker]);
}

Instead of making 4 sounds, I used the same code from the assignments to make a song that I felt fit what I wanted to show, a scene of Fall. That scene has birds flying, leaves falling, and a sun that becomes whiter and whiter to fit the upcoming Winter.