Attempt to impose limits
This commit is contained in:
parent
54fa7fc00b
commit
b4ca1320b8
@ -10,6 +10,9 @@ var _canvas;
|
|||||||
// Offline recording duration
|
// Offline recording duration
|
||||||
var offlineRecordingDuration = 3000;
|
var offlineRecordingDuration = 3000;
|
||||||
|
|
||||||
|
// Offline limits for hardware consierations
|
||||||
|
var offlineLimits = 6;
|
||||||
|
|
||||||
// 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";
|
||||||
var archiveListingUrl = window.location + "archive";
|
var archiveListingUrl = window.location + "archive";
|
||||||
@ -80,6 +83,22 @@ function stop() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function gardenOfflineLimits() {
|
||||||
|
/**
|
||||||
|
* Ensure shapes stay within limits
|
||||||
|
**/
|
||||||
|
if (shapes.length < offlineLimits) return;
|
||||||
|
|
||||||
|
for (let i = 0; i < shapes.length; i++) {
|
||||||
|
let shape = shapes[i];
|
||||||
|
shape.hide();
|
||||||
|
}
|
||||||
|
|
||||||
|
while (shapes.length > 0) {
|
||||||
|
shapes.pop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function sendToArchive() {
|
function sendToArchive() {
|
||||||
/**
|
/**
|
||||||
* Send the sound to the back-end for archiving.
|
* Send the sound to the back-end for archiving.
|
||||||
@ -286,6 +305,9 @@ class GeneratedShape {
|
|||||||
this.nextTick = random(1000, 9000);
|
this.nextTick = random(1000, 9000);
|
||||||
this.tickTimer = 0;
|
this.tickTimer = 0;
|
||||||
|
|
||||||
|
// Should remain hidden
|
||||||
|
this.hidden = false;
|
||||||
|
|
||||||
this.initialise();
|
this.initialise();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -355,10 +377,26 @@ class GeneratedShape {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
hide() {
|
||||||
|
/**
|
||||||
|
* Hide the shape
|
||||||
|
**/
|
||||||
|
if (!this.hidden) {
|
||||||
|
this.hidden = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
while (this.colour._getAlpha() > 0) {
|
||||||
|
let currentAlpha = this.colour._getAlpha();
|
||||||
|
this.colour.setAlpha(currentAlpha - random(0, 3));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
docolour() {
|
docolour() {
|
||||||
/**
|
/**
|
||||||
* Draw colour and fade-in shape.
|
* Draw colour and fade-in shape.
|
||||||
**/
|
**/
|
||||||
|
if (this.hidden === true) return;
|
||||||
|
|
||||||
if (this.opacity != 256) {
|
if (this.opacity != 256) {
|
||||||
if (this.opacity < 256) {
|
if (this.opacity < 256) {
|
||||||
// shape should fade in, so increment alpha value
|
// shape should fade in, so increment alpha value
|
||||||
@ -552,6 +590,7 @@ 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();
|
||||||
|
Loading…
Reference in New Issue
Block a user