• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • about this course
  • syllabus
  • rubric
  • labs
  • blog

HCI | TechX

August 13, 2020

Homework Day 6 – Simon Hsieh

For the visualization process, I decided to use the existing smiley face program and alter it so the size changes with its amplitude. I found a piece of code in examples that got the job done for me, and implemented that code on my work. The result was a smiley face grooving with the music playing.

import processing.sound.*;
SoundFile sample;
Amplitude rms;
float smoothingFactor = 0.1;
float sum;

float u;
float v;
float speedU;
float speedV;

void setup() {
sample = new SoundFile(this, “The White Stripes – Fell In Love With A Girl.mp3”);
sample.loop();
rms = new Amplitude(this);
rms.input(sample);
size(500, 500);
background(255);
frameRate(3.4E+38);
u = 0;
v = 0;
speedU = 0.05;
speedV = 0.1;
}

void draw() {
background(255);
sum += (rms.analyze() – sum) * smoothingFactor;
float rms_scaled = sum * (height/2);
drawFace(u, v, color(0,0,0), rms_scaled);
u = u + speedU;
v = v + speedV;
if(u > width || u < 0){ speedU = -speedU; } if(v > width || v < 0){
speedV = -speedV;
}
}

void drawFace(float x, float y, color c, float size) {
fill(c);
ellipse(x, y, size, size);
fill(255);
ellipse(x – size/5, y – size/10, size/10, size/10);
ellipse(x + size/5, y – size/10, size/10, size/10);
arc(x, y, size0.7, size0.7, 0, PI);
}

Effect – Sound Visualization

Filed Under: blog

Reader Interactions

Leave a Reply Cancel reply

You must be logged in to post a comment.

Primary Sidebar

Recent Posts

  • Homework Day 8 – Simon Hsieh
  • homework day 8 – Michael
  • Homework-day8-Sophie
  • Harry Hao HW DAY8
  • homework day 8 – dora

Copyright © 2025 HCI | TechX on the Brunch Pro Theme