summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff Becker <jeff@i2p.rocks>2019-06-20 11:49:10 -0400
committerJeff Becker <jeff@i2p.rocks>2019-06-20 11:49:10 -0400
commit27cb8a6ceb4a64206f61b49ed9659c81f62c686e (patch)
tree445df74fefddae44fe0f19fa34fc02810aaa9424
parent83636844bb87c37037d2d72e5aa68aeb77c5ac00 (diff)
update js
-rw-r--r--docroot/main.js21
1 files changed, 14 insertions, 7 deletions
diff --git a/docroot/main.js b/docroot/main.js
index 1559e4f..7c8e804 100644
--- a/docroot/main.js
+++ b/docroot/main.js
@@ -144,12 +144,19 @@ function reloadFile(e) {
var source;
-function onBuffer (buffer) {
+function onBuffer (buffer, vid) {
if(source) source.stop();
- source = audioContext.createBufferSource();
- console.info('Got the buffer', buffer);
+ if(vid)
+ {
+ source = audioContext.createMediaElementSource(vid);
+ }
+ else
+ {
+ source = audioContext.createBufferSource();
+ console.info('Got the buffer', buffer);
+ source.buffer = buffer;
+ }
document.getElementById("beat").innerText = "(._.)";
- source.buffer = buffer;
//create the analyser node
analyser = audioContext.createAnalyser();
@@ -276,14 +283,14 @@ function onBuffer (buffer) {
state.lowpass.push(now);
if(state.lowpass.length > 128)
state.lowpass.shift();
- var top = Math.ceil( state.interval / 4, 25.0);
+ var top = Math.ceil( state.interval / 4, 10.0);
if( Math.abs(state.lowpass[state.lowpass.length -1] - state.lowpass[state.lowpass.length - 2]) > top)
{
state.beats.push(now);
if(state.beats.length > 32)
state.beats.shift();
recalcBPM(state);
- if(now - state.lastBeat > state.interval / 1.15)
+ if(now - state.lastBeat > (state.interval / 0.95))
{
dance_tick(state.counter++);
state.lastBeat = now;
@@ -299,7 +306,7 @@ function onBuffer (buffer) {
recalcBPM(state);
}
// tick dancer if we think we should
- if(state.interval > 50)
+ if(state.interval > 20)
{
if(now - state.lastDance > state.interval)
{