Skip to content

Updates to JS engine are missing after MidiController::makeInputHandler() #15989

@git-developer

Description

@git-developer

Bug Description

When MidiController::makeInputHandler() is used, some changes to the JS engine have no effect. This issue contains a reproducible demo showing that volume does not update under certain circumstances.

Prerequisites

  1. MidiController::makeInputHandler() is used to register a fader (volume) and a button (press: volume_set_zero / release: volume = 0.5) for deck 1.
  2. The mute button is pressed => Deck 1 is muted.
  3. The mute button is released => Deck 1 is unmuted.
  4. The volume fader is moved => Volume of deck 1 changes.
  5. The mute button is pressed => Deck 1 is muted.
  6. The mute button is released.

Expected behavior

Deck 1 is unmuted.

Actual behavior

The volume of Deck 1 does not change, the deck stays muted.

Additional context

  • The issue does not occur when MidiController::makeInputHandler() is not used.
  • The issue does not occur when volume is set to 0 (instead of using volume_set_zero).

Test case

XML demo: broken
<?xml version="1.0" encoding="utf-8"?>
<MixxxControllerPreset schemaVersion="1" mixxxVersion="2.6+">
  <info>
    <name>Volume Demo Broken</name>
  </info>
  <controller id="VolumeDemoBroken">
    <scriptfiles>
      <file filename="midi-components-0.0.js" />
      <file filename="volume-demo-scripts.js" functionprefix="VolumeDemoBroken" />
    </scriptfiles>
  </controller>
</MixxxControllerPreset>
XML demo: working
<?xml version="1.0" encoding="utf-8"?>
<MixxxControllerPreset schemaVersion="1" mixxxVersion="2.6+">
  <info>
    <name>Volume Demo OK</name>
  </info>
  <controller id="VolumeDemoOK">
    <scriptfiles>
      <file filename="midi-components-0.0.js" />
      <file filename="volume-demo-scripts.js" functionprefix="VolumeDemoOK" />
    </scriptfiles>
    <controls>
      <control>
        <group>[Channel1]</group>
        <key>VolumeDemoOK.muteButton.input</key>
        <status>0x90</status>
        <midino>0x11</midino>
        <options>
          <script-binding/>
        </options>
      </control>
      <control>
        <group>[Channel1]</group>
        <key>volume</key>
        <status>0xB0</status>
        <midino>0x31</midino>
      </control>
    </controls>
  </controller>
</MixxxControllerPreset>
JavaScript
/*
 * Behavior:
 *  Script is loaded, no MIDI control was touched yet.
 *  Button [0x90, 0x11] is pressed => Deck 1 is muted
 *  Button [0x90, 0x11] is released => Deck 1 volume is set to 0.5
 * 
 *  Volume is changed via MIDI fader [0xB0, 0x31].
 *  Button [0x90, 0x11] is pressed => Deck 1 is muted
 *  Button [0x90, 0x11] is released => Deck 1 STAYS MUTED
 * 
 */
MuteButtonHolder = {
  muteButton: new components.Button({
      group: "[Channel1]",
      midi: [0x90, 0x11],
      type: components.Button.prototype.types.toggle,
  })
}
MuteButtonHolder.muteButton.input = function(_channel, _control, value, _status, _group) {
  if (value) {
      print("muteButton: Press");
      script.triggerControl("[Channel1]", "volume_set_zero");
      //engine.setValue("[Channel1]", "volume", 0); // works, no problem
  } else {
      print("muteButton: Release");
      engine.setValue("[Channel1]", "volume", 0.5);
      print("muteButton: Volume after set to 0.5: " +  engine.getValue("[Channel1]", "volume"));
  }
};

VolumeDemoOK = {
  init: function() {},
  shutdown: function() {},
  muteButton: MuteButtonHolder.muteButton
};

VolumeDemoBroken = {
  volumeFader: new components.Pot({
    group: "[Channel1]",
    key: "volume",
    midi: [0xB0, 0x31]
  }),
  muteButton: MuteButtonHolder.muteButton,
  init: function(_controllerId, _debug) {
    midi.makeInputHandler(0xB0, 0x31, this.volumeFader.input.bind(VolumeDemoBroken.volumeFader));
    midi.makeInputHandler(0x90, 0x11, this.muteButton.input.bind(VolumeDemoBroken.muteButton));
  },
  shutdown: function() {},
};

Version

2.6

OS

Ubuntu 24.04

Metadata

Metadata

Assignees

No one assigned

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions