-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
midi-components-0.0.js: Pot support for arbitrary maximums in 7-/14-bit handlers #4495
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||
---|---|---|---|---|
|
@@ -467,16 +467,25 @@ | |||
// For the first messages, disregard the LSB in case | ||||
// the first LSB is received after the first MSB. | ||||
if (this.MSB === undefined) { | ||||
this.max = 127; | ||||
// a flaw in the Pot API does not mandate consumers | ||||
// to supply an accurate max value when using | ||||
// this with non-7-bit inputs. We cannot detect | ||||
// that in the constructor so set the max | ||||
// appropriately here | ||||
if (this.max === Component.prototype.max) { | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do not understand the condition. When does this happen. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It checks if the user did not specify a custom max value. If that is the case, the maximum is not |
||||
this.max = (1 << 14) - 1; | ||||
} | ||||
value = (value << 7) + (this._firstLSB ? this._firstLSB : 0); | ||||
this.input(channel, control, value, status, group); | ||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Temporary change a member to before calling a function looks hacky. Why is this code required? Is this an initial call with low precision? Let's say we have 8 bit precision, than the MSB is 1 for the max value. Can this call be removed? Alternative we may leave max untouched just set the this.MSB before and pass 0 as value. By the way, every input function does
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I agree, but the entire
Yes.
Maybe. I'll look into it. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The problem with removing this call (and by extension the entire branch) is that requesting the initial controller state will break if the LSB is received before the MSB. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If the LSB received before the MSB, the whole implementation is broken! Consider going from 126 to 129
Wen the send order is actually swapped the MSB from the first value is paired with the LSB from the next:
result:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In the C Domain we allow both orders: mixxx/src/controllers/midi/midicontroller.cpp Line 318 in 7672cf1
The requirement is that both messages are send with nothing else in between. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. First of all, we discussing no longer the scope of this PR. In the C domain we also do not know the order in advance. We collect MSB and LSB messages and when both is there we calculate the value. We discard a stored MSB or LSB when any other message is send. This ensures that both are actually belong together. Of cause that can ticked as well, but at least better than always using the wrong order. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
So whats the point then? I know the design is flawed. So will we agree on that and discuss whats actually in the scope of this PR or will we blow it 10x as we usually do?
Are you sure? Thats what I figured the distinction between
Ok going back on topic. We don't know in which order There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That was my point, not blowing up this PR. I have now understand the issue.
Yes, pretty sure. We even have a test for that. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So for the solution here, wan may to shift the "value" left, instead of sifting the "max" right. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Now I understand your proposal. Thanks. I just pushed the commit containing your suggestions. |
||||
this.max = 16383; | ||||
} | ||||
this.MSB = value; | ||||
}, | ||||
inputLSB: function(channel, control, value, status, group) { | ||||
// Make sure the first MSB has been received | ||||
if (this.MSB !== undefined) { | ||||
this.input(channel, control, value, status, group); | ||||
} else { | ||||
this._firstLSB = value; | ||||
} | ||||
}, | ||||
connect: function() { | ||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why can't that be detected in the constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because we don't know how the component is being used until either the
input
handler (for regular 7-bit precision) or theinputLSB/inputMSB
handlers (for 14-bit precision) have been called.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Adding this requirement later is a breaking API change, so something we should reserve for the ES6 rework.