Browse Source

Record pitch, amplitude and duration

main
Luke Murphy 4 years ago
parent
commit
8001d09b57
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 34
      voicegardens/static/voicegardens.js

34
voicegardens/static/voicegardens.js

@ -50,11 +50,19 @@ var toScreenY = 0;
// All shapes generated
var shapes = [];
// Sound properties
var amplitude;
var duration;
var fft;
var pitch;
function record() {
/**
* Start recording a sound.
**/
if (microphone.enabled) {
fft = new p5.FFT();
fft.setInput(recorder);
setTimeout(recorder.record(recording), recordingTimeout);
}
}
@ -68,6 +76,11 @@ function stop() {
// signal to the draw loop that we should generate a new shape
newSoundJustRecorded = true;
// store sound properties from recording
pitch = fft.analyze();
amplitude = recording.getPeaks();
duration = recording.duration();
}
}
@ -131,27 +144,6 @@ function setupRecording() {
archiveButton.mousePressed(archive);
}
function getSoundInfo() {
/**
* Retrieve sound information like pitch, amplitude, duration, etc.
**/
amplitude = recording.getPeaks();
duration = recording.duration();
// pitch (frequency?) I think we can use fft.analyze() and then find the
// highest value (0 -> 1024) that has a non-zero value this gives us the
// highest frequency from the recording
// https://p5js.org/reference/#/p5.FFT
// https://p5js.org/reference/#/p5.FFT/analyze
// nuance?
// "I meant the amount of variation in the voice - i.e is it one single
// monotone note or does it go up and down octaves or start soft and high and
// become deep and guttural etc."
//
// How do to do this? Unsure ...
}
class GeneratedShape {
constructor() {
/**

Loading…
Cancel
Save