linearize fade-ins on mix points #1001
Comments
|
maybe it's also worth saying up front: if we were dealing with fixed endpoints, this would be a simple problem of using ramps or exponential segments and transforming them arbitrarily. but the application has other requirements:
so... i'm not really seeing a good way to satisfy all this with "classic" envelope constructs. intuitively, it feels like we should be able to just construct an IIR filter with (approximately) a logarithmically-shaped impulse response, which would be ideal. so that's what i'm looking at right now. would be curious to hear if anyone has encountered such a thing before. |
|
... nah, don't think so |
|
ok well, initial explorations actually look kinda promising... i'm surprised made a small python script to design IIR filter coefficients matching a desired impulse response, by numerical optimization. with a 3rd-order filter, Nelder-Mead search on the 6 coefficients gives -80db mean-squared error between target and actual IRs. (2nd order is much worse, 4th order isn't significantly better.) still need to try incorporating this into an actual signal processor class to see if it does what i think it will. (execute this filter if value is increasing, equivalent simple onepole if decreasing, should give perceptually linear and equivalent fadeins and fadeouts.) if that looks ok, the last challenge is making this modulateable. unless some smart person can come with an analytical solution (entirely possible), i guess i would be reduced to performing many searches for different time constants, and using 6 lookup tables to get the coefficients at runtime. |
|
hrm, well the filter design approach is super interesting and does actually work. and now there's a tool for designing IIR filters based on desired impulse response, if anyone wants such a thing. but after evaluation i don't think it's the right solution here, mainly cause i don't think it's performant enough to justify its simplicity. the "log impulse" filter requires something like 30 operations per sample, and we have something like 20 of these things in at that cost, we can do a classic envelope thing instead:
this gives us flexibility (e.g. maybe raised-cosine fades are nicest) and is straightforward. possible downside is that it's relatively hard to maintain continuous derivatives, but i'm not sure that matters so much unless the fades are super long and liable to overlap. |
problem: level smoothing is implemented with a simple 1-pole lowpass on the linear amplitude.
for fade-outs, this is fine; the exponential decay becomes a linear loudness ramp
but for fade-ins, the exponential attack becomes a doubly-exponential loudness ramp:


so... need to make a slightly smarter smoother class particularly for levels, where ramp-up is logarithmic, and ramp-down remains exponential. (preferably without killing performance by performing lin-log conversions each sample.)
The text was updated successfully, but these errors were encountered: