Project 10: Sonic Story

nighttimeDownload
var my=270;
var mdy=1;
var windowOpen=true;
var star;
var monster;
var windowSound;
var clock;
var fr=0;

function preload(){
    clock=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/clockticksound.wav");
    star=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/star.wav");
    windowSound=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/window.wav");
    monster=loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/growl-1.wav");
}

function setup() {
    createCanvas(480, 480);
    useSound();
    frameRate(1);
}

function soundSetup() {
    clock.setVolume(0.5);
    star.setVolume(0.2);
    windowSound.setVolume(0.5);
    monster.setVolume(1);
}

function draw() {
    background(38, 39, 59);
    drawStatic();
    //monster
    fill(0);
    if (fr>7 & fr<=17){
        monster.play();
        ellipse(260, my, 80, 60);
        rect(220, my, 80, 300-my);
        fill(255, 0, 0);
        triangle(235, my-13, 255, my-10, 245, my-5);
        triangle(285, my-13, 265, my-10, 275, my-5);
        //claws
        for (var i=0; i<3; i++){
            fill(0);
            quad(175+(i*10), 300, 180+(i*10), 295, 185+(i*10), 300, 180+(i*10), 330);
          }
        if (fr>8 & fr<=12){
            my-=5;
        }
        if (fr>12 & fr<=16){
            my+=5;
        }
    }

    //clock
    clock.play();
    push();
    translate(355, 40);
    scale(0.22);
    drawClock();
    pop();

    //star
    push();
    if (fr<5){
        star.play();
    }
    switch(fr){
        case 0: translate(290, 100); scale(0.05); break;
        case 1: translate(280, 105); scale(0.2); break;
        case 2: translate(260, 110); scale (0.3); break;
        case 3: translate(240, 115); scale(0.2); break
        case 4: translate(220, 120); scale(0.05); break;
        case 5: translate(200, 125); scale(0); break;
        default: scale(0); break;
    }

    noStroke();
    fill(255);
    drawStar();
    pop();

    //windowPane
    drawWindow();
    if (fr>6 & fr<=16){
        windowOpen=false;
    }
    if (fr==7){
        windowSound.play();
    }
    if (fr>16){
        windowOpen=true;
    }
    if (fr==17){
        windowSound.play
    }

    fr++;
    if (fr>=22){
        fr=0;
    }
}

function drawClock(){
  //from https://p5js.org/examples/input-clock.html
  var cx;
  var cy;
  var secR;
  var minR;
  var hrR;
  var cD;

  var radius=width/2;
  secR=radius*0.71;
  minR=radius*0.6;
  hrR=radius*0.5;
  cD=radius*1.7

  cx=width/2;
  cy=height/2;

  noStroke();
  fill(15);
  ellipse(cx, cy, cD+25, cD+25);
  fill(200);
  ellipse(cx, cy, cD, cD);

  var s=map(second(), 0, 60, 0, TWO_PI)-HALF_PI;
  var m=map(minute()+norm(second(), 0, 60), 0, 60, 0, TWO_PI)-HALF_PI;
  var h=map(hour()+norm(minute(), 0, 60), 0, 24, 0, TWO_PI*2)-HALF_PI;

  stroke(0);
  strokeWeight(1);
  line(cx, cy, cx+cos(s)*secR, cy+sin(s)*secR);
  strokeWeight(2);
  line(cx, cy, cx+cos(m)*minR, cy+sin(m)*minR);
  strokeWeight(4);
  line(cx, cy, cx+cos(h)*hrR, cy+sin(h)*hrR);

  strokeWeight(2);
  beginShape(POINTS);
  for(var i=0; i<360; i+=6){
      var angle=radians(i);
      var x=cx+cos(angle)*secR;
      var y=cy+sin(angle)*secR;
      vertex(x, y);
  }
  endShape();
}

function drawStatic(){
  //window
  noStroke();
  fill(64, 65, 90);
  square(25, 25, 300);
  fill(12, 13, 42);
  square(50, 50, 250);
  //bed frame and mattress
  fill(55, 34, 26);
  strokeWeight(3);
  stroke(32, 17, 11);
  rect(240, 375, 240, 105);
  rect(240, 350, 25, 130);
  noStroke();
  fill(192, 157, 167);
  quad(270, 400, 480, 400, 480, 480, 300, 480);
  fill(120, 82, 93);
  triangle(270, 480, 270, 400, 300, 480);
  //moon
  fill(248, 216, 8);
  ellipse(100, 100, 60, 60);
}

function drawStar(){
    //same code as star example from arrays lecture
    var starX=[50, 61, 83, 69, 71, 50, 29, 31, 17, 39];
    var starY=[18, 37, 43, 60, 82, 73, 82, 60, 43, 37];
    var nPoints=starX.length;
    beginShape();
    for (var i=0; i<nPoints; i++){
        vertex(starX[i], starY[i]);
    }
    endShape(CLOSE);

}

function drawWindow(){
    stroke(64, 65, 90);
    strokeWeight(10);
    noFill();
    if (windowOpen==true){
        line(175, 30, 175, 320);
        line(30, 175, 320, 175);
    }
    if (windowOpen==false){
        line(175, 30, 175, 320);
        line(30, 175, 170, 175);
        line(210, 80, 320, 40);
        line(210, 80, 210, 360);
        line(210, 360, 320, 320);
        line(210, 220, 320, 180);

    }

}

For this project I wanted to have a scene where someone goes to bed and wakes up in the middle of the night to see a monster for the spooky vibes. I struggled a bit trying to figure out all of the objects I was going to animate so I added a shooting star in the beginning.

I got the clock from the p5.js reference site and I used the same code for the star that we had in our Arrays lecture previously in the semester.

Looking Outwards 10: Computer Music

I choose to look into Michel Waisvisz and his work “Hyper Instruments.” Waisvisz was a Dutch composer and performer and invented many experimental musical instruments. He worked at STEIM in Amsterdam from 1981 until 2008. I admire Waisvisz because of his innovation and the way he blends technology and music theory together to make new instruments. I wouldn’t be able to think of half of the things he does. He uses a lot of oscillators to get his sounds and has also taken sensor data and converted it into MIDI way back in 1984, the first to do so. Waisvisz was always trying to challenge people’s definition of music by looking to new electronic instruments, and you have definitely see that in this piece.

Project-10 Sonic Story

sonic story
// Rishi Karthikeyan 
//rkarthik@andrew.cmu.edu
//Section B 

//HW 10 Sonic Story  

let elf; 
    var elfX = 350; var elfY = 225;
let santa; 
    var santaX = 115; var santaY = 225;
let santaWorkshop;
let santaAndReindeer; 
    var santaAndReindeerX = 160; var santaAndReindeerY = 250;
let santaOnChimney;
let kid; 
    var kidX = 100; var kidY = 275;
let tree;

let elfVoice;
let sleighBells;
let santaVoice;
let kidVoice;

var count = 0;
var centerX = 250;
var centerY = 200;
var dx = 30;
var dy = 5;

function preload() {
    //load images
    elf = loadImage('https://i.imgur.com/pu8ed6l.png');
    santa = loadImage('https://i.imgur.com/5rgNTe1.png');
    santaWorkshop =loadImage('https://i.imgur.com/bmjFtUd.png');
    santaAndReindeer = loadImage('https://i.imgur.com/t86lPuw.png');
    santaOnChimney = loadImage('https://i.imgur.com/NoL1xBz.png');
    kid = loadImage('https://i.imgur.com/F06Ekzc.png');
    tree = loadImage('https://i.imgur.com/qOOQlZt.png'); 

    //load sounds
    elfVoice = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/ElfVoice.wav");
    sleighBells = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/SleighBells.wav");
    santaVoice = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/SantaVoice.wav");
    kidVoice = loadSound("https://courses.ideate.cmu.edu/15-104/f2020/wp-content/uploads/2020/11/KidVoice.wav");
}


function setup() {
    createCanvas(500, 400);
    //createDiv("p5.dom.js library is loaded.");
    useSound();
    imageMode(CENTER);
    frameRate(1);
}

function soundSetup() { 
    elfVoice.setVolume(0.5);
    sleighBells.setVolume(0.5);
    santaVoice.setVolume(0.5);
    kidVoice.setVolume(0.5);
}

