time dilation in fft domain

Discussion about the DSP Dimension's articles, tutorials and code.

Moderator: neuronaut

time dilation in fft domain

Postby threedaygoaty » 26.01.2010 12:49

Hi there,
I have enjoyed this forum as a reader and recently read up on DSP for time dilation of audio.
I did find a lot about it and I got so far as coding for FFT and iFFT in Perl.
However, I did not do audio physics at school and was hoping to find at least a pseudo code version of
a time dilation transform on the FTT data. I found some equations and some matlab code but it did not work for me.
If anyone can possibly give me some pointers this would be great. I am not good at converting complex math to Perl but I am a competent perl coder.
Kind regards,
TDG
threedaygoaty
 
Posts: 3
Joined: 21.01.2010 05:57

Re: time dilation in fft domain

Postby neuronaut » 26.01.2010 13:21

Hi, and welcome to the forum.

Could you be a bit more specific as to what kind of process you're referring to? According to widely accepted terminology "time dilation" is the effect that occurs when you reduce the sample rate of a signal (decimation) while keeping the playback sample rate the same.

This will cause the time scale of the signal to be dilated, which results in a higher pitched sound (faster playback) as the peaks and valleys of the waveform will come to lie closer together. While it is possible to achieve this process in the frequency domain it is usually more efficient to operate directly on the time domain representation of the signal.

HTH,
--smb
Free DSP tutorials by Stephan M. Bernsee at http://www.dspdimension.com
"There are 10 types of people in this world: those who understand binary, those who don't"
--Unknown
neuronaut
 
Posts: 1098
Joined: 17.11.2005 09:15
Location: Mainz, Germany

Re: time dilation in fft domain

Postby threedaygoaty » 27.01.2010 13:18

Thanks Neuronaught,

I want an audio file to play more slowly without affecting its pitch.
I got so far as converting the sample to a length a power of two and then passing the samples through a Perl FFT library.
I read that each sample in the FFT domain needs to be multiplied by a exponent of a factor with a linear phase. I tried a few matlab code samples for this but I was unable to fully understand what to do.
I did learn that the FFT has a certain structure and that the second half of it may not need to be modified.
I'm probably a long way from my goal!
threedaygoaty
 
Posts: 3
Joined: 21.01.2010 05:57

Re: time dilation in fft domain

Postby neuronaut » 27.01.2010 13:24

Ok, so you're referring to the process called "time compression/expansion", or more colloquially called "time stretching".

The easiest way to achieve this without writing lots of code or reading books on the phase vocoder is to use our smbPitchShift() code to change the pitch and use sample rate conversion to change its pitch back to normal. This will modify pitch while maintaining speed and the subsequent sample rate conversion will change this into a speed change without affecting pitch.

HTH
--smb
Free DSP tutorials by Stephan M. Bernsee at http://www.dspdimension.com
"There are 10 types of people in this world: those who understand binary, those who don't"
--Unknown
neuronaut
 
Posts: 1098
Joined: 17.11.2005 09:15
Location: Mainz, Germany

Re: time dilation in fft domain

Postby neuronaut » 27.01.2010 15:34

Hi again,

I've created a little hack based on our smbPitchShift example project that does time stretching instead of pitch shifting. Feel free to check it out, maybe it helps you create a Perl version:

http://stephan.bernsee.com/smbPitchShif ... S_Hack.zip

Cheers
--smb
Free DSP tutorials by Stephan M. Bernsee at http://www.dspdimension.com
"There are 10 types of people in this world: those who understand binary, those who don't"
--Unknown
neuronaut
 
Posts: 1098
Joined: 17.11.2005 09:15
Location: Mainz, Germany

Re: time dilation in fft domain

Postby threedaygoaty » 28.01.2010 14:16

Dear all,

code sample>
/* map delta phase into +/- Pi interval */
qpd = tmp/M_PI;
if (qpd >= 0) qpd += qpd&1;
else qpd -= qpd&1;
tmp -= M_PI*(double)qpd;

I am confident I can make this work in Perl. Let me have a go and I will post back what works
for your interest. I appreciate Perl is not a performance language and I will code it in basic Perl, the more ambitious
Perl coder might try PDL.

Thank you again,
TDG
threedaygoaty
 
Posts: 3
Joined: 21.01.2010 05:57


Return to The DSP Dimension

Who is online

Users browsing this forum: No registered users and 0 guests

cron