Skip to content
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

Add support for S-Series MK2 speed-sensitive knobs #20

Merged
merged 4 commits into from
Jul 18, 2024
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 15 additions & 5 deletions controller_definition.py
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,7 @@ def OnDirtyMixerTrack(self, index):
def OnUpdateMeters(self): # Intended to be declared by child
raise NotImplementedError()

def adjustMixer(self, knob: int, dataType: str, action: str, selectedTrack: int):
def adjustMixer(self, knob: int, dataType: str, action: str, selectedTrack: int, sensitivity: float = None):
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sensitivity: float = None should be speed: int instead. Also, please comment the parameter in the docstring of the function.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pushed 9094dd1, which should resolve this. Let me know if I can elaborate more on the description I put.

""" Dynamically maps the physical knob to the right mixer track depending on the track group the selected track belongs to, and adjusts the parameter.
### Parameters

Expand All @@ -436,23 +436,33 @@ def adjustMixer(self, knob: int, dataType: str, action: str, selectedTrack: int)
# Multiplies the trackGroup to 8 to get the index of the first track of that group
trackFirst = trackGroup * 8

# If you receive a sensitivity value, set it to a controllable value, else default to 1
if (sensitivity):
sensitivity = sensitivity / 15

# When decreasing the mixer knob, the amount that it changes is dramatically different than increasing.
if (action == "DECREASE"):
sensitivity = sensitivity / 10
else:
sensitivity = 1

Copy link
Owner

@hobyst hobyst Feb 19, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to do any of this to normalize the value. Try first with the suggestion I wrote in my review and tweak the logarithmic function before falling back the implementation to a conditional block again.

if (trackGroup == 15) and (knob == 6 or knob == 7): # Control 15th group exception
return

else:
if dataType == "VOLUME":
if action == "INCREASE":
mixer.setTrackVolume(trackFirst + knob, mixer.getTrackVolume(trackFirst + knob) + config.KNOB_INCREMENTS_VOL)
mixer.setTrackVolume(trackFirst + knob, mixer.getTrackVolume(trackFirst + knob) + (config.KNOB_INCREMENTS_VOL * sensitivity))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offset should be config.KNOB_INCREMENTS_VOL * log(speed, 63) instead of config.KNOB_INCREMENTS_VOL * sensitivity. Same thing goes for decrement.


elif action == "DECREASE":
mixer.setTrackVolume(trackFirst + knob, mixer.getTrackVolume(trackFirst + knob) - config.KNOB_INCREMENTS_VOL)
mixer.setTrackVolume(trackFirst + knob, mixer.getTrackVolume(trackFirst + knob) - (config.KNOB_INCREMENTS_VOL * sensitivity))

elif dataType == "PAN":
if action == "INCREASE":
mixer.setTrackPan(trackFirst + knob, mixer.getTrackPan(trackFirst + knob) + config.KNOB_INCREMENTS_PAN)
mixer.setTrackPan(trackFirst + knob, mixer.getTrackPan(trackFirst + knob) + (config.KNOB_INCREMENTS_PAN * sensitivity))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Offset should be config.KNOB_INCREMENTS_PAN * log(speed, 63) instead of config.KNOB_INCREMENTS_PAN * sensitivity. Same thing goes for decrement.


elif action == "DECREASE":
mixer.setTrackPan(trackFirst + knob, mixer.getTrackPan(trackFirst + knob) - config.KNOB_INCREMENTS_PAN)
mixer.setTrackPan(trackFirst + knob, mixer.getTrackPan(trackFirst + knob) - (config.KNOB_INCREMENTS_PAN * sensitivity))

def getUndoStatus(self):
""" Helper function to set the light on the UNDO button. """
Expand Down