choosing not to fret
First day with a fretless banjo.
colorsfretlessareYaClawhammerinmusesspectrumwavesfftsoundProcessThoughtstmp2
let colors = [
"#31505e",
"#336279",
"#327595",
"#678492",
"#949286",
"#baa179",
"#deaf6b",
"#f9bd63",
"#f2c57f",
"#e9ce9a"
];
let fretless;
let areYaClawhammerin = false;
let muses = [];
let spectrum;
let waves;
let fft;
let t = 0;
let n = 100;
function preload() {
userStartAudio();
fretless = loadSound("/assets/My%20Song%207.m4a");
}
function setup() {
muses = [];
createCanvas(windowWidth, windowHeight);
fretless.amp(0.4);
describe(
"fretless banjo doodle with 5 lines of circles like strings, a larger white circle that fades in and out in size and opacity, and other circles moving in an orbit of various sizes that move with the music. The sketch starts by clicking on it. the color palette is muted yellows, blues and yellows and oranges"
);
fft = new p5.FFT();
spectrum = fft.analyze();
for (let i = 0; i < spectrum.length; i++) {
muses.push(new Thoughts(i, random([-80, -40, 0, 40, 80])));
}
noStroke();
}
function draw() {
translate(width / 2, height / 2);
if (areYaClawhammerin) {
t += 0.005;
if (!fretless.isPlaying()) {
fretless.play();
}
} else {
fretless.pause();
}
background(50, 70, 80, 5 + 50 * abs(cos(t / 1.3)));
soundProcess();
if (!areYaClawhammerin) {
push();
fill(colors[0]);
triangle(
-width / 2 + 20,
height / 2 - 30,
-width / 2 + 20,
height / 2 - 50,
-width / 2 + 40,
height / 2 - 40
);
pop();
}
fill(255, 255, 255, 3 + 2 * sin(t / 4));
circle(0, 0, width / 3 + (width / 3) * cos(t / 2));
}
function soundProcess() {
spectrum = fft.analyze();
waves = fft.waveform();
for (let i = 0; i < spectrum.length; i += 5) {
for (let j = 0; j < 7; j++) {
push();
noStroke();
muses[i].display(spectrum[i] / 10, waves[i]);
pop();
}
}
}
class Thoughts {
constructor(i, x) {
this.i = i;
let c =
(min(width, height) - (min(width, height) / spectrum.length) * i) * 0.2;
this.L = random(-c, c);
this.theta = random(-PI, PI);
this.x = ((this.i % 5) * width) / 5;
this.x1 = x;
this.y = this.L * cos(this.theta);
this.t = 1;
this.dt = random(0.000002);
this.c2 = random(colors);
this.c3 = random(colors);
}
display(dt, w) {
this.t += (10 * sin(this.dt + (abs(w / 100) + abs(dt / 50000)))) / 10;
this.theta = TWO_PI * sin(this.t);
this.x = this.x1;
this.y = this.L * cos(this.theta);
let tmp2 = color(this.c2);
tmp2.setAlpha(50);
fill(tmp2);
if (this.i % 2 === 0) {
push();
let tmp = color(this.c3);
tmp.setAlpha(5);
rotate(t * this.dt * 1000000);
fill(tmp);
circle(
this.x1 + this.L * this.t * cos((t / 10) * this.dt),
this.y + this.L * sin(this.L / 100 + this.t + t),
(this.y * sin(this.t + t / 2)) / 10 +
(this.L * this.t * cos((t / 10) * this.dt)) / 20
);
pop();
}
circle(
this.x1,
this.y * sin(this.t + t / 20),
3 + 10 * abs(sin(w + dt / 100))
);
let f = width / 2;
noStroke();
}
}
function mousePressed() {
areYaClawhammerin = !areYaClawhammerin;
}
function touchStarted() {
areYaClawhammerin = !areYaClawhammerin;
return false;
}
function keyPressed() {
fretless.stop();
setup();
draw();
}