Fix sound capture

This commit is contained in:
Luke Murphy 2020-02-15 15:35:48 +01:00
parent d49d94895e
commit 5358fc2797
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -544,13 +544,14 @@ function draw() {
// build a new copy of the recording to store on the shape object
let soundBlob = recording.getBlob();
let data = new p5.File(soundBlob);
let recordedSound = new p5.SoundFile(data, function() {
amplitude = recording.getPeaks(1)[0] * 100;
duration = recording.duration();
let newShape = new GeneratedShape(recordedSound, amplitude, duration);
shapes.push(newShape);
newSoundJustRecorded = false;
let sound = new p5.SoundFile(data, function() {
let amp = sound.getPeaks(1)[0] * 100;
let dur = sound.duration();
let shape = new GeneratedShape(sound, amp, dur);
shape.sound();
shapes.push(shape);
sendToArchive();
newSoundJustRecorded = false;
});
}