-
Notifications
You must be signed in to change notification settings - Fork 26
Sync current state of analog controls on pedalboard load #114
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
Open
sastraxi
wants to merge
4
commits into
TreeFallSound:pistomp-v3
Choose a base branch
from
sastraxi:feat/analog-control-sync
base: pistomp-v3
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
11beee2
Add analog MIDI sync on pedalboard change
sastraxi 10becb3
Merge branch 'pistomp-v3' into feat/analog-control-sync
sastraxi 75443da
Avoid hasattr by moving send_current_value to base class
sastraxi 47efbfa
Add autosync and refactor send_current_value() -> initialize()
sastraxi 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 hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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 |
|---|---|---|
|
|
@@ -20,6 +20,7 @@ | |
|
|
||
| import common.token as Token | ||
| import common.util as Util | ||
| from pistomp.analogcontrol import AnalogControl | ||
| import pistomp.analogmidicontrol as AnalogMidiControl | ||
| import pistomp.footswitch as Footswitch | ||
| import pistomp.taptempo as taptempo | ||
|
|
@@ -46,7 +47,7 @@ def __init__(self, default_config, handler, midiout, refresh_callback): | |
|
|
||
| # Standard hardware objects (not required to exist) | ||
| self.relay = None | ||
| self.analog_controls = [] | ||
| self.analog_controls: list[AnalogControl] = [] | ||
| self.encoders = [] | ||
| self.controllers = {} | ||
| self.footswitches = [] | ||
|
|
@@ -104,13 +105,15 @@ def reinit(self, cfg): | |
| # reinit hardware as specified by the new cfg context (after pedalboard change, etc.) | ||
| self.cfg = self.default_cfg.copy() | ||
|
|
||
| self.__init_midi_default() | ||
|
|
||
| # Global footswitch init (callbacks and groups) | ||
| Footswitch.Footswitch.init(self.handler.callbacks) | ||
|
|
||
| # Footswitch configuration | ||
| self.__init_footswitches(self.cfg) | ||
|
Comment on lines
-112
to
-113
Contributor
Author
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. Same for this; already done below. |
||
| # Analog control configuration | ||
| for ac in self.analog_controls: | ||
| try: | ||
| ac.initialize() | ||
| except Exception as e: | ||
| logging.warning(f"Failed to initialize analog control {ac}: {e}") | ||
|
|
||
| # Pedalboard specific config | ||
| if cfg is not None: | ||
|
|
@@ -239,6 +242,7 @@ def create_analog_controls(self, cfg): | |
| midi_cc = Util.DICT_GET(c, Token.MIDI_CC) | ||
| threshold = Util.DICT_GET(c, Token.THRESHOLD) | ||
| control_type = Util.DICT_GET(c, Token.TYPE) | ||
| autosync = Util.DICT_GET(c, Token.AUTOSYNC) | ||
|
|
||
| if adc_input is None: | ||
| logging.error("Config file error. Analog control specified without %s" % Token.ADC_INPUT) | ||
|
|
@@ -248,9 +252,11 @@ def create_analog_controls(self, cfg): | |
| continue | ||
| if threshold is None: | ||
| threshold = 16 # Default, 1024 is full scale | ||
| if autosync is None: | ||
| autosync = False # Default to False | ||
|
|
||
| control = AnalogMidiControl.AnalogMidiControl(self.spi, adc_input, threshold, midi_cc, midi_channel, | ||
| self.midiout, control_type, id, c) | ||
| self.midiout, control_type, id, c, autosync) | ||
| self.analog_controls.append(control) | ||
| key = format("%d:%d" % (midi_channel, midi_cc)) | ||
| self.controllers[key] = control | ||
|
|
@@ -299,9 +305,6 @@ def get_real_midi_channel(self, cfg): | |
| pass | ||
| return chan | ||
|
|
||
| def __init_midi_default(self): | ||
| self.__init_midi(self.cfg) | ||
|
|
||
| def __init_midi(self, cfg): | ||
| self.midi_channel = self.get_real_midi_channel(cfg) | ||
| # TODO could iterate thru all objects here instead of handling in __init_footswitches | ||
|
|
||
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
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.
This just does the same as the "pedalboard-specific config" below.