-
Notifications
You must be signed in to change notification settings - Fork 76
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 envelope generator script #259
Add envelope generator script #259
Conversation
Don't forget to add your script to the central contrib readme! |
def update_display(self): | ||
if ticks_ms() - self.last_refreshed_display >= self.display_refresh_rate: | ||
#Save state to file | ||
self.save_state() |
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.
[optional] I would suggest instead moving this call closer to where the two state values change, inside change_sustain_mode()
and change_looping_mode()
. That will avoid unnecessary calls to save state when state has not changed. (I know PolyrhythmSeq sets a bad example, I need to fix that)
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.
done!
oled.vline(self.envelope_display_bounds[0], self.envelope_display_bounds[1], self.envelope_display_bounds[3], 1) | ||
oled.vline((self.envelope_display_bounds[2] - 1), self.envelope_display_bounds[1], self.envelope_display_bounds[3], 1) | ||
|
||
try: |
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.
[optional] Pro tip: you want to keep your try/except as tightly narrowed to the scope of where the exception is thrown. When you have this many lines inside of a try/except, you might have a line throw a ZeroDivisionError that you weren't expecting and that would hide the bug from you and make troubleshooting tricky. Additionally, it's not obvious to the reader where in this block the ZeroDivisionError might get thrown.
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.
fixed! hopefully the code is more clear now
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
Co-authored-by: Adam Wonak <adam.wonak@gmail.com>
…allen/EuroPi into add-envelope-generator
A simple envelope generator script:
din triggers an envelope (and sustains it if on asr mode)
k1 controls rise time
k2 controls fall time
ain is added to k2 to control fall time (i'm planning to allow ain to be routed to other parameters)
b1 changes mode between ar (Attack Release) and asr (Attack Sustain Release)
b2 changes mode between once and looping envelopes
The envelope is displayed as linear (currently) but the actual output is logarithmic, so works well for audio