Make art with your voice! Sing to plot the frequency with the highest volume. Try clapping your hands, or drumming on your desk to see other effects. It is a work in progress :)
“Perfect Pitch” by Ayla van der Wal
https://openprocessing.org/sketch/1024156
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!
Turn on the microphone
CC Attribution ShareAlike
Perfect Pitch
van der Wal
xxxxxxxxxx
p5.disableFriendlyErrors = true;
let voice;
let x, y, y2, offset, r = 0;
let amp = window.innerHeight;
let ex = 0, ey = 0;
let maxAt = 0;
let x3;
let f = 10;
let fft;
let bands = 256;
let h;
function setup() {
createCanvas(window.innerWidth, window.innerHeight);
frameRate(60);
colorMode(HSB, 100);
voice = new p5.AudioIn();
voice.start();
// Create an Input stream which is routed into the Amplitude analyzer
fft = new p5.FFT(0.75, bands);
// patch the AudioIn
x3 = width/bands;
background(0,0,0);
}
function draw() {
noStroke();
fill(0,0,100,5);
rect(0,0, width, height);
y2 = y;
stroke(0);
voice.connect(fft)
let spectrum = fft.analyze();
// for(let i = 0; i < bands; i++){
// print(spectrum[i] + " ");
// // The result of the FFT is normalized
// // draw the line for frequency band i scaling it up by 5 to get more amplitude.
// line(x1*i, height, x1*i, height-h*10);
// strokeWeight(3);
//}
for (let i = 0; i < spectrum.length; i++) {
maxAt = spectrum[i] > spectrum[maxAt] ? i : maxAt;
}
h = pow(map(max(spectrum), 0, 255, 0, window.innerHeight/64),2.2);
let newmaxAt = (map(maxAt, 0, spectrum.length, 0, 60*window.innerWidth));
updateWave(newmaxAt, h);
maxAt = 0;
}
function updateWave(j, h) {
for (let x2 = 1; x2 < window.innerWidth; x2+=1) {
let x1 = x2-1;
let y1 = sin(radians(-x1*abs(j/window.innerWidth)+r))*h;
let y2 = sin(radians(-x2*abs(j/window.innerWidth)+r))*h;
stroke(frameCount % 100, 100, 100);
noFill();
strokeWeight(4);
line(x1, window.innerHeight/2-y1, x2, window.innerHeight/2-y2);
}
r = millis()/8;
}
Examples: Play - Synthesis - Microphone
See More Shortcuts