Skip to content

Commit

Permalink
small icue & audio changes
Browse files Browse the repository at this point in the history
  • Loading branch information
hexxone committed Nov 10, 2020
1 parent c3ec538 commit 1db2e9c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
7 changes: 3 additions & 4 deletions weicue.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ var weicue = {
icueDevices: [],
preview: null,
icueInterval: null,
mainCanvas: null,
helperCanvas: null,
helperContext: null,
// settings
Expand Down Expand Up @@ -450,10 +449,10 @@ AAAASUVORK5CYII=
},

// prepare canvas
updateCanvas: function () {
updateCanvas: function (mainCanvas) {
var self = weicue;
var sett = self.settings;
if (!self.isAvailable || !self.mainCanvas || sett.icue_mode == 0 || self.icueDevices.length < 1) return;
if (!self.isAvailable || !mainCanvas || sett.icue_mode == 0 || self.icueDevices.length < 1) return;

if (sett.icue_mode == 1) {
// get helper vars
Expand All @@ -468,7 +467,7 @@ AAAASUVORK5CYII=
hctx.fillStyle = "rgba(" + spl.join(", ") + ", " + sett.icue_area_decay / 100 + ")";
hctx.fillRect(0, 0, cueWid, cueHei);
// scale down and copy the image to the helper canvas
hctx.drawImage(self.mainCanvas, area.left, area.top, area.width, area.height, 0, 0, cueWid, cueHei);
hctx.drawImage(mainCanvas, area.left, area.top, area.width, area.height, 0, 0, cueWid, cueHei);
// blur the helper projection canvas
if (sett.icue_area_blur > 0) self.gBlurCanvas(self.helperCanvas, hctx, sett.icue_area_blur);
}
Expand Down
14 changes: 6 additions & 8 deletions worker/weasWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ var smoothArray = function (array, smoothing) {
var applyValueLeveling = function (curr, prev, sett) {
for (var i = 0; i < curr.length; i++) {
var diff = curr[i] - prev[i];
var mlt = diff > 0 ? sett.audio_increase : sett.audio_decrease;
var mlt = 100 - (diff > 0 ? sett.audio_increase : sett.audio_decrease);
curr[i] -= diff * mlt / 100;
}
};
Expand Down Expand Up @@ -167,20 +167,18 @@ onmessage = function (e) {
}
// calc average with previous entry
var average = sum / data.length;
// I cant really explain.... magic?
var intensity = (bass * 6 - mids + peaks) / 6 / average;
// done
self.postMessage({
silent: (max < settings.minimum_volume / 1000),
min: min,
max: max,
range: max - min,
bass: bass,
mids: mids,
peaks: peaks,
sum: sum,
min: min,
max: max,
average: average,
intensity: intensity,
range: max - min,
silent: (max < settings.minimum_volume / 1000),
intensity: (bass * 8 - mids + peaks) / 6 / average,
time: performance.now() / 1000,
data: data.buffer,
}, [data.buffer]);
Expand Down

0 comments on commit 1db2e9c

Please sign in to comment.