From 6a2a1e778954211a143468c452fc47c9a31d2259 Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sun, 9 Feb 2020 17:28:12 +0100 Subject: [PATCH] Maybe working multiple shape noises --- voicegardens/static/voicegardens.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/voicegardens/static/voicegardens.js b/voicegardens/static/voicegardens.js index ad4db6a..d24d077 100644 --- a/voicegardens/static/voicegardens.js +++ b/voicegardens/static/voicegardens.js @@ -138,7 +138,7 @@ function setupRecording() { } class GeneratedShape { - constructor() { + constructor(soundRecorded) { /** * Initialise the new shape. **/ @@ -223,7 +223,7 @@ class GeneratedShape { this.destY = random(windowHeight); // the sound recording attached to this shape - this.recording; + this.soundRecorded = soundRecorded; // the shape that was last collided with this.lastCollidedShape; @@ -293,8 +293,8 @@ class GeneratedShape { /** * Play a sound after a collision is detected. **/ - if (this.recording.isLoaded()) { - this.recording.play(); + if (this.soundRecorded.isLoaded()) { + this.soundRecorded.play(); } } @@ -434,9 +434,12 @@ function draw() { // generate a new shape after a sound recording if (newSoundJustRecorded === true) { - let newShape = new GeneratedShape(); - newShape.recording = recording; + let soundBlob = recording.getBlob(); + let recordedSound = new p5.SoundFile(new p5.File(soundBlob)); + let newShape = new GeneratedShape(recordedSound); + shapes.push(newShape); + newSoundJustRecorded = false; }