markphilpot / gcpeditor

Ground Control Pro Editor
6 stars 0 forks source link

Device Channels for MIDI Always Set to 1 #18

Open sbmechanics opened 7 years ago

sbmechanics commented 7 years ago

In Configuration > Devices, the channel for a given device always sets to 1. See the screenshots below (Device 1 as Channel 1, Device 8 as Channel 8 > SYX file shows Device 1 as Channel 1, Device 8 as Channel 1).
capture capture1

sbmechanics commented 7 years ago

It appears that line 700 of main.js ( gcp.config.deviceChannels[dNum] = 1;) is setting the channel to 1 for any active device, and that a UI change of the Channel does not change the relevant gcp.config.deviceChannels[dNum].

sbmechanics commented 7 years ago

This issue affects the Program Offset setting for Devices as well.

sbmechanics commented 7 years ago

Potential fix: add following code below line 721 in main.js:

$d.find('.deviceChannel').change(function(){ gcp.config.deviceChannels[dNum] = +$(this).val(); }).val(gcp.config.deviceChannels[dNum]);

$d.find('.deviceProgramOffset').change(function(){ gcp.config.deviceProgramOffsets[dNum] = +$(this).val(); }).val(gcp.config.deviceProgramOffsets[dNum]);

sbmechanics commented 7 years ago

Unsure if this is related to these changes, and I can open a separate issue if you want. On a blank / new config (imported syx files are not affected), Preset 0 always starts with all devices disabled, and starts with the PC number for all devices as 1. Incrementing up starts at Preset 1, which will also have all devices set to PC but enables (see picture). For new configs, my guess is that all device on Preset 0 should be enabled (for consistency purposes), and that the incrementing should start with Preset 0, at 0 or 1 depending on the Program Offset for the device in Configuration > Devices. The trick would be not to have a preset PC change if editing to the preset had already been done and the Program Offset subsequently changed. capture

sbmechanics commented 7 years ago

Increment issue drop-in fix would be to change line 499 in gcp.js to this.presets[i].deviceProgramChanges[j].pc = (i%128); from this.presets[i].deviceProgramChanges[j].pc = (i%128) - 1; and commenting out lines 496 and 501 in gcp.js.

Looking at the GCP board itself, best option may be to simply increment from 1 on all devices, starting at preset 1, regardless of Program Offset, and default all devices on. (Which matches the changes above, but all of it needs a second look.) The more that I look at this, and the way that it can renumber Program Changes on an existing config whenever a device is added / removed or the Program Offset is changed, the more that I'm thinking the entire if / for loop (496-502 in gcp.js) should be commented out, letting the user number the PC and select device on / off as they see fit. The risk of custom presets getting renumbered is high. The same would likely apply for renumbering that occurs elsewhere in the code for a change to the Program Offset setting. The downside would be that most people are likely moving through Program Changes in presets sequentially from 0-127 or 1-128 when creating a config. Thoughts?