0
$\begingroup$

I want to simulate the play-rate change function of a modern digital sampler. For the purpose I have constructed a sinc-resampling based algorithm of my own which changes the play-rate of a digital audio signal.

There is some issue with the algorithm, as the output of the algorithm is far from nulling with the output of my sampler software, when same play-rate is applied. In particular, the high-frequencies do not null. The audio produced by the sampler and my algorithm sounds identical and the magnitude of the FFT is extremely close, so the issue seems to be with the phase. Why does the algorithm not produce similar output to my sampler, in specific is there some error that introduces phase-shift?

The algorithm is simple $y_i$ being the i+1th sample, $n$ the total amount of samples and $a$ the play-rate:

$$f(x)=\sum_{i=0}^{n-1}y_i \text{ sinc}(x-i)$$

$$g(a,x)=f(ax)$$

And the ouput can be had as $\{g(a,0),g(a,1)...g(a,n-1)\}$.

Python code:

import numpy
def ratechange(data,rate):
    Y=numpy.zeros(len(data))
    for i in range(len(data)):
        for j in range(len(data)):
            Y[i]+=data[j]*numpy.sinc((-j+i*rate))
    return Y
$\endgroup$
8
  • $\begingroup$ I'm sorry but the question is a bit ambiguous (to me at least). Please very clearly differentiate between analog signals, sampled signals and digital signals. Also what's a play-rate? Probably not the sampling rate at the input,but the one at the DAC output? Then I assume you talk about a cassette play rate (rotation speed) simulation algorithm? What's an inverted output? Please be more clear on your eventual purpose and your intended strategy to achieve it. $\endgroup$ – Fat32 Dec 27 '17 at 23:54
  • $\begingroup$ @Fat32 Playrate is the speed at which a signal is played back, so 1 = original speed 2 = twice the speed and so on. Inverted output is the output multiplied by -1. You got the premise right, except I am not trying to emulate a tape, but a completely digital sampler running similar algorithm based on sinc interpolation. Since the result is far from nulling with the sampler I am wondering if there is an issue with the algorithm (particularly whether there is some flaw which adds phase-shift). $\endgroup$ – Dole Dec 28 '17 at 0:23
  • $\begingroup$ ok. fine. According to your description rate = 2 seems half speed and not twice the speed. can you replace rate with 1/rate and try? $\endgroup$ – Fat32 Dec 28 '17 at 0:43
  • $\begingroup$ @Fat32 It should be 2 = twice the speed. But yes I have made sure that the speed is in fact the same by checking the FFT magintude and time domain plots of the signals + listening to the output and even trying to adjust the rate slightly (even worse results). $\endgroup$ – Dole Dec 28 '17 at 1:07
  • $\begingroup$ In your sinc function interpolator the quantitiy rate is used in place of $ T_{out}/ T_{in}$ where $T_{out}$ is the output playback period and $T_{in}$ is the input sampling period. Therefore rate = 2 means, $2 = T_o / T_i$ hence $T_o = 2 \cdot T_i$ hence output play-back period is two times the input sampling period, which means output speed is half. Please make sure your setup. $\endgroup$ – Fat32 Dec 28 '17 at 1:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.