|
|
@ -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; |
|
|
|
} |
|
|
|
|
|
|
|