summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian <git-developer@users.noreply.github.com>2020-11-25 09:25:05 +0100
committerChristian <git-developer@users.noreply.github.com>2020-11-25 09:25:05 +0100
commitca3deb8e3c135a3e8e635aa073305c45c9e09011 (patch)
tree8fde8369ea69859ee459628eb761e0a636b880b4
parentab457a4661ee4208216cc132ad38eadad018a7dc (diff)
feat(BCR2000): restrict publishers to pots
-rw-r--r--res/controllers/midi-components-extension.js46
1 files changed, 24 insertions, 22 deletions
diff --git a/res/controllers/midi-components-extension.js b/res/controllers/midi-components-extension.js
index 5edaa33bb5..1afe106bdf 100644
--- a/res/controllers/midi-components-extension.js
+++ b/res/controllers/midi-components-extension.js
@@ -967,33 +967,35 @@
},
/**
- * Enhance components for sending output values to the controller.
+ * Enhance pots so that they send output values to the controller.
*
- * The enhancement is implemented by adding a `Publisher` for each source component.
+ * The enhancement is implemented by creating a `Publisher` for each pot.
* The optional array of function names may be used to rebind the publisher
- * every time a function is called on the source component.
+ * every time a function is called on the pot.
*
- * @param {Array} target Target for publisher components
- * @param {object} componentContainer Container with components to be enhanced
+ * @param {Array} target Storage for publisher components
+ * @param {object} potContainer Component container with pots to be enhanced
* @param {Array<string>} rebindTriggers Names of functions that trigger a rebind of the
- * publisher to the source component
+ * publisher to the pot
* @private
*/
- addPublishers: function(target, componentContainer, rebindTriggers) {
+ createPublishersForPots: function(target, potContainer, rebindTriggers) {
var triggers = rebindTriggers || [];
- componentContainer.forEachComponent(function(effectComponent) {
- var prototype = Object.getPrototypeOf(effectComponent);
- var publisher = new components.extension.Publisher({source: effectComponent});
- target.push(publisher);
- triggers.forEach(function(functionName) {
- var delegate = prototype[functionName];
- if (typeof delegate === "function") {
- prototype[functionName] = function() {
- delegate.apply(this, arguments);
- publisher.bind();
- };
- }
- });
+ potContainer.forEachComponent(function(effectComponent) {
+ if (effectComponent instanceof components.Pot) {
+ var prototype = Object.getPrototypeOf(effectComponent);
+ var publisher = new components.extension.Publisher({source: effectComponent});
+ target.push(publisher);
+ triggers.forEach(function(functionName) {
+ var delegate = prototype[functionName];
+ if (typeof delegate === "function") {
+ prototype[functionName] = function() {
+ delegate.apply(this, arguments);
+ publisher.bind();
+ };
+ }
+ });
+ }
});
},
@@ -1012,7 +1014,7 @@
var unit = new components.EffectUnit(effectUnitDefinition.unitNumbers, true);
this.setMidiAddresses(effectUnitDefinition, unit);
if (effectUnitDefinition.feedback) {
- this.addPublishers(target, unit, ["onFocusChange", "shift", "unshift"]);
+ this.createPublishersForPots(target, unit, ["onFocusChange", "shift", "unshift"]);
}
unit.init();
return unit;
@@ -1033,7 +1035,7 @@
var unit = new components.extension.EqualizerUnit(equalizerUnitDefinition.channel);
this.setMidiAddresses(equalizerUnitDefinition, unit);
if (equalizerUnitDefinition.feedback) {
- this.addPublishers(target, unit);
+ this.createPublishersForPots(target, unit);
}
return unit;
},