Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
package-lock.json
71 changes: 11 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,64 +1,15 @@
Assignment 4 - Creative Coding: Interactive Multimedia Experiences
===
## 3D Audio Visualizer - Kitchen by Sza

For this assignment we will focus on client-side development using popular audio/graphics/visualization technologies. The goal of this assignment is to refine our JavaScript knowledge while exploring the multimedia capabilities of the browser.
https://a4-amandalongo-a25.onrender.com

- [Three.js Tutorial](https://github.com/jmcuneo/cs4241-guides/blob/master/using.three.md)
- [WebAudio / Canvas Tutorial](https://github.com/jmcuneo/cs4241-guides/blob/main/using.webaudio_and_canvas.md)
- [SVG + D3 tutorial](https://github.com/jmcuneo/cs4241-guides/blob/main/using.svg_and_d3.md)
<img width="1512" height="730" alt="Screenshot 2025-09-30 at 9 51 17 AM" src="https://github.com/user-attachments/assets/d1a43143-c95a-41b8-b83c-51c382ec8303" />

Baseline Requirements
---
I followed a tutorial on youtube to create a audio visualizer using threejs. https://youtu.be/qDIF2z_VtHs?si=9XmV8smE7waWC5pt

Your application is required to implement the following functionalities:

- A server created using Express. This server can be as simple as needed.
- A client-side interactive experience using at least one of the following web technologies frameworks.
- [Three.js](https://threejs.org/): A library for 3D graphics / VR experiences
- [D3.js](https://d3js.org): A library that is primarily used for interactive data visualizations
- [Canvas](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D raster drawing API included in all modern browsers
- [SVG](https://developer.mozilla.org/en-US/docs/Web/API/Canvas_API): A 2D vector drawing framework that enables shapes to be defined via XML.
- [Web Audio API](https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API): An API for audio synthesis, analysis, processing, and file playback.
- A user interface for interaction with your project, which must expose at least four parameters for user control. [tweakpane](https://cocopon.github.io/tweakpane/) is highly recommended for this, but you can also use regular HTML `<input>` tags (the `range` type is useful to create sliders). You might also explore interaction by tracking mouse movement via the `window.onmousemove` event handler in tandem with the `event.clientX` and `event.clientY` properties. Consider using the [Pointer Events API](https://developer.mozilla.org/en-US/docs/Web/API/Pointer_events) to ensure that that both mouse and touch events will both be supported in your app.
- Your application should display basic documentation for the user interface when the application first loads.

The interactive experience should possess a reasonable level of complexity. Some examples:
### Three.js
- A generative algorithm creates simple agents that move through a virtual world. Your interface controls the behavior / appearance of these agents.
- A simple 3D game. You really want this to be a simple as possible or it will be outside the scope of this assignment.
- An 3D audio visualization of a song of your choosing. User interaction should control aspects of the visualization.
### Canvas
- Implement a generative algorithm such as [Conway's Game of Life](https://bitstorm.org/gameoflife/) (or 1D cellular automata) and provide interactive controls. Note that the Game of Life has been created by 100s of people using `<canvas>`; we'll be checking to ensure that your implementation is not a copy of these.
- Design a 2D audio visualizer of a song of your choosing. User interaction should control visual aspects of the experience.
### Web Audio API
- Create a screen-based musical instrument using the Web Audio API. You can use projects such as [Interface.js](http://charlie-roberts.com/interface/) or [Nexus UI](https://nexus-js.github.io/ui/api/#Piano) to provide common musical interface elements, or use dat.GUI in combination with mouse/touch events (use the Pointer Events API). Your GUI should enable users to control aspects of sound synthesis. If you want to use higher-level instruments instead of the raw WebAudio API sounds, consider trying the instruments provided by [Tone.js]() or [Gibber](https://github.com/charlieroberts/gibber.audio.lib).
### D3.js
- Create visualizations using the datasets found at [Awesome JSON Datasets](https://github.com/jdorfman/Awesome-JSON-Datasets). Experiment with providing different visualizations of the same data set, and providing users interactive control over visualization parameters and/or data filtering. Alternatively, create a single visualization with using one of the more complicated techniques shown at [d3js.org](d3js.org) and provide meaningful points of interaction for users.

Deliverables
---

Do the following to complete this assignment:

1. Implement your project with the above requirements.
1. Test your project to make sure that when someone goes to your main page on Render, etc., it displays correctly.
1. Ensure that your project has the proper naming scheme `a4-firstname-lastname` so we can find it.
1. Fork this repository and modify the README to the specifications below.
1. Create and submit a Pull Request to the original repo. Name the pull request using the following template: `a4-firstname-lastname`.

Grading
---
Unlike previous assignments, this assignment will be solely graded on whether or not you successfully complete it. Partial credit will be generously given.

Sample Readme (delete the above when you're ready to submit, and modify the below so with your links and descriptions)
---

## Your Web Application Title

your hosting link e.g. http://a4-charlieroberts.glitch.me

Include a very brief summary of your project here. Images are encouraged when needed, along with concise, high-level text. Be sure to include the following:

- the goal of the application
- challenges you faced in realizing the application
- the instructions you present in the website should be clear enough to use the application, but if you feel any need to provide additional instructions please do so here.
- I wanted to learn something creative and I have always wanted to learn threejs. I used this tutorial because I didn't quite know where to start but I really liked the formatting of the tutorial and was able to add my own things to it and remove the stuff I wasn't really looking to learn.
- The tutorial used parcel, which I didnt really know how to use. So I was able to remove it and implement express so that i could run the application easier.
- to run locally
- npm install
- npm run dev
- you can click play and pause on the bottom left corner to control the music
- you can change sizing and colors that the visualizer shows on the top right, feel free to mess around with it!
Binary file added music/kitchenSza.mp3
Binary file not shown.
18 changes: 18 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
{
"name": "amanda-longo-a4",
"version": "1.0.0",
"description": "",
"main": "scripts.js",
"scripts": {
"dev": "node server.js",
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"dat.gui": "^0.7.9",
"express": "^4.18.2",
"three": "^0.158.0"
}
}
36 changes: 36 additions & 0 deletions server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
const express = require('express');
const path = require('path');
const fs = require('fs');

const app = express();
const PORT = process.env.PORT || 3000;

const distDir = path.join(__dirname, 'dist');
const srcDir = path.join(__dirname, 'src');

// Serve built files if present, otherwise serve source files
if (fs.existsSync(distDir)) {
app.use(express.static(distDir));
console.log('Serving static files from /dist');
} else {
app.use(express.static(srcDir));
console.log('Serving static files from /src');
}

// Also expose the music folder so audio files load correctly
const musicDir = path.join(__dirname, 'music');
if (fs.existsSync(musicDir)) {
app.use('/music', express.static(musicDir));
}

// Fallback to index.html for SPA routing
app.get('*', (req, res) => {
const indexPath = fs.existsSync(path.join(distDir, 'index.html'))
? path.join(distDir, 'index.html')
: path.join(srcDir, 'index.html');
res.sendFile(indexPath);
});

app.listen(PORT, () => {
console.log(`Server listening at http://localhost:${PORT}`);
});
148 changes: 148 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width,initial-scale=1" />
<title>Assignment 4</title>
<style>
html,
body {
height: 100%;
margin: 0;
background: #000;
}
canvas {
display: block;
}
.controls {
position: fixed;
left: 16px;
bottom: 16px;
z-index: 10;
display: flex;
gap: 8px;
}
.controls button {
font: 600 14px/1.2 system-ui, sans-serif;
padding: 10px 14px;
border-radius: 10px;
border: 1px solid rgba(255, 255, 255, 0.2);
background: rgba(255, 255, 255, 0.06);
color: #fff;
cursor: pointer;
backdrop-filter: blur(6px);
}
.controls button:disabled {
opacity: 0.5;
cursor: not-allowed;
}
</style>

<!-- Import map pins exact versions so subpaths resolve -->
<script type="importmap">
{
"imports": {
"three": "https://unpkg.com/three@0.160.0/build/three.module.js",
"three/examples/jsm/": "https://unpkg.com/three@0.160.0/examples/jsm/",
"lil-gui": "https://unpkg.com/lil-gui@0.19.2/dist/lil-gui.esm.js"
}
}
</script>
</head>
<body>
<div class="controls">
<button id="playPauseBtn" disabled>Loading…</button>
</div>
<!-- Shaders live in the page; the browser ignores unknown script types and leaves the text -->
<script id="vertexshader" type="x-shader/x-vertex">
uniform float u_time;
uniform float u_frequency;

vec3 mod289(vec3 x){ return x - floor(x * (1.0/289.0)) * 289.0; }
vec4 mod289(vec4 x){ return x - floor(x * (1.0/289.0)) * 289.0; }
vec4 permute(vec4 x){ return mod289(((x*34.0)+10.0)*x); }
vec4 taylorInvSqrt(vec4 r){ return 1.79284291400159 - 0.85373472095314 * r; }
vec3 fade(vec3 t){ return t*t*t*(t*(t*6.0-15.0)+10.0); }

float pnoise(vec3 P, vec3 rep){
vec3 Pi0 = mod(floor(P), rep);
vec3 Pi1 = mod(Pi0 + vec3(1.0), rep);
Pi0 = mod289(Pi0); Pi1 = mod289(Pi1);
vec3 Pf0 = fract(P); vec3 Pf1 = Pf0 - vec3(1.0);
vec4 ix = vec4(Pi0.x, Pi1.x, Pi0.x, Pi1.x);
vec4 iy = vec4(Pi0.yy, Pi1.yy);
vec4 iz0 = Pi0.zzzz;
vec4 iz1 = Pi1.zzzz;

vec4 ixy = permute(permute(ix) + iy);
vec4 ixy0 = permute(ixy + iz0);
vec4 ixy1 = permute(ixy + iz1);

vec4 gx0 = ixy0 * (1.0 / 7.0);
vec4 gy0 = fract(floor(gx0) * (1.0 / 7.0)) - 0.5;
gx0 = fract(gx0);
vec4 gz0 = vec4(0.5) - abs(gx0) - abs(gy0);
vec4 sz0 = step(gz0, vec4(0.0));
gx0 -= sz0 * (step(0.0, gx0) - 0.5);
gy0 -= sz0 * (step(0.0, gy0) - 0.5);

vec4 gx1 = ixy1 * (1.0 / 7.0);
vec4 gy1 = fract(floor(gx1) * (1.0 / 7.0)) - 0.5;
gx1 = fract(gx1);
vec4 gz1 = vec4(0.5) - abs(gx1) - abs(gy1);
vec4 sz1 = step(gz1, vec4(0.0));
gx1 -= sz1 * (step(0.0, gx1) - 0.5);
gy1 -= sz1 * (step(0.0, gy1) - 0.5);

vec3 g000 = vec3(gx0.x,gy0.x,gz0.x);
vec3 g100 = vec3(gx0.y,gy0.y,gz0.y);
vec3 g010 = vec3(gx0.z,gy0.z,gz0.z);
vec3 g110 = vec3(gx0.w,gy0.w,gz0.w);
vec3 g001 = vec3(gx1.x,gy1.x,gz1.x);
vec3 g101 = vec3(gx1.y,gy1.y,gz1.y);
vec3 g011 = vec3(gx1.z,gy1.z,gz1.z);
vec3 g111 = vec3(gx1.w,gy1.w,gz1.w);

vec4 norm0 = taylorInvSqrt(vec4(dot(g000,g000),dot(g010,g010),dot(g100,g100),dot(g110,g110)));
g000 *= norm0.x; g010 *= norm0.y; g100 *= norm0.z; g110 *= norm0.w;
vec4 norm1 = taylorInvSqrt(vec4(dot(g001,g001),dot(g011,g011),dot(g101,g101),dot(g111,g111)));
g001 *= norm1.x; g011 *= norm1.y; g101 *= norm1.z; g111 *= norm1.w;

float n000 = dot(g000, Pf0);
float n100 = dot(g100, vec3(Pf1.x, Pf0.yz));
float n010 = dot(g010, vec3(Pf0.x, Pf1.y, Pf0.z));
float n110 = dot(g110, vec3(Pf1.xy, Pf0.z));
float n001 = dot(g001, vec3(Pf0.xy, Pf1.z));
float n101 = dot(g101, vec3(Pf1.x, Pf0.y, Pf1.z));
float n011 = dot(g011, vec3(Pf0.x, Pf1.yz));
float n111 = dot(g111, Pf1);

vec3 fade_xyz = fade(Pf0);
vec4 n_z = mix(vec4(n000,n100,n010,n110), vec4(n001,n101,n011,n111), fade_xyz.z);
vec2 n_yz = mix(n_z.xy, n_z.zw, fade_xyz.y);
float n_xyz = mix(n_yz.x, n_yz.y, fade_xyz.x);
return 2.2 * n_xyz;
}

void main(){
// BUGFIX: add vec3(u_time), not a float
float noise = 3.0 * pnoise(position + vec3(u_time), vec3(10.0));
float displacement = (u_frequency / 30.0) * (noise / 10.0);
vec3 newPosition = position + normal * displacement;
gl_Position = projectionMatrix * modelViewMatrix * vec4(newPosition, 1.0);
}
</script>

<script id="fragmentshader" type="x-shader/x-fragment">
uniform float u_red;
uniform float u_green;
uniform float u_blue;
void main(){
gl_FragColor = vec4(u_red, u_green, u_blue, 1.0);
}
</script>

<!-- Your module entry -->
<script src="./js/scripts.js" type="module"></script>
</body>
</html>
Loading