Hi
I'm currently working on a sequencer, and wanted to know if anyone could help with how I could timestretch samples.
I'm using sfread~ to play sampled loops. Changing the playback speed changes the pitch, so I want to timestretch them so that I can do modulation on the fly without having to make a new loop.
-
How do you timestretch?
-
umm...not sure if anyone's made a simple external to do that yet, but i'll tell you the way i was doing it:
*first, give up on sfplay~ ...you wanna write your audio files into arrays, and then use tabplay~
*the way in which i was "timestretching" was a bit weird, and the effect was a bit different to a normal timestretch, but it worked nonetheless....
what i did was to get the sample length in bytes from the output of the [soundfiler] object, and then divide that by 32 to give the lentgh of 1/32 part of the sample
tabplay~ can be triggered with byte offsets, so i used a metro and simple counter to increase the byte offset by 1/32 of a sample every click, and then return to zero after 32 clicks.
this worked really well for timestrethcing down, and sometimes worked ok for timestretching up, but it could get a bit stuttery.
recently though, i've been really getting into just changing the pitch to keep things looping. not sure why, it just sounds better to my ears when things get pitched funny. -
You can use FFT analysis to acquire timestretching, although I don´t know exactly how it works. There´s quite some theory involved and one of the ways is the one which hardoff is referring to.
There are some free tools on the internet like soundhog, they can timestretch as well as pitch shift without stretching the length of a sample, maybe there´s some help file in it which can help you out....try to get some help on sound convolution theory I think it will help you out as well, but it is quite hard math. -
Thanks.
Kind of freaky, but I changed all the sfplay~ to tabplay~ shortly after I posted this, as tabplay~ seems to give a quicker and cleaner response than sfplay~. Don't know why, though.
I'll get right on, and post any results. Seems that timestretching is one the harder things to do, that many people require.
Oh, and going a bit off topic. Does anyone know of a place to post patches? I could be cool to get some respons of the stuff I've been working on. -
yeah there´s a patch section on the forum, it´s the second one or something i think. it says patch
-
_as tabplay~ seems to give a quicker and cleaner response than sfplay~. Don't know why, though. _
i think it's because sfplay~ plays the sound from disk, where with tabplay~ it's loaded into memory. does that sound right?
--zac -
em411 has lots of good patches
-
Check out the samples that MSP includes with the Pd distribution. There is one demoing the FFT stuff that has an excellent timestretcher in it. You can adjust the averaging window it uses to stretch and interpolate - I usually have it set to a 2000 sample window.
Ah, the file you want is I07.phase.vocoder.pd in the doc/3.audio.examples/ directory from the source .tar.gz file!
-
@sdbrown said:
Check out the samples that MSP includes with the Pd distribution. There is one demoing the FFT stuff that has an excellent timestretcher in it. You can adjust the averaging window it uses to stretch and interpolate - I usually have it set to a 2000 sample window.
Ah, the file you want is I07.phase.vocoder.pd in the doc/3.audio.examples/ directory from the source .tar.gz file!
Yeah, I was going to mention that too. I don't think it's possible to timestretch complex waveforms without some distortion, but with adjustable parameters you can adapt it to different files.
-
Even easier. Forgive me, I'm new to Pd so this will be in Reaktor speak.
You can do this with basic granular synthesis. Do to it Homebrew style you need three things. You need two ramp oscillators (phasors?) and a clock generator. The main ramp sets the play position in samples, but ONLY when the clock generator bangs. The other ramp oscillator (phasor?) determins the pitch, so this is basically what you have now, just a basic table read. When the clock gen bangs this pitch osc is reset.
The speed of the clock generator is in milliseconds, this is the grain time.
BOTH the oscilators are added together, this sum is your new play position in your table!
It works pretty well, I've implemented it in reaktor. Hope this helps. Any questions, email me.