summaryrefslogtreecommitdiffstats
path: root/res
diff options
context:
space:
mode:
authorBe <be@mixxx.org>2020-04-21 09:58:52 -0500
committerBe <be@mixxx.org>2020-04-21 09:58:52 -0500
commit1c333dd64e635852f58c244e9c704fe334a919cf (patch)
treece2f2636f7447d352b84eeb2f3457d1259136880 /res
parent7dcfef51536c031cf7ad2f24065057d54843205e (diff)
parentcf755a24393bbd3e10d251f559bdb7fa5c39ac32 (diff)
Merge remote-tracking branch 'upstream/2.2'
Diffstat (limited to 'res')
-rw-r--r--res/controllers/common-controller-scripts.js47
1 files changed, 47 insertions, 0 deletions
diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js
index a7421d613f..1c00f561d1 100644
--- a/res/controllers/common-controller-scripts.js
+++ b/res/controllers/common-controller-scripts.js
@@ -455,6 +455,7 @@ var bpm = function() {
};
bpm.tapTime = 0.0;
+bpm.previousTapDelta = 0.0;
bpm.tap = []; // Tap sample values
/* -------- ------------------------------------------------------
@@ -467,6 +468,7 @@ bpm.tap = []; // Tap sample values
Output: -
-------- ------------------------------------------------------ */
bpm.tapButton = function(deck) {
+<<<<<<< HEAD
var now = new Date() / 1000; // Current time in seconds
var tapDelta = now - bpm.tapTime;
bpm.tapTime = now;
@@ -478,10 +480,39 @@ bpm.tapButton = function(deck) {
if (bpm.tap.length > 8) bpm.tap.shift(); // Keep the last 8 samples for averaging
var sum = 0;
for (var i = 0; i < bpm.tap.length; i++) {
+=======
+ var now = new Date() / 1000; // Current time in seconds
+ var tapDelta = now - bpm.tapTime;
+ bpm.tapTime = now;
+
+ // assign tapDelta in cases where the button has not been pressed previously
+ if (bpm.tap.length < 1) {
+ bpm.previousTapDelta = tapDelta;
+ }
+ // reset if longer than two seconds between taps
+ if (tapDelta > 2.0) {
+ bpm.tap = [];
+ return;
+ }
+ // reject occurences of accidental double or missed taps
+ // a tap is considered missed when the delta of this press is 80% longer than the previous one
+ // and a tap is considered double when the delta is shorter than 40% of the previous one.
+ // these numbers are just guesses that produced good results in practice
+ if ((tapDelta > bpm.previousTapDelta * 1.8)||(tapDelta < bpm.previousTapDelta * 0.6)) {
+ return;
+ }
+ bpm.previousTapDelta = tapDelta;
+ bpm.tap.push(60 / tapDelta);
+ // Keep the last 8 samples for averaging
+ if (bpm.tap.length > 8) bpm.tap.shift();
+ var sum = 0;
+ for (i=0; i<bpm.tap.length; i++) {
+>>>>>>> upstream/2.2
sum += bpm.tap[i];
}
var average = sum / bpm.tap.length;
+<<<<<<< HEAD
var fRateScale = average / engine.getValue("[Channel" + deck + "]", "bpm");
// Adjust the rate:
@@ -491,6 +522,22 @@ bpm.tapButton = function(deck) {
"[Channel" + deck + "]", "rate",
fRateScale * engine.getValue("[Channel" + deck + "]", "rate_dir"));
// print("Script: BPM="+average+" setting to "+fRateScale);
+=======
+ var group = "[Channel" + deck + "]";
+
+ // "bpm" was changed in 1.10 to reflect the *adjusted* bpm, but I presume it
+ // was supposed to return the tracks bpm (which it did before the change).
+ // "file_bpm" is supposed to return the set BPM of the loaded track of the
+ // channel.
+ var fRateScale = average/engine.getValue(group, "file_bpm");
+
+ // Adjust the rate:
+ fRateScale = (fRateScale - 1.) / engine.getValue(group, "rateRange")
+
+ engine.setValue(
+ group, "rate",
+ fRateScale * engine.getValue(group, "rate_dir"));
+>>>>>>> upstream/2.2
};
// ----------------- Common regular expressions --------------------------