Remove pitch for now

This commit is contained in:
Luke Murphy 2020-02-07 13:47:52 +01:00
parent e9c29c777a
commit b5bedbf8a1
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -52,16 +52,12 @@ var shapes = [];
// Sound properties // Sound properties
var amplitude; var amplitude;
var duration; var duration;
var fft;
var pitch;
function record() { function record() {
/** /**
* Start recording a sound. * Start recording a sound.
**/ **/
if (microphone.enabled) { if (microphone.enabled) {
fft = new p5.FFT();
fft.setInput(recorder);
setTimeout(recorder.record(recording), recordingTimeout); setTimeout(recorder.record(recording), recordingTimeout);
} }
} }
@ -76,9 +72,6 @@ function stop() {
// signal to the draw loop that we should generate a new shape // signal to the draw loop that we should generate a new shape
newSoundJustRecorded = true; newSoundJustRecorded = true;
// https://p5js.org/reference/#/p5.FFT/analyze
pitch = getMaxPitch(fft.analyze());
// https://p5js.org/reference/#/p5.SoundFile/getPeaks // https://p5js.org/reference/#/p5.SoundFile/getPeaks
amplitude = recording.getPeaks(1)[0] * 100; amplitude = recording.getPeaks(1)[0] * 100;
@ -419,14 +412,3 @@ function windowResized() {
**/ **/
resizeCanvas(windowWidth, windowHeight); resizeCanvas(windowWidth, windowHeight);
} }
function getMaxPitch(spectrum) {
/**
* Get max pitch.
*/
for (let x = spectrum.length - 1; x > 0; x--) {
if (spectrum[x] != 0) {
return x;
}
}
}