|
@ -50,11 +50,19 @@ var toScreenY = 0; |
|
|
// All shapes generated
|
|
|
// All shapes generated
|
|
|
var shapes = []; |
|
|
var shapes = []; |
|
|
|
|
|
|
|
|
|
|
|
// Sound properties
|
|
|
|
|
|
var amplitude; |
|
|
|
|
|
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); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -68,6 +76,11 @@ 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; |
|
|
|
|
|
|
|
|
|
|
|
// store sound properties from recording
|
|
|
|
|
|
pitch = fft.analyze(); |
|
|
|
|
|
amplitude = recording.getPeaks(); |
|
|
|
|
|
duration = recording.duration(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -131,27 +144,6 @@ function setupRecording() { |
|
|
archiveButton.mousePressed(archive); |
|
|
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 { |
|
|
class GeneratedShape { |
|
|
constructor() { |
|
|
constructor() { |
|
|
/** |
|
|
/** |
|
|