From 5e092df9d61a596d594a722233bbc96ce8f4e042 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 15 Feb 2020 15:28:35 +0100 Subject: [PATCH] Generate shape when the sound is ready --- voicegardens/static/voicegardens.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/voicegardens/static/voicegardens.js b/voicegardens/static/voicegardens.js index 3c4b966..f939c1d 100644 --- a/voicegardens/static/voicegardens.js +++ b/voicegardens/static/voicegardens.js @@ -554,10 +554,12 @@ function draw() { if (newSoundJustRecorded === true) { // build a new copy of the recording to store on the shape object let soundBlob = recording.getBlob(); - let recordedSound = new p5.SoundFile(new p5.File(soundBlob)); - let newShape = new GeneratedShape(recordedSound, amplitude, duration); - shapes.push(newShape); - newSoundJustRecorded = false; + let data = new p5.File(soundBlob); + let recordedSound = new p5.SoundFile(data, function() { + let newShape = new GeneratedShape(recordedSound, amplitude, duration); + shapes.push(newShape); + newSoundJustRecorded = false; + }); } for (let i = 0; i < shapes.length; i++) {