function draw() {
    background(200);  

    count++;

    switch (count) {
        case 1: elfVoice.play(); break;
        case 6: sleighBells.play(); break;
        case 11: santaVoice.play(); break;
        case 16: kidVoice.play(); break;
    }
    
    if (count >= 0 & count < 5) { 
        workshop();
        dy = 10;
        elfY -= dy;
        if ( elfY <= 215) {
            elfY +=20;
        }
    }
    if (count >= 5 & count < 10) { 
        reindeer(); 
        dy = 20;
        santaAndReindeerX += dx;
        santaAndReindeerY -= dy; 
    }
    if (count >= 10 & count < 15) { 
        chimney(); 
        centerY += dy;
    }
    if (count >= 15 & count < 20) {
        home(); 
        kidY -= 5;
        if ( kidY <= 270) {
            kidY +=10;
        }
    }
    if (count >=20) {
        end(); 
    } 
    
}

function workshop() {
    nightSky();
    //snow 
    fill(255);
    rect(0, 215, width, 200);
    image(santaWorkshop, centerX+80, centerY-30, 300, 100);
    image(elf, elfX, elfY, 130, 130);
    image(santa, santaX, santaY, 206, 200);
}

function reindeer() {
    nightSky();
    //moon
    noStroke();
    fill(208);
    circle(centerX, centerY-30, 200);

    //mountains 
    fill(20, 28, 38);
    beginShape();
    vertex(0, height);
    vertex(0, 270);
    vertex(105, 225);
    vertex(205, 300);
    vertex(290, 250);
    vertex(350, 280);
    vertex(450, 205);
    vertex(width, 225);
    vertex(width, height);
    endShape(CLOSE);

    image(santaAndReindeer, santaAndReindeerX, santaAndReindeerY, 270, 225);
}

function chimney() {
    nightSky();
    //roof
    image(santaOnChimney, centerX, centerY, 230, 230);
    noStroke();
    fill(195, 70, 55);
    rect(0, 315, width, 85); 
}

function home() {
    nightSky();
    
    //wall
    noStroke();
    fill(224, 193, 173);
    rect(0, 0, width, 50);
    rect(0, 0, 50, height);
    rect(250, 0, 250, height);
    rect(0, 150, width, 200);

    //floor
    fill(225, 221, 207);
    rect(0, 300, width, 100);

    //window 
    strokeWeight(5);
    stroke(255);
    noFill();
    rect(50, 50, 100, 100);
    rect(150, 50, 100, 100);
    strokeWeight(2);
    line(50, 100, 250, 100);
    line(100, 50, 100, 150);
    line(200, 50, 200, 150);

    image(kid, kidX, kidY, 150, 125);
    image(tree, 340, 220, 300, 300);
}

function end() {
    nightSky();
    noStroke();
    fill(255);
    textSize(50);
    text('The End', 185, 250);
}

function nightSky() {
    //night sky
    background(6, 20, 34);
    //stars 
    stroke(255);
    for (var i = 0; i < 1000; i++) {
        point(random(0,width), random(-0, height));
    }
}

Four Sounds (1) elf singing (2) sleigh bells (3) Santa talking (4) kid celebrating

I wanted to make something Christmas related. This story shows Santa delivering presents. This project was a lot of fun to create and helped me better understand how to code with images and sound.

LO – 10

“Aura” by the Stanford Laptop Orchestra, who also go by SLOrk, is a wonderful work or art that is very harmonic and calming. Using ChucK, a programing language specifically for music creation, and SLOrk music lanterns about nine artists move the lanterns – “auras” – from side to side to communicate with ChucK via WiFi to create the music, lights, and colors. This piece starts with one voice, and gradually the rest join in to create harmony. The initial voice “calls” the other voices to join in and their auras all have the same light, thus creating “harmony”. However, as they all join the auras become unique in color though still in harmony. As the piece ends, the artist move apart leaving their auras behind. What makes this work so special is that it embodies the “why” qualities of humans. The idea was that as human relationships grow, their auras blend and harmonize, and remain as memories. It’s the positive light radiating off others that forms as we grow close with one another and share memories. Something that we see with our “third eye” as we interact and reminisce. A lot of SLOrk’s work explores and embodies humans through music and technology. This piece was such a wonderful embodiment and a light in some stressful times we are all going through right now. Even during these crazy times we all have relationships with people that are helping us through these times.

If you want to see more of their work check out their website:

http://slork.stanford.edu

To see this specific piece:

http://slork.stanford.edu/works/aura/

And here’s the video: