Skip to content

Commit e9a765e

Browse files
Patrick WrightPatrick Wright
Patrick Wright
authored and
Patrick Wright
committed
The grand master doesn't seem to work correctly on the current version of QLC+. So, we will perform GM calculations manually (i.e., scale all inputs by the GM value) before send fader values to QLC+.
1 parent 573252e commit e9a765e

File tree

2 files changed

+64
-10
lines changed

2 files changed

+64
-10
lines changed

index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
<!-- GM Fader -->
105105
<div class="fader-container d-flex justify-content-center">
106106
<!-- Fader -->
107-
<div class="fader" id="gm" channel="0" value="255" max="255" onValueChanged="onChannelInput" label="GM"></div>
107+
<div class="fader" id="gm" channel="0" value="255" max="255" onValueChanged="onGMChannelInput" label="GM"></div>
108108
</div>
109109
</div>
110110

js/app.js

Lines changed: 63 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,14 @@ const kSceneModeRun = "run";
55
const kSelectorSceneMode = 'input[type=radio][name=selectMode]';
66
const kSelectorConnectingSpinner = "label[for=btnConnect] .spinner";
77
const kLockGMFader = false; //Should the Grand Master fader be lockable?
8+
/**
9+
* @brief Does the QLC+ application support the grand master fader?
10+
*
11+
* If true, then the grand master fader value will be sent directly to QLC+.
12+
* If false, the values of all faders will be internally scaled by the grand
13+
* master and sent to QLC+.
14+
*/
15+
const kQLCHasGrandMaster = false;
816

917
//Globals
1018
var qlc = new QLCPlus(autoReconnect = true);
@@ -125,10 +133,53 @@ function confirmModal(title, message, callback)
125133
//-----[ FUNCTION: sendAllFaders ]----------------------------------------------
126134
function sendAllFaders()
127135
{
128-
qlc.setGrandMaster(gmFader.value);
129-
for (let i = 0; i < faders.length; i++)
136+
if (kQLCHasGrandMaster)
137+
{
138+
qlc.setGrandMaster(gmFader.value);
139+
for (let i = 0; i < faders.length; i++)
140+
{
141+
qlc.setSimpleDeskChannel(faders[i].channel, faders[i].value);
142+
}
143+
}
144+
else
130145
{
131-
qlc.setSimpleDeskChannel(faders[i].channel, faders[i].value);
146+
const gmValPercent = gmFader.valueToPercent(gmFader.value);
147+
for (let i = 0; i < faders.length; i++)
148+
{
149+
qlc.setSimpleDeskChannel(faders[i].channel, Math.trunc(faders[i].value * gmValPercent));
150+
}
151+
}
152+
153+
}
154+
155+
//-----[ FUNCTION: onGMChannelInput ]-------------------------------------------
156+
function onGMChannelInput(self)
157+
{
158+
const val = self.value;
159+
const valPercent = self.valueToPercent(self.value);
160+
161+
try
162+
{
163+
if (kQLCHasGrandMaster) //We can let QLC+ handle the grand master
164+
{
165+
qlc.setGrandMaster(val);
166+
}
167+
else //We need to manually perform grand master calculations
168+
{
169+
//Scale all fader values by the grand master
170+
for (let i = 0; i < faders.length; i++)
171+
{
172+
const channel = faders[i].channel;
173+
const faderVal = faders[i].value;
174+
const scaledFaderVal = Math.trunc(faderVal * valPercent);
175+
176+
qlc.setSimpleDeskChannel(channel, scaledFaderVal);
177+
}
178+
}
179+
}
180+
catch (e)
181+
{
182+
console.log(e); //Do nothing
132183
}
133184
}
134185

@@ -138,20 +189,23 @@ function sendAllFaders()
138189
*/
139190
function onChannelInput(self)
140191
{
141-
var channel = self.channel;
142-
var val = self.value;
192+
const channel = self.channel;
193+
const val = self.value;
143194

144195
try
145196
{
146-
if (channel == 0)
197+
if (kQLCHasGrandMaster)
147198
{
148-
qlc.setGrandMaster(val);
199+
qlc.setSimpleDeskChannel(channel, val);
149200
}
150201
else
151202
{
152-
qlc.setSimpleDeskChannel(channel, val);
203+
//Scale the value actually sent to QLC+ by the current grand master value
204+
const gmValPercent = gmFader.valueToPercent(gmFader.value);
205+
const scaledVal = Math.trunc(val * gmValPercent);
206+
207+
qlc.setSimpleDeskChannel(channel, scaledVal);
153208
}
154-
155209
}
156210
catch(e)
157211
{

0 commit comments

Comments
 (0)