stretching the sound?

Posts: 23
Joined: 2007.12
Post: #1
Is there any way to control the duration of a sound file.

say I have a sound object that last 0.5 seconds & sometimes I need it to be .25 seconds other times I need it to be .75 seconds so is there a way the stretch the sound?
Quote this message in a reply
Posts: 1,488
Joined: 2002.09
Post: #2
If you are using OpenAL this is pretty trivial as you can control the playback pitch as simply as you would the volume. Haven't looked at other APIs extensively, but I would suspect that controlling the playback sampling rate is not impossibly difficult with them either.

If you want the sound to be stretched, but not change in pitch, that is much harder.

Scott Lembcke - Howling Moon Software
Author of Chipmunk Physics - A fast and simple rigid body physics library in C.
Quote this message in a reply
Posts: 6
Joined: 2009.01
Post: #3
Pitching the sound will definitely alter it's length. If the pitch needs to stay the same you could break the sound up into a beginning/loop/end and trigger each when you needed to. Might be a lot of work for a 1/2 second sound though. Or a granular approach could work as well where you build the sound from lots of small grains.
Quote this message in a reply
Post Reply