|
@ -27,7 +27,6 @@ var recording; |
|
|
var newSoundJustRecorded = false; |
|
|
var newSoundJustRecorded = false; |
|
|
|
|
|
|
|
|
// All user clickable buttons
|
|
|
// All user clickable buttons
|
|
|
var archiveButton; |
|
|
|
|
|
var playButton; |
|
|
var playButton; |
|
|
var recordButton; |
|
|
var recordButton; |
|
|
var stopButton; |
|
|
var stopButton; |
|
@ -85,6 +84,9 @@ function stop() { |
|
|
|
|
|
|
|
|
// https://p5js.org/reference/#/p5.SoundFile/duration
|
|
|
// https://p5js.org/reference/#/p5.SoundFile/duration
|
|
|
duration = recording.duration(); |
|
|
duration = recording.duration(); |
|
|
|
|
|
|
|
|
|
|
|
sendToArchive(); |
|
|
|
|
|
addToFooterArchive(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -97,9 +99,9 @@ function play() { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function archive() { |
|
|
function sendToArchive() { |
|
|
/** |
|
|
/** |
|
|
* Send the sound to the back-end for archving. |
|
|
* Send the sound to the back-end for archiving. |
|
|
**/ |
|
|
**/ |
|
|
var soundBlob = recording.getBlob(); |
|
|
var soundBlob = recording.getBlob(); |
|
|
|
|
|
|
|
@ -119,6 +121,12 @@ function archive() { |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function addToFooterArchive() { |
|
|
|
|
|
/** |
|
|
|
|
|
* Add shape to the archive. |
|
|
|
|
|
**/ |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function setupRecording() { |
|
|
function setupRecording() { |
|
|
/** |
|
|
/** |
|
|
* Setup logic for sound recording. |
|
|
* Setup logic for sound recording. |
|
@ -142,10 +150,6 @@ function setupRecording() { |
|
|
playButton = createButton("play"); |
|
|
playButton = createButton("play"); |
|
|
playButton.position(10, 75); |
|
|
playButton.position(10, 75); |
|
|
playButton.mousePressed(play); |
|
|
playButton.mousePressed(play); |
|
|
|
|
|
|
|
|
archiveButton = createButton("archive"); |
|
|
|
|
|
archiveButton.position(10, 110); |
|
|
|
|
|
archiveButton.mousePressed(archive); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
class GeneratedShape { |
|
|
class GeneratedShape { |
|
@ -383,14 +387,18 @@ function draw() { |
|
|
translate(screenX, screenY); |
|
|
translate(screenX, screenY); |
|
|
|
|
|
|
|
|
if (newSoundJustRecorded === true) { |
|
|
if (newSoundJustRecorded === true) { |
|
|
shapes.push(new GeneratedShape()); |
|
|
newShape = new GeneratedShape(); |
|
|
|
|
|
shapes.push(newShape); |
|
|
|
|
|
addToArchive(newShape); |
|
|
newSoundJustRecorded = false; |
|
|
newSoundJustRecorded = false; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
for (let i = 0; i < shapes.length; i++) { |
|
|
for (let i = 0; i < shapes.length; i++) { |
|
|
let shape = shapes[i]; |
|
|
let shape = shapes[i]; |
|
|
|
|
|
|
|
|
shape.draw(); |
|
|
shape.draw(); |
|
|
shape.move(); |
|
|
shape.move(); |
|
|
|
|
|
|
|
|
if (shape.collide(shapes) === true) { |
|
|
if (shape.collide(shapes) === true) { |
|
|
shape.sound(); |
|
|
shape.sound(); |
|
|
} |
|
|
} |
|
|