Skip to content

Commit 6f92ebd

Browse files
committed
Add tempo button LED as beat indicator option
Signed-off-by: Sam Whited <[email protected]>
1 parent d0946ae commit 6f92ebd

File tree

2 files changed

+36
-16
lines changed

2 files changed

+36
-16
lines changed

Diff for: res/controllers/DJ TechTools MIDI Fighter Twister.midi.xml

+17
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,23 @@
1111
</devices>
1212
</info>
1313
<settings>
14+
<option variable="beatColor" type="enum" label="Beat Indicator Color">
15+
<description>
16+
Use the tempo knob LED as a beat indicator when set.
17+
</description>
18+
<value label="Off" default="true">-1</value>
19+
<value label="Firmware Default">127</value>
20+
<value label="Blue">1</value>
21+
<value label="Celeste">32</value>
22+
<value label="Teal">40</value>
23+
<value label="Green">50</value>
24+
<value label="Lime">60</value>
25+
<value label="Yellow">66</value>
26+
<value label="Orange">74</value>
27+
<value label="Red">85</value>
28+
<value label="Fuscia">100</value>
29+
<value label="Purple">108</value>
30+
</option>
1431
<option variable="peakColor" type="enum" label="Peak Indicator Color">
1532
<description>
1633
Use the gain knob LED as a peak indicator when set.

Diff for: res/controllers/DJ TechTools-MIDI Fighter Twister-scripts.js

+19-16
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,21 @@ var MidiFighterTwister;
1515
return Math.pow(value / 4, 0.5) * max;
1616
};
1717

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+
};
3233
};
3334

3435
components.Button.prototype.on = engine.getSetting("defColor");
@@ -101,12 +102,14 @@ var MidiFighterTwister;
101102
group: `[Channel${this.deckNumbers[0]}]`,
102103
midi: [0xB1, this.midiModifier(0x04)],
103104
key: "rate_set_default",
105+
connect: indicatorConnect(engine.getSetting("beatColor"), "beat_active"),
104106
});
107+
105108
this.gainButton = new components.Button({
106109
group: `[Channel${this.deckNumbers[0]}]`,
107110
midi: [0xB1, this.midiModifier(0x00)],
108111
key: "pregain_set_default",
109-
connect: gainConnect,
112+
connect: indicatorConnect(engine.getSetting("peakColor"), "PeakIndicator"),
110113
});
111114
// The volume button toggles the headphones, unlike the others which
112115
// reset their control.
@@ -167,7 +170,7 @@ var MidiFighterTwister;
167170
group: "[Master]",
168171
midi: [0xB1, 0x0F],
169172
key: "gain_set_default",
170-
connect: gainConnect,
173+
connect: indicatorConnect(engine.getSetting("peakColor"), "PeakIndicator"),
171174
});
172175
}
173176

0 commit comments

Comments
 (0)