Hey everybody,
I am trying to find the most efficient and simple way to sustain a part of an audio clip. The ultimate objective is to have that sound play longer or shorter, depending on external parameter (e.g. play as long as the player presses a button).
To illustrate: I wish to play the sound file from the beginning, loop between A and B for as long as I want (maybe even a ping pong loop), and when done, continue playing from the same point through to the end.
My findings so far:
- I found this ADSR forum thread that talks about it a little more.
- Slicing the file to three parts and playing them as needed produces artifacts, and in any case I prefer to avoid this approach.
- I was hoping GetData and SetData would perhaps help me do it, but I didn’t figure out if it is true, and how to do it.
- I have tried an alternative approach, which has a long sample by default, and I fade its volume out prematurely, if a short sound is needed. This of course, loses any actual sample data that may be present at the real end of the sample.
If anyone can suggest a way to achieve this, it would be great.