The left edge is ok, but at the right edge you see something strange. This is a magnified part of the right edge of another case:
Some samples before the right edge, the fadein turns into a fadeout all of a sudden. It really is not audible, it's only 19 samples long, but I guess in some cases it will be audible.
I'm using the pwlv function to shape an envelope for the volume (or amplitude or whatyoucallit). Here's the whole code:
- Code: Select all
;name "Soft zeroing"
;action "Do the thing..."
;control fade "Fade" real "ms" 10 1 500
(setq percnt (/ (/ fade 1000.0) (/ len *sound-srate*)))
(setq a (pwlv 1.0 percnt 0.0 (- 1.0 percnt) 0.0 1.0 1.0))
(mult a s)
So I have a slider to set the length of the fadeout and fadein, between 1 and 500 milliseconds. Then some math and stuff to turn it into a percentage (um... from 0 to 1, not from 0 to 100, but you get the idea). The whole pwlv line should create the envelope for me going through (0, 1) (l, 0) (r, 0) and (1, 1) where l and r would be the end time of the fadeout and start time of the fadein.
My code fails at the far right edge. pwlv doesn't get it right. It adds a fading to zero as a last point. What's going on here?