Generate shape when the sound is ready

This commit is contained in:
Luke Murphy 2020-02-15 15:28:35 +01:00
parent 4fcb9fd0be
commit 5e092df9d6
No known key found for this signature in database
GPG Key ID: 5E2EF5A63E3718CC

View File

@ -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++) {