Reputation: 2850
I've been trying to add release (or decay) time on a sine wave generation project, taking this example as ground. What I basically want is not the sound to cut off so drastically and add some release at end when I stop generating it.
How can I achieve it?
Upvotes: 0
Views: 240
Reputation: 70703
Start some number of samples, say 5 to 50 milliseconds or your decided release time, before you want silence, and multiply your sine wave samples by a ramp that decreases from 1.0 to 0.0 over that time interval. Linear decrease is OK, but a raised cosine (0.5 + 0.5 * cos(pi*t)) might be better.
Upvotes: 1