Skip to content

Commit

Permalink
Merge pull request #2 from hannahilea/hr/p5
Browse files Browse the repository at this point in the history
Add `Sketch: Sound ripples` project
  • Loading branch information
hannahilea authored Mar 8, 2024
2 parents 589ca63 + 40f4274 commit e935822
Show file tree
Hide file tree
Showing 5 changed files with 139 additions and 10 deletions.
4 changes: 2 additions & 2 deletions blog.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Hannah Robertson's blog" />
<meta name="author" content="Hannah Robertson" />
<link rel="shortcut icon" type="image/png" href="../img/favicon.png" />
<link rel="stylesheet" type="text/css" href="../css/main.css" />
<link rel="shortcut icon" type="image/png" href="./img/favicon.png" />
<link rel="stylesheet" type="text/css" href="./css/main.css" />

<script type="module" src="https://md-block.verou.me/md-block.js"></script>

Expand Down
5 changes: 4 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<h1>@hannahilea</h1>
</div>
<h5>Hannah Robertson </h5>
<h5>DSP ENGINEER | ARTIST </h5>
<h5>DSP ENGINEER | MAKER </h5>
<!-- <h5><i>@hannahilea</i></h5> -->
</div>
<nav class="navbar" role="navigation">
Expand Down Expand Up @@ -57,6 +57,9 @@ <h5>DSP ENGINEER | ARTIST </h5>
src="https://img.shields.io/badge/linkedin-%230077B5.svg?style=for-the-badge&logo=linkedin&logoColor=white&color=0843c3"
style="height:20%; width:auto" alt="View Hannah Robertson's profile on LinkedIn" /></a>
</p>
<!-- link to cuttle -->
<!-- link to p5 -->
<!-- link to insta -->
<!-- <a href="HannahRobertsonResume2004.pdf" class="nav-link">RESUME</a> -->
</div>
</div>
Expand Down
23 changes: 16 additions & 7 deletions projects.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="Hannah Robertson's projects" />
<meta name="author" content="Hannah Robertson" />
<link rel="shortcut icon" type="image/png" href="../img/favicon.png" />
<link rel="stylesheet" type="text/css" href="../css/main.css" />
<link rel="shortcut icon" type="image/png" href="./img/favicon.png" />
<link rel="stylesheet" type="text/css" href="./css/main.css" />

<title>@hannahilea: projects</title>
</head>
Expand All @@ -18,7 +18,7 @@
<div class="row-1">
<div class="name-desc">
<div class="underline">
<h1><a href="../index.html">@hannahilea</a>'s projects</h1>
<h1><a href="./index.html">@hannahilea</a>'s projects</h1>
</div>
</div>
<nav class="navbar" role="navigation">
Expand All @@ -28,6 +28,19 @@ <h1><a href="../index.html">@hannahilea</a>'s projects</h1>
</nav>
</div>

<div>
<!-- <h3>Gallery</h3> -->
<ul>
<li><a href="./projects/sound-ripple-sketch">
<h3>Sketch: Sound ripples</h3></a>
<p>A creative coding excercise (prompt: <i>Particles, lots of them</i>), co-created with <a
href="https://hendersonreed.github.io/">Henderson Reed Hummel</a>
while at the <a href="www.recurse.com">Recurse Center</a></p></li>
<li>...</li>
</ul>
(SITE IS UNDER ACTIVE DEVELOPMENT---ADDITIONAL PROJECTS COMING SOON)
</div>

<div class="row-2">
<div class="links-outer">
<div class="mobile-buttons">
Expand All @@ -37,11 +50,7 @@ <h1><a href="../index.html">@hannahilea</a>'s projects</h1>
</div>
</div>
</div>

<div>UNDER CONSTRUCTION! PROJECTS COMING SOON.</div>

</div>

</body>

</html>
38 changes: 38 additions & 0 deletions projects/sound-ripple-sketch/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<!DOCTYPE html>
<html lang="en">

<head>
<title>Sketch: Sound ripples</title>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.7.0/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="../../css/main.css" />
<style>
canvas {
display: block;
position: absolute;
left: 0;
top: 10;
}

</style>
</head>

<body>
<nav class="navbar" role="navigation"></nav>
<div class="underline">
<h4><a href="../../index.html">@hannahilea</a> > <a href="../../projects.html">projects</a> > Sketch: Sound ripples
</h4>
</div>
</nav>
<details>
<summary>Details</summary>
<p><i>Provenance:</i> A creative coding excercise (prompt: <i>Particles, lots of them</i>), co-created with <a
href="https://hendersonreed.github.io/">Henderson Reed Hummel</a>
while at the <a href="www.recurse.com">Recurse Center</a></p>
<p><i>Usage:</i> When prompted, grant microphone access, then move your mouse around the screen while talking or
making noise.</p>
</details>
<script src="./sketch.js"></script>
</body>

</html>
79 changes: 79 additions & 0 deletions projects/sound-ripple-sketch/sketch.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
// Co-created by hannahilea (https://hannahilea.github.io/)
// and hendersonreed (https://hendersonreed.github.io/)
// as a creative coding project while at the
// Recurse Center (www.recurse.com/)
// Original p5 sketch: https://editor.p5js.org/hannahilea/sketches/Vx6KrBw6-

let mic;
let livingParticles = [];

function setup() {
createCanvas(windowWidth, windowHeight)
colorMode(HSL, 1.0);

// Create an Audio input
mic = new p5.AudioIn();

// start the Audio Input.
// By default, it does not .connect() (to the computer speakers)
mic.start();
}

function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}

function spawnParticles(volume) {
let numParticles = volume * 100;
for (let i = 0; i < numParticles; i++) {

// Different particle modes:
// Square:
// let particle = {x: mouseX, y: mouseY, energy: volume, dX: random(-1.0,1.0), dY: random(-1.0,1.0), life: 1.0};

// Funky 1d diagonal lines
// let d = random(-1.0,1.0);
// let particle = {x: mouseX, y: mouseY, energy: volume, dX: d, dY: d, life: 1.0};

// Funky x's
// let d = random(-1.0,1.0);
// let particle = {x: mouseX, y: mouseY, energy: volume, dX: random([-1,1]) * d, dY: random([-1,1]) * d, life: 1.0};

// Circular rings! Like water drops
let d = random(0, 2 * PI);
let particle = { x: mouseX, y: mouseY, energy: volume, dX: random([-1, 1]) * cos(d), dY: random([-1, 1]) * sin(d), life: volume * 8 };

// let d = random(0, 2*PI);
// let particle = {x: mouseX, y: mouseY, energy: volume, dX: random(0,1) * cos(d), dY: random(0,1) * sin(d), life: volume * 8};

livingParticles.push(particle);
}
}

function draw() {
background("darkblue");

// https://stackoverflow.com/questions/55026293/google-chrome-javascript-issue-in-getting-user-audio-the-audiocontext-was-not
getAudioContext().resume();

// Get the overall volume (between 0 and 1.0)
let vol = mic.getLevel() * 4.0;
if (vol > 0.04) {
spawnParticles(vol);
}

if (true) {
livingParticles = livingParticles.filter((particle) => {
return particle.life > 0;
});
}

livingParticles.forEach((particle) => {
fill(particle.energy, 0.75, 0.5);
noStroke();
ellipse(particle.x + particle.dX, particle.y + particle.dY, particle.life * 5, particle.life * 5);
particle.x += particle.dX;
particle.y += particle.dY;
particle.life -= .005;
});
}

0 comments on commit e935822

Please sign in to comment.