Browse Source

Set fifth click to reset screen

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

35
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,18 +585,23 @@ function draw() {
// generate a new shape after a sound recording // generate a new shape after a sound recording
if (newSoundJustRecorded === true) { if (newSoundJustRecorded === true) {
// build a new copy of the recording to store on the shape object let limits = gardenOfflineLimits();
let soundBlob = recording.getBlob(); console.log("limits are:");
let data = new p5.File(soundBlob); console.log(limits);
let sound = new p5.SoundFile(data, function () { if (limits === false) {
let amp = sound.getPeaks(1)[0] * 100; console.log("making another one!");
let dur = sound.duration(); // build a new copy of the recording to store on the shape object
let shape = new GeneratedShape(sound, amp, dur); let soundBlob = recording.getBlob();
gardenOfflineLimits(); let data = new p5.File(soundBlob);
shape.sound(); let sound = new p5.SoundFile(data, function () {
shapes.push(shape); let amp = sound.getPeaks(1)[0] * 100;
sendToArchive(); let dur = sound.duration();
}); let shape = new GeneratedShape(sound, amp, dur);
shape.sound();
shapes.push(shape);
sendToArchive();
});
}
newSoundJustRecorded = false; newSoundJustRecorded = false;
} }

Loading…
Cancel
Save