calculate_sustain now respects default attack, decay, and release#3514
Open
mschubmehl wants to merge 2 commits into
Open
calculate_sustain now respects default attack, decay, and release#3514mschubmehl wants to merge 2 commits into
mschubmehl wants to merge 2 commits into
Conversation
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The following four notes should all be played with
attack: 0, decay: 0, sustain: 0, release: 1.The first three correctly release over one beat, as expected, but the last one plays over two beats with
attack: 0, decay: 0, sustain: 1, release: 1. This is because thesustainvalue calculated incalculate_sustain!only takes into account explicit arguments and thread-local defaults, ignoring the defaults for the underlying synth. Aftercalculate_sustain!convertsduration: 1intosustain: 1(incorrectly assumingattack: 0, decay: 0, release: 0), the defaultrelease: 1is applied, resulting in a note that lasts two beats.This is easily fixed by passing the
defaultsvariable intocalculate_sustain!, where it can be queried forattack,decay, andreleasevalues that are not specified in the explicit argumentsargs. With this change, all four notes above sound the same, as expected. Note that this will result in a user-visible change to the way a piece plays, but only if they do not specifyrelease, either using an explicit argument or something like the thread-localuse_synth_defaults.I noticed this as I was trying to understand why
play_pattern_timedwithout areleaseargument produces so much overlap, so it's worth noting that this change carries through to something likeWith this change, there is no longer an extra beat of overlap between the notes, so it now sounds identical to the following, as expected:
Finally, the examples in the documentation for
play_pattern_timedshould also say that it's equivalent to settingdurationfor each note played, notsustaindirectly. This was true before and after my change.Thanks to all of you for your amazing work on this project!