Extending a waveform
Although it's not entirely clear to what you try to do (maybe there are better ways to accomplish your goal), I'll try to give some hints.

There exist "time stretching" techniques that can slow down a sample without changing its pitch, but they are not trivial to implement yourself. Some audio editors have plugins that support this.

As a poor man's implementation, if the sound has a single pitch, you can try something like the following (I've successfully used this in the past to extend a long, sung, single note):

First I cut the sound in three parts:

Sound -> | Begin | Middle | End |

Always cut at zero crossings.

Then, if you make "Middle" short enough, like around 0.1 seconds or so, you can repeat it a number of times times to stretch your sound a bit:

| Begin | Middle | Middle | Middle | Middle | Middle | Middle | End |