@@ -15,20 +15,21 @@ var MidiFighterTwister;
15
15
return Math . pow ( value / 4 , 0.5 ) * max ;
16
16
} ;
17
17
18
- const gainConnect = function ( ) {
19
- this . connections [ 0 ] = engine . makeConnection ( this . group , this . outKey , this . output . bind ( this ) ) ;
20
-
21
- const peakColor = engine . getSetting ( "peakColor" ) ;
22
- if ( peakColor !== - 1 ) {
23
- this . connections [ 1 ] = engine . makeConnection ( this . group , "PeakIndicator" , ( value ) => {
24
- if ( value ) {
25
- this . send ( peakColor ) ;
26
- } else {
27
- const pregainDef = this . inGetParameter ( ) ;
28
- this . send ( pregainDef ? this . on : this . off ) ;
29
- }
30
- } ) ;
31
- }
18
+ const indicatorConnect = function ( color , key ) {
19
+ return function ( ) {
20
+ this . connections [ 0 ] = engine . makeConnection ( this . group , this . outKey , this . output . bind ( this ) ) ;
21
+
22
+ if ( color !== - 1 ) {
23
+ this . connections [ 1 ] = engine . makeConnection ( this . group , key , ( value ) => {
24
+ if ( value === 0 ) {
25
+ this . send ( color ) ;
26
+ } else {
27
+ const pregainDef = this . inGetParameter ( ) ;
28
+ this . send ( pregainDef ? this . on : this . off ) ;
29
+ }
30
+ } ) ;
31
+ }
32
+ } ;
32
33
} ;
33
34
34
35
components . Button . prototype . on = engine . getSetting ( "defColor" ) ;
@@ -101,12 +102,14 @@ var MidiFighterTwister;
101
102
group : `[Channel${ this . deckNumbers [ 0 ] } ]` ,
102
103
midi : [ 0xB1 , this . midiModifier ( 0x04 ) ] ,
103
104
key : "rate_set_default" ,
105
+ connect : indicatorConnect ( engine . getSetting ( "beatColor" ) , "beat_active" ) ,
104
106
} ) ;
107
+
105
108
this . gainButton = new components . Button ( {
106
109
group : `[Channel${ this . deckNumbers [ 0 ] } ]` ,
107
110
midi : [ 0xB1 , this . midiModifier ( 0x00 ) ] ,
108
111
key : "pregain_set_default" ,
109
- connect : gainConnect ,
112
+ connect : indicatorConnect ( engine . getSetting ( "peakColor" ) , "PeakIndicator" ) ,
110
113
} ) ;
111
114
// The volume button toggles the headphones, unlike the others which
112
115
// reset their control.
@@ -167,7 +170,7 @@ var MidiFighterTwister;
167
170
group : "[Master]" ,
168
171
midi : [ 0xB1 , 0x0F ] ,
169
172
key : "gain_set_default" ,
170
- connect : gainConnect ,
173
+ connect : indicatorConnect ( engine . getSetting ( "peakColor" ) , "PeakIndicator" ) ,
171
174
} ) ;
172
175
}
173
176
0 commit comments