Browse Source

Maybe working multiple shape noises

main
Luke Murphy 4 years ago
parent
commit
6a2a1e7789
No known key found for this signature in database GPG Key ID: 5E2EF5A63E3718CC
  1. 15
      voicegardens/static/voicegardens.js

15
voicegardens/static/voicegardens.js

@ -138,7 +138,7 @@ function setupRecording() {
} }
class GeneratedShape { class GeneratedShape {
constructor() { constructor(soundRecorded) {
/** /**
* Initialise the new shape. * Initialise the new shape.
**/ **/
@ -223,7 +223,7 @@ class GeneratedShape {
this.destY = random(windowHeight); this.destY = random(windowHeight);
// the sound recording attached to this shape // the sound recording attached to this shape
this.recording; this.soundRecorded = soundRecorded;
// the shape that was last collided with // the shape that was last collided with
this.lastCollidedShape; this.lastCollidedShape;
@ -293,8 +293,8 @@ class GeneratedShape {
/** /**
* Play a sound after a collision is detected. * Play a sound after a collision is detected.
**/ **/
if (this.recording.isLoaded()) { if (this.soundRecorded.isLoaded()) {
this.recording.play(); this.soundRecorded.play();
} }
} }
@ -434,9 +434,12 @@ function draw() {
// generate a new shape after a sound recording // generate a new shape after a sound recording
if (newSoundJustRecorded === true) { if (newSoundJustRecorded === true) {
let newShape = new GeneratedShape(); let soundBlob = recording.getBlob();
newShape.recording = recording; let recordedSound = new p5.SoundFile(new p5.File(soundBlob));
let newShape = new GeneratedShape(recordedSound);
shapes.push(newShape); shapes.push(newShape);
newSoundJustRecorded = false; newSoundJustRecorded = false;
} }

Loading…
Cancel
Save