Browse Source

Set fifth click to reset screen

offline
decentral1se 4 years ago
parent
commit
1839f91438
No known key found for this signature in database GPG Key ID: 92DAD76BD9567B8A
  1. 13
      voicegardens/static/voicegardens.js

13
voicegardens/static/voicegardens.js

@ -11,7 +11,7 @@ var _canvas;
var offlineRecordingDuration = 3000; var offlineRecordingDuration = 3000;
// Offline limits for hardware considerations // Offline limits for hardware considerations
var offlineLimits = 4; var offlineLimits = 5;
// URL which exposes the archive saving API end-point // URL which exposes the archive saving API end-point
var archiveUrl = window.location + "add-to-archive"; var archiveUrl = window.location + "add-to-archive";
@ -87,7 +87,7 @@ function gardenOfflineLimits() {
/** /**
* Ensure shapes stay within limits * Ensure shapes stay within limits
**/ **/
if (shapes.length < offlineLimits) return; if (shapes.length < offlineLimits) return 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];
@ -97,6 +97,8 @@ function gardenOfflineLimits() {
while (shapes.length > 0) { while (shapes.length > 0) {
shapes.pop(); shapes.pop();
} }
return true;
} }
function sendToArchive() { function sendToArchive() {
@ -583,6 +585,11 @@ 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 limits = gardenOfflineLimits();
console.log("limits are:");
console.log(limits);
if (limits === false) {
console.log("making another one!");
// build a new copy of the recording to store on the shape object // build a new copy of the recording to store on the shape object
let soundBlob = recording.getBlob(); let soundBlob = recording.getBlob();
let data = new p5.File(soundBlob); let data = new p5.File(soundBlob);
@ -590,11 +597,11 @@ function draw() {
let amp = sound.getPeaks(1)[0] * 100; let amp = sound.getPeaks(1)[0] * 100;
let dur = sound.duration(); let dur = sound.duration();
let shape = new GeneratedShape(sound, amp, dur); let shape = new GeneratedShape(sound, amp, dur);
gardenOfflineLimits();
shape.sound(); shape.sound();
shapes.push(shape); shapes.push(shape);
sendToArchive(); sendToArchive();
}); });
}
newSoundJustRecorded = false; newSoundJustRecorded = false;
} }

Loading…
Cancel
Save