Not all values are sent when switching photos
I have been having an issue where not all of the parameter values are sent from lightroom to my midi controller when advancing through photos.
I am working on trying to track down the bug, but here is what I have so far: -3 photos in my library -My controller has only one parameter, the Dehaze slider -1 photo has dehaze set to -60, the other to -25 and the other to +25 (these are rough values that I will need to confirm later, the photos also have other adjustments)
I am able to reproduce this issue as soon as I open Lightroom. I do not make any adjustments but just switch back and forth from photos. When I click from one photo to the next the dehaze value appears to be sent properly to the controller for the -60 and -25 photos, however as soon as I click on the photo that has dehaze set to +25, this value is not sent to the controller and the leds on the controller show the previous value (-25 or -60)
I put in a couple of debug statements into client.lua to see what was happening, to see if the midi value for dehaze was being sent when each new photo is selected. It turns out that this is not the case. I put some print statements in the startAsyncTask function prior to the call to MIDI2LR.SERVER:send() to see what parameters were being sent. AS expected the calls to update the dehaze were only being sent for the -60 and -25 cases and not for the +25 case.
The problem appears to be inside the LrDevelopController.addAdjustmentChangeObserver() function. The parameters from the BASIC panel all seem to be included and sent properly, but switching back and forth between photos doesn't always send every parameter or the dehaze slider.
I would like to have every parameter sent to my midi controller, as soon as I select a new photo in the develop module. But it appears as though only certain parameters are being sent across.
If I load another profile and then switch back to the original profile then all of the settings are sent to the controller. But this is because of the call to resync() which updates everything.
Thank you for digging into this! Could you check the variable MIDI2LR.PARAM_OBSERVER.Dehaze immediately before the for loop in the adjustment change observer? Also were you in the Develop module for all three images? The application will intentionally stop sending parameter changes if not in the Develop module, as it is impossible to ascertain the correct range for a parameter in the other modules (a LR limitation).
Ill keep working at it. Yes, I have been in the develop module the entire time. To reproduce the issue, I simply boot up lightroom in the develop library and just click back and forth between the photos. And in the case where i have positive dehaze value, I do not receive any signals.
The problem appears to be with Parameters.Order, that it no longer includes the Dehaze. I
if LrApplicationView.getCurrentModuleName() ~= 'develop' then return end
for _,param in ipairs(Parameters.Order) do
if(param == "Dehaze") then LrDialogsMYdebug.message('dehaze param in parameters order') end if(observer[param] ~= LrDevelopController.getValue(param)) then
If I boot into the program with the positive dehaze photo selected I receive the signals to my midi controller. When i switch to a negatize dehaze photo, I get feedback. But then when I switch back to the positive dehzae photo, the dehaze on my midi is not updated.
I don’t understand how Parameters.Order can lose Dehaze, but try the following:
Replace
for _,param in ipairs(Parameters.Order) do
With
for param in pairs(Parameters.Names) do
It turns out that the following line is the culprit
observer[param] = LrDevelopController.getValue(param)
If I comment this line out, the plugin always sends the data feedback to my MIDI controller. Now to find out why this is causing the issue... Might have been messing up the iterator in the for loop
I think I have narrowed it down to the following two lines, which play off of each other.
MIDI2LR.SERVER:send(string.format('%s %g\n', param, develop_lerp_to_midi(param))) observer[param] = LrDevelopController.getValue(param)
If I comment out the first, the observer gets updated with the appropriate new values any time the observer doesnt match the values from the lightroom sliders. But since the output to the midi controller is disabled, my midi controller is not updated.
If I comment out the second line, the midi controller is updated, but it is updated unnecessarily, as all parameters are refreshed regardless, even if they already match the lightroom sliders.
very odd. could you try the following change, which is from the Develop branch? There may be some recursion issues here, with the observer called multiple times. Perhaps this simplification of the code will fix it. Otherwise I'll put a semaphore guard in place.
Swap out the for loop
for _,param in ipairs(Parameters.Order) do
if(observer[param] ~= LrDevelopController.getValue(param)) then
MIDI2LR.SERVER:send(string.format('%s %g\n', param, develop_lerp_to_midi(param)))
observer[param] = LrDevelopController.getValue(param)
MIDI2LR.LAST_PARAM = param
end
end
with
for _,param in ipairs(Parameters.Order) do
local lrvalue = LrDevelopController.getValue(param)
if observer[param] ~= lrvalue and type(lrvalue) == 'number' then
MIDI2LR.SERVER:send(string.format('%s %g\n', param, develop_lerp_to_midi(param)))
observer[param] = lrvalue
MIDI2LR.LAST_PARAM = param
end
end
Yes!! Looks like this seems have resolved the issue, too many calls to LrDevelopController.getValue I was just about there if you see below. I believe this will fix the previous NOISE issue (#138) as well. It turns out there were quite a few parameters being omitted and dehaze, noise and camera calibration info was not being updated to the controller.
Additional INFO prior to fix: Even more strange the following works to update my midi controller but This works: if(observer[param] ~= LrDevelopController.getValue(param)) then MIDI2LR.SERVER:send(string.format('%s %g\n', param, develop_lerp_to_midi(param))) MIDI2LR.LAST_PARAM = param end
But if I comment out this first line: if(observer[param] ~= LrDevelopController.getValue(param)) then then my controller is not updated!
fixed in preview release 0.9.4.2 https://github.com/rsjaffe/MIDI2LR/releases/tag/v0.9.4.2