You can use the famous [url=http://sky.prohosting.com/oparviai/soundtouch/:1l0wmsvo]soundtouch[/url:1l0wmsvo] library and feed the data needed by this library in a DSP callback.
Or you can code it by your own, [url=http://www.dspdimension.com/html/timepitch.html:1l0wmsvo]here[/url:1l0wmsvo] is a good start.