-
Notifications
You must be signed in to change notification settings - Fork 6
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
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
f585f63
modify adjustMixer function to accept optional sensitivity parameter
keithhand 3eb103c
add custom s-series messages for speed-sensitive knobs
keithhand 7a91a03
fix sensitivity math
keithhand 9094dd1
add docstring parameter and remove parameter default
keithhand File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -301,22 +301,22 @@ def OnMidiMsg(self, event): | |
event.handled = True | ||
# Increase | ||
if nihia.mixer.KNOB_INCREASE_MIN_SPEED <= event.data2 <= nihia.mixer.KNOB_INCREASE_MAX_SPEED: | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[0][0], "VOLUME", "INCREASE", mixer.trackNumber()) | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[0][0], "VOLUME", "INCREASE", mixer.trackNumber(), event.data2) | ||
|
||
# Decrease | ||
elif nihia.mixer.KNOB_DECREASE_MIN_SPEED >= event.data2 >= nihia.mixer.KNOB_DECREASE_MAX_SPEED: | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[0][0], "VOLUME", "DECREASE", mixer.trackNumber()) | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[0][0], "VOLUME", "DECREASE", mixer.trackNumber(), event.data2) | ||
|
||
# Shifted knobs (pan adjustment) | ||
elif nihia.mixer.knobs[1][0] <= event.data1 <= nihia.mixer.knobs[1][7]: | ||
event.handled = True | ||
# Increase | ||
if nihia.mixer.KNOB_INCREASE_MIN_SPEED <= event.data2 <= nihia.mixer.KNOB_INCREASE_MAX_SPEED: | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[1][0], "PAN", "INCREASE", mixer.trackNumber()) | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[1][0], "PAN", "INCREASE", mixer.trackNumber(), event.data2) | ||
|
||
# Decrease | ||
elif nihia.mixer.KNOB_DECREASE_MIN_SPEED >= event.data2 >= nihia.mixer.KNOB_DECREASE_MAX_SPEED: | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[1][0], "PAN", "DECREASE", mixer.trackNumber()) | ||
self.adjustMixer(event.data1 - nihia.mixer.knobs[1][0], "PAN", "DECREASE", mixer.trackNumber(), event.data2) | ||
|
||
# Additional controller-dependent code | ||
try: | ||
|
@@ -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: int): | ||
""" 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 | ||
|
||
|
@@ -429,30 +429,35 @@ def adjustMixer(self, knob: int, dataType: str, action: str, selectedTrack: int) | |
- action: Can be INCREASE or DECREASE. | ||
|
||
- selectedTrack: The actual selected track that will be used to calculate the track group. | ||
|
||
- sensitivity: The speed at which a knob gets turned. | ||
""" | ||
# Calculates which track group the current track belongs to and truncates the value to get the exact number | ||
trackGroup = math.trunc(1/8 * selectedTrack) | ||
|
||
# Multiplies the trackGroup to 8 to get the index of the first track of that group | ||
trackFirst = trackGroup * 8 | ||
|
||
# Convert the sensitivity value received by the knob to be a normalized multiplier | ||
sensitivity = abs(-1 / (sensitivity - 64)) | ||
|
||
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)) | ||
|
||
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)) | ||
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. Offset should be |
||
|
||
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. """ | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Offset should be
config.KNOB_INCREMENTS_VOL * log(speed, 63)
instead ofconfig.KNOB_INCREMENTS_VOL * sensitivity
. Same thing goes for decrement.