“Sound Clock” by ookey
https://openprocessing.org/sketch/506676
License CreativeCommons Attribution ShareAlike
https://creativecommons.org/licenses/by-sa/3.0
{{filePath}}
{{width}} x {{height}}
Report Sketch
Oh, that naughty sketch! Please let us know what the issue is below.
Apply Template
Applying this template will reset your sketch and remove all your changes. Are you sure you would like to continue?
Report Sketch
Report Comment
Please confirm that you would like to report the comment below.
We will review your submission and take any actions necessary per our Community Guidelines. In addition to reporting this comment, you can also block the user to prevent any future interactions.
Please report comments only when necessary. Unnecessary or abusive use of this tool may result in your own account being suspended.
Are you sure you want to delete your sketch?
Any files uploaded will be deleted as well.
Delete Comment?
This will also delete all the replies to this comment.
Delete this tab? Any code in it will be deleted as well.
Select a collection to submit your sketch
We Need Your Support
Since 2008, OpenProcessing has provided tools for creative coders to learn, create, and share over a million open source projects in a friendly environment.
Niche websites like ours need your continued support for future development and maintenance, while keeping it an ad-free platform that respects your data and privacy!
Please consider subscribing below to show your support with a "Plus" badge on your profile and get access to many other features!
click to turn sound on and off
CC Attribution ShareAlike
Sound Clock
xxxxxxxxxx
//Help taken from Professor Golan Levin's Clock
//https://www.openprocessing.org/sketch/503875
//and p5.js FFT library example
//https://p5js.org/reference/#/p5.FFT/analyze
var filterH;
var fft;
var prevSec;
var millisRolloverTime;
var ratio;
var noiseamp = 0.0;
var oscamp = 0.0;
function setup(){
createCanvas(400,400);
millisRolloverTime = 0;
noise = new p5.Noise();
noise.amp(noiseamp);
filterH = new p5.BandPass();
filterH.res(50);
noise.disconnect();
noise.connect(filterH);
noise.start();
oscM = new p5.Oscillator();
oscM.amp(oscamp);
oscM.setType('square');
oscM.disconnect();
oscM.connect(filterH);
oscM.start();
fft = new p5.FFT();
}
function draw(){
background(249,241,241);
var S = second();
if (prevSec != S) {
millisRolloverTime = millis();
}
prevSec = S;
var Smils = S + (floor(millis() - millisRolloverTime)/1000);
var M = minute() + (Smils / 60);
var H = hour() + (M / 60);
var freqH = map(H, 0.0, 23.0, 20.0, 2320.0) / 2.0;
filterH.freq(freqH);
filterH.res((sin(map(Smils, 0, 60, 0, PI)) * 60) + 10);
ratio = (60 - M + 20) / (60 - M + 10);
freqM = freqH * ratio;
oscM.freq(freqM);
var spectrum = fft.analyze();
noStroke();
fill(123,184,197);
for (var i = 0; i< spectrum.length; i++){
var x = map(i, 0, spectrum.length, 0, width);
var h = -height + map(spectrum[i], 0, 255, height, 0);
rect(x, height, width / spectrum.length, h )
}
stroke(255);
}
function mouseClicked()
{
if (noiseamp > 0.0)
{
noiseamp = 0.0;
oscamp = 0.0;
}
else
{
oscamp = 0.8;
noiseamp = 1.0;
}
noise.amp(noiseamp);
oscM.amp(oscamp);
}
Examples: Play - Synthesis - Microphone
See More Shortcuts