@@ -48,6 +48,9 @@ const DefaultPadLayoutKeyboard = "keyboard";
48
48
* Change settings in the preferences
49
49
*/
50
50
51
+ // For testing: switch between engine.scratch.. functions and engine.setValue(.., "scratch2..")
52
+ const useEngineScratch = ! ! engine . getSetting ( "scratchModeScratchTick" ) ;
53
+
51
54
const DeckColors = [
52
55
LedColors [ engine . getSetting ( "deckA" ) ] || LedColors . red ,
53
56
LedColors [ engine . getSetting ( "deckB" ) ] || LedColors . blue ,
@@ -117,6 +120,11 @@ const BeatLoopRolls = [
117
120
// the motor if enable. Recommended value are 33 + 1/3 or 45.
118
121
// Default: 33 + 1/3
119
122
const BaseRevolutionsPerMinute = engine . getSetting ( "baseRevolutionsPerMinute" ) || 33 + 1 / 3 ;
123
+ // alpha and beta are the recommended start values from
124
+ // https://github.com/mixxxdj/mixxx/wiki/midi%20scripting#scratching-and-jog-wheels
125
+ const ScratchAlpha = 1.0 / 8 ;
126
+ const ScratchBeta = ScratchAlpha / 32 ;
127
+ const ScratchIntervalsPerRev = 6750 ;
120
128
121
129
// Define whether or not to use motors.
122
130
// This is a BETA feature! Please use at your own risk. Setting this off means that below settings are inactive
@@ -2413,8 +2421,16 @@ class S4Mk3Deck extends Deck {
2413
2421
this . touched = touched ;
2414
2422
if ( this . deck . wheelMode === wheelModes . vinyl || this . deck . wheelMode === wheelModes . motor ) {
2415
2423
if ( touched ) {
2416
- engine . setValue ( this . group , "scratch2_enable" , true ) ;
2417
- } else {
2424
+ if ( useEngineScratch ) {
2425
+ engine . scratchEnable ( this . deck . currentDeckNumber ,
2426
+ ScratchIntervalsPerRev ,
2427
+ BaseRevolutionsPerMinute ,
2428
+ ScratchAlpha ,
2429
+ ScratchBeta ) ; // ramoing true by default
2430
+ } else {
2431
+ engine . setValue ( this . group , "scratch2_enable" , true ) ;
2432
+ }
2433
+ } else { // release
2418
2434
this . stopScratchWhenOver ( ) ;
2419
2435
}
2420
2436
}
@@ -2427,9 +2443,17 @@ class S4Mk3Deck extends Deck {
2427
2443
if ( engine . getValue ( this . group , "play" ) &&
2428
2444
engine . getValue ( this . group , "scratch2" ) < 1.5 * baseRevolutionsPerSecond &&
2429
2445
engine . getValue ( this . group , "scratch2" ) > 0 ) {
2430
- engine . setValue ( this . group , "scratch2_enable" , false ) ;
2446
+ if ( useEngineScratch ) {
2447
+ engine . scratchDisable ( this . deck . currentDeckNumber ) ;
2448
+ } else {
2449
+ engine . setValue ( this . group , "scratch2_enable" , false ) ;
2450
+ }
2431
2451
} else if ( engine . getValue ( this . group , "scratch2" ) === 0 ) {
2432
- engine . setValue ( this . group , "scratch2_enable" , false ) ;
2452
+ if ( useEngineScratch ) {
2453
+ engine . scratchDisable ( this . deck . currentDeckNumber ) ;
2454
+ } else {
2455
+ engine . setValue ( this . group , "scratch2_enable" , false ) ;
2456
+ }
2433
2457
} else {
2434
2458
engine . beginTimer ( 100 , this . stopScratchWhenOver . bind ( this ) , true ) ;
2435
2459
}
@@ -2509,7 +2533,11 @@ class S4Mk3Deck extends Deck {
2509
2533
break ;
2510
2534
case wheelModes . vinyl :
2511
2535
if ( this . deck . wheelTouch . touched || engine . getValue ( this . group , "scratch2" ) !== 0 ) {
2512
- engine . setValue ( this . group , "scratch2" , this . speed ) ;
2536
+ if ( useEngineScratch ) {
2537
+ engine . scratchTick ( this . deck . currentDeckNumber , diff ) ;
2538
+ } else {
2539
+ engine . setValue ( this . group , "scratch2" , this . speed ) ;
2540
+ }
2513
2541
} else {
2514
2542
engine . setValue ( this . group , "jog" , this . speed ) ;
2515
2543
}
0 commit comments