4
$\begingroup$

What is the difference (if any) between PSOLA (Pitch Synchronous Overlap and Add) and TDHS (time domain harmonic scaling) time-pitch modification algorithms?

$\endgroup$
1
  • 2
    $\begingroup$ it's gonna be hard to spell out a nice analytical answer. with accurate math and consistent notation. but i'll work on one tonight. in my book, one shifts the spectral envelope or formants with the pitch and the other does not. so the latter is better suited to shifting vocals unless you like Chipmunkization (or Munchkinization). $\endgroup$ Commented Dec 1, 2015 at 23:27

1 Answer 1

4
$\begingroup$

OK I did the two some time ago, TDHS in principle just apply time scale modification and to change the pitch do you need apply interpolation (resample) and it will shift the spectral envelope.

For TDHS is hard to find some paper that teach how its really works, I learned the math and how it works in the Burazerovic Dzevdet paper:

$N_p$ is defined as the local Pitch Period

$\alpha$ is the time stretch factor

$N_c$ is the cross-fade length, here half the length of the window.

To compress the time $\alpha < 1$ the equation is:

$$ \begin{align} N_c & = \operatorname{round}\left(N_p\frac{\alpha}{1-\alpha}\right) \\ & = \left\lfloor N_p\frac{\alpha}{1-\alpha} + \frac12 \right\rfloor \\ \end{align} $$

where "$\lfloor \cdot \rfloor $" is the floor() function returning the most positive integer not exceeding the argument.

The illustration from Dzevdet paper show how the algorithm works using a triangular window (n. b. 4 cycles become 3 and the period and fundamental frequency (pitch) of the waveform is not changed):

enter image description here

Now to expansion $\alpha > 1$ (note 3 cycles become 4 and the period and fundamental frequency (pitch) of the waveform is not changed):

$$ \begin{align} N_c & = \operatorname{round}\left(N_p\frac{\alpha}{\alpha-1}\right) \\ & = \left\lfloor N_p\frac{\alpha}{\alpha-1} + \frac12 \right\rfloor \\ \end{align} $$

enter image description here

OK here my simple demo how TDHS works to compress:

alpha=0.5;
f=735;
Fs=44100;
signal= 0.9*sin(2*pi*f/Fs*(1:1000)); 
signal = signal';
period= 60;
out2=[];

Nc=round((period*alpha)/(1-alpha));
nsamples = length(signal);

ii=1;
out2=[];
while ( ii <= nsamples )

    if ii+Nc+period-1 > nsamples
        %OK I'm lost some samples in the end of out2 output signal, no problem just tests 
        HI=000 %debug 

    else

        frame = signal(ii:ii+Nc+period-1);
        frame1=frame(1:Nc) .* (1-linspace(0,1,Nc))';
        frame2=frame(period:Nc+period-1) .* linspace(0,1,Nc)';
        OUT = frame1+frame2;
        out2 = [out2' OUT']';


    end

    ii = ii + Nc+period-1

end

plot(out2)

Course this is just to show for you the concept, I used fixed integer period $N_p = 60 (44100/735)$

Now To PSOLA things will different, Usually you need to use the Pitch information to mark the sign to the glottal instants you can change the Pitch and the time (no formants change here) .

Take a look in my answer about PSOLA here


$\endgroup$
5
  • $\begingroup$ hey, sorry for tripping over other edits, eder. i rolled it back. i just wanted to touch up a little bit of $\LaTeX$. $\endgroup$ Commented Dec 2, 2015 at 19:26
  • $\begingroup$ No problem @robertbristow-johnson thanks for it :-) $\endgroup$
    – ederwander
    Commented Dec 2, 2015 at 21:18
  • $\begingroup$ i made some changes to this answer (still working on my own). note that the slanted lines depicted are much better called the "cross-fade length", not the "window length". a "window", in this case can be thought of as the concatenation of a fade-up function followed by a fade-down function. using these linear cross-fades, the window would be either a triangular window or a trapezoidal window. if the window is triangular, one must begin another cross-fade immediately after the previous cross-fade was completed. $\endgroup$ Commented Dec 6, 2015 at 3:35
  • $\begingroup$ i have some concern about the accuracy of the second drawing for time-expansion. what is really happening here is that the 3 cycles from sample 0 to about sample 141, those three cycles are becoming four cycles from sample 0 to sample 188. the value of the output sample at y[188] is the same as the value of the input at x[141]. the use of solid and dotted lines for the waveform are actually misleading. it is not the two inner cycles being cross-faded into the three inner cycles. $\endgroup$ Commented Dec 6, 2015 at 4:22
  • $\begingroup$ @robertbristow-johnson i can send to you my complete code based in Burazerovic Dzevdet paper, if have you interest please send me an email $\endgroup$
    – ederwander
    Commented Dec 6, 2015 at 5:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.