From 5ae19defd2bf965f423fd7df8ca153d7afc3d1a9 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Mon, 23 Mar 2020 19:54:51 +0100 Subject: [PATCH 01/11] first fix idea. Yet to test! --- res/controllers/common-controller-scripts.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index c1d2d09f58f..a7660afce93 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -268,13 +268,13 @@ script.absoluteNonLinInverse = function(value, low, mid, high, min, max) { if (!max) { max = 127 } - var center = (max - min) / 2 - var result + var center = (max-min)/2; + var result; - if (value == mid) { - return center - } else if (value < mid) { - result = (center / (mid - low)) * (value - low) + if (value==mid) { + return center; + } else if (value Date: Mon, 23 Mar 2020 19:55:55 +0100 Subject: [PATCH 02/11] added filter for accidental bpm.tapButton presses/misses --- res/controllers/common-controller-scripts.js | 39 +++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index a7660afce93..6f99c7b8778 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -405,8 +405,9 @@ script.softStart = function(channel, control, value, status, group, factor) { bpm = function() { } -bpm.tapTime = 0.0 -bpm.tap = [] // Tap sample values +bpm.tapTime = 0.0; +bpm.previousTapDelta = 0.0; +bpm.tap = []; // Tap sample values /* -------- ------------------------------------------------------ bpm.tapButton @@ -418,18 +419,28 @@ bpm.tap = [] // Tap sample values Output: - -------- ------------------------------------------------------ */ bpm.tapButton = function(deck) { - var now = new Date() / 1000 // Current time in seconds - var tapDelta = now - bpm.tapTime - bpm.tapTime = now - if (tapDelta > 2.0) { // reset if longer than two seconds between taps - bpm.tap = [] - return - } - bpm.tap.push(60 / tapDelta) - if (bpm.tap.length > 8) bpm.tap.shift() // Keep the last 8 samples for averaging - var sum = 0 - for (i = 0; i < bpm.tap.length; i++) { - sum += bpm.tap[i] + var now = new Date()/1000; // Current time in seconds + var tapDelta = now - bpm.tapTime; + bpm.tapTime=now; + if (bpm.tap.lenght<1.0) { + bpm.previousTapDelta=tapDelta; + } + // assign tapDelta in cases where the button has not been pressed previously + if (tapDelta>2.0) { // reset if longer than two seconds between taps + bpm.tap=[]; + return; + } + if ((tapDelta > bpm.previousTapDelta*1.8)||(tapDelta8) bpm.tap.shift(); // Keep the last 8 samples for averaging + var sum = 0; + for (i=0; i Date: Mon, 23 Mar 2020 19:58:07 +0100 Subject: [PATCH 03/11] addressed issues from last review --- res/controllers/common-controller-scripts.js | 30 +++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index 6f99c7b8778..080da05a735 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -421,35 +421,37 @@ bpm.tap = []; // Tap sample values bpm.tapButton = function(deck) { var now = new Date()/1000; // Current time in seconds var tapDelta = now - bpm.tapTime; - bpm.tapTime=now; - if (bpm.tap.lenght<1.0) { - bpm.previousTapDelta=tapDelta; + bpm.tapTime = now; + if (bpm.tap.length < 1) { + bpm.previousTapDelta = tapDelta; } // assign tapDelta in cases where the button has not been pressed previously - if (tapDelta>2.0) { // reset if longer than two seconds between taps - bpm.tap=[]; + if (tapDelta > 2.0) { // reset if longer than two seconds between taps + bpm.tap = []; return; } - if ((tapDelta > bpm.previousTapDelta*1.8)||(tapDelta bpm.previousTapDelta*1.8)||(tapDelta < bpm.previousTapDelta*0.4)) { + return; } - bpm.previousTapDelta=tapDelta; - // the if-case is meant to be a filter to reject accidental double presses - // or when the button was missed for some reason. - bpm.tap.push(60/tapDelta); - if (bpm.tap.length>8) bpm.tap.shift(); // Keep the last 8 samples for averaging + bpm.previousTapDelta = tapDelta; + bpm.tap.push(60 / tapDelta); + if (bpm.tap.length > 8) bpm.tap.shift(); // Keep the last 8 samples for averaging var sum = 0; for (i=0; i Date: Mon, 23 Mar 2020 20:00:35 +0100 Subject: [PATCH 04/11] moved comments to proper position --- res/controllers/common-controller-scripts.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index 080da05a735..9f6691c799c 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -419,14 +419,16 @@ bpm.tap = []; // Tap sample values Output: - -------- ------------------------------------------------------ */ bpm.tapButton = function(deck) { - var now = new Date()/1000; // Current time in seconds + 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; } - // assign tapDelta in cases where the button has not been pressed previously - if (tapDelta > 2.0) { // reset if longer than two seconds between taps + // reset if longer than two seconds between taps + if (tapDelta > 2.0) { bpm.tap = []; return; } @@ -439,25 +441,27 @@ bpm.tapButton = function(deck) { } bpm.previousTapDelta = tapDelta; bpm.tap.push(60 / tapDelta); - if (bpm.tap.length > 8) bpm.tap.shift(); // Keep the last 8 samples for averaging + // Keep the last 8 samples for averaging + if (bpm.tap.length > 8) bpm.tap.shift(); var sum = 0; for (i=0; i Date: Wed, 25 Mar 2020 12:06:52 +0100 Subject: [PATCH 05/11] fixed form of unrelated paragraph --- res/controllers/common-controller-scripts.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index 9f6691c799c..c7ea1178e58 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -268,13 +268,13 @@ script.absoluteNonLinInverse = function(value, low, mid, high, min, max) { if (!max) { max = 127 } - var center = (max-min)/2; + var center = (max - min) / 2; var result; - if (value==mid) { + if (value === mid) { return center; - } else if (value Date: Wed, 25 Mar 2020 12:10:49 +0100 Subject: [PATCH 06/11] building group string now only once per call --- res/controllers/common-controller-scripts.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index c7ea1178e58..70bf350dd5c 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -449,18 +449,20 @@ bpm.tapButton = function(deck) { } var average = sum / bpm.tap.length + 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("[Channel" + deck + "]", "file_bpm"); + var fRateScale = average/engine.getValue(group, "file_bpm"); // Adjust the rate: - fRateScale = (fRateScale - 1.) / engine.getValue("[Channel" + deck + "]", "rateRange") + fRateScale = (fRateScale - 1.) / engine.getValue(group, "rateRange") engine.setValue( - "[Channel" + deck + "]", "rate", - fRateScale * engine.getValue("[Channel" + deck + "]", "rate_dir")); + group, "rate", + fRateScale * engine.getValue(group, "rate_dir")); }; // ----------------- Common regular expressions -------------------------- From 906b9955586aaf0c486a08af526ae5643ba75645 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Fri, 3 Apr 2020 15:39:03 +0200 Subject: [PATCH 07/11] common-controller-scripts: change tap threshold res/controllers/common-controller-scripts: increased treshold for detecting duplicate taps as the previous threshold was too low and sometimes failed to identify taps as duplicates --- res/controllers/common-controller-scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index 70bf350dd5c..3cc31b105f0 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -436,7 +436,7 @@ bpm.tapButton = function(deck) { // 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.4)) { + if ((tapDelta > bpm.previousTapDelta*1.8)||(tapDelta < bpm.previousTapDelta*0.6)) { return; } bpm.previousTapDelta = tapDelta; From 59353f4b4162c194cb11c5034242cf5dc175b178 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Fri, 3 Apr 2020 15:54:33 +0200 Subject: [PATCH 08/11] add changelog entry for script.tabButton fix --- CHANGELOG | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG b/CHANGELOG index 761be54aa50..a45ade8d5e7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,6 +11,7 @@ * AutoDJ: Skip next track when both deck are playing lp:1399974 #2531 * Tweak scratch parameters for Mixtrack Platinum #2028 * Fix auto tempo going to infinity on Pioneer DDJ-SB2 #2559 +* Fix script.tabButton logic and reject missed & double taps #2594 * Add controller mapping for Native Instruments Traktor Kontrol S2 MK3 #2348 * Add controller mapping for Soundless joyMIDI #2425 * Add controller mapping for Hercules DJControl Inpulse 300 #2465 From c195f4663e5835dc1841f4295f26c6d39dc00101 Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Fri, 3 Apr 2020 22:55:37 +0200 Subject: [PATCH 09/11] CHANGELOG: fixed tabButton -> tapButton typo --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index a45ade8d5e7..c92553926f8 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,7 +11,7 @@ * AutoDJ: Skip next track when both deck are playing lp:1399974 #2531 * Tweak scratch parameters for Mixtrack Platinum #2028 * Fix auto tempo going to infinity on Pioneer DDJ-SB2 #2559 -* Fix script.tabButton logic and reject missed & double taps #2594 +* Fix script.tapButton logic and reject missed & double taps #2594 * Add controller mapping for Native Instruments Traktor Kontrol S2 MK3 #2348 * Add controller mapping for Soundless joyMIDI #2425 * Add controller mapping for Hercules DJControl Inpulse 300 #2465 From 5d73481a3560c7403bc0b90adfef5aa471ef750f Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Fri, 3 Apr 2020 22:57:28 +0200 Subject: [PATCH 10/11] common-controller-scripts: incorporate last review Added spaces around operators in bpm.tapButton double/missed taps logic --- res/controllers/common-controller-scripts.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/res/controllers/common-controller-scripts.js b/res/controllers/common-controller-scripts.js index 3cc31b105f0..7355649ee1d 100644 --- a/res/controllers/common-controller-scripts.js +++ b/res/controllers/common-controller-scripts.js @@ -436,7 +436,7 @@ bpm.tapButton = function(deck) { // 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)) { + if ((tapDelta > bpm.previousTapDelta * 1.8)||(tapDelta < bpm.previousTapDelta * 0.6)) { return; } bpm.previousTapDelta = tapDelta; From 246b9c2f4d04d6f0d0c89da250cf4590b41eb27c Mon Sep 17 00:00:00 2001 From: Swiftb0y <12380386+Swiftb0y@users.noreply.github.com> Date: Fri, 3 Apr 2020 23:07:52 +0200 Subject: [PATCH 11/11] CHANGELOG: fix script.tapButton -> bpm.tapButton --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index c92553926f8..76f85a4b9d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -11,7 +11,7 @@ * AutoDJ: Skip next track when both deck are playing lp:1399974 #2531 * Tweak scratch parameters for Mixtrack Platinum #2028 * Fix auto tempo going to infinity on Pioneer DDJ-SB2 #2559 -* Fix script.tapButton logic and reject missed & double taps #2594 +* Fix bpm.tapButton logic and reject missed & double taps #2594 * Add controller mapping for Native Instruments Traktor Kontrol S2 MK3 #2348 * Add controller mapping for Soundless joyMIDI #2425 * Add controller mapping for Hercules DJControl Inpulse 300 #2465