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
Lb302: Consistent decay in time #7230
Lb302: Consistent decay in time #7230
Conversation
The previous implementation of Lb302`s decay used a fixed decay factor that was multiplied with the signal until the minimum threshold of 1/65536 was crossed. This fixed factor resulted in different lengths in time for different sample rates. This is fixed by computing the decay factor by taking the sample rate into account as well. The new static method `computeDecayFactor` computes the factor that is needed to make a signal decay from 1 to a given attenuation over a given time. The parameters used in the call to that method in `Lb302Synth::process` have been fine-tuned such that, at a sample rate of 44.1 kHz, they result in a factor very close to the previous hard-coded factor of 0.99897516.
This seem to work fine but I bumped into a couple of issues that makes the PR a bit hard to test. |
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.
Looks good. Tested, exports fine at different sample rates. Fine that is, except from the issues reported earlier in the thread.
@zonkmachine, thanks for testing! The phasing issue will likely be caused by the attack which is still hard-coded to the following value in the constructor:
The attack code looks a bit more complicated, so I am not sure if it can be fixed in the same way. It already seems to somewhat take the sample rate into account though:
|
The phasing issue seems to be already present in
Edit: the wobbly start at the 192 kHz export is caused by the filter which is excited with a step. See results about the band-limited oscillator below. The filter does not seem to be aware of sample rate nevertheless. |
OK. I'm not sure what all this means but none of it seem really related to this PR. |
It seems that the problem with the phase is caused by the Lb302 instance keeping some state. I have exported two times at 192 kHz. With the first export the signal starts at 0 (phase 0). The second time it starts "in the middle" as seen in the screenshot above. |
Yes, it indeed seems unrelated. Shall I merge this one? |
Yes. |
The previous implementation of Lb302`s decay used a fixed decay factor that was multiplied with the signal until the minimum threshold of 1/65536 was crossed. This fixed factor resulted in different lengths in time for different sample rates.
This is fixed by computing the decay factor by taking the sample rate into account as well. The new static method
computeDecayFactor
computes the factor that is needed to make a signal decay from 1 to a given attenuation over a given time.The parameters used in the call to that method in
Lb302Synth::process
have been fine-tuned such that, at a sample rate of 44.1 kHz, they result in a factor very close to the previous hard-coded factor of 0.99897516.