kfrlib / kfr

Fast, modern C++ DSP framework, FFT, Sample Rate Conversion, FIR/IIR/Biquad Filters (SSE, AVX, AVX-512, ARM NEON)
https://www.kfrlib.com
GNU General Public License v2.0
1.65k stars 253 forks source link

resample streaming #72

Closed mipac closed 4 years ago

mipac commented 4 years ago

Hi, Could you give me an example showing resampling a stream of samples?

best regards,

dancazarin commented 4 years ago

Hi, Here is an example of resampling. It processes audio by blocks in cycle. Cycle body is what should be done in your block processing function. https://github.com/kfrlib/kfr/blob/master/tools/sample_rate_converter.cpp

Because with resampling the sizes of input and output buffers differ, there are two different approaches:

Both are possible with KFR using output_size_for_input and input_size_for_output functions.

Note that resampler has delay, get_fractional_delay function returns it (may be fractional).

mipac commented 4 years ago

I haven't seen that example... sorry for noise...

It's difficult to understand the use of univector, for example the use of .ref() after the slice() etc... Do you have pointer to a tutorial about that fundamentals ?

best regards

dancazarin commented 4 years ago

ref() converts univector<>&& returned by slice() to univector<>& required by resampler<>::process. It's just requirement of C++.