panda-official / TimeSwipe

PANDA Timeswipe driver and firmware

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

add sample rate setting

mkh-welsch opened this issue · comments

the 5-pol analog filter in the hardware is optimized for the 48kHz samples per second. anyways, if the user wants a lower sample rate, the original signal has to be digitally filtered before downsampling the values. this should be implemented in the driver.

this here seems to be a good starting point.
https://github.com/terrygta/SignalResampler

if we resample block-wise, there are artifacts at the start and the beginning due to the math behind resampling and filters, so it needs paddings from original data to overcome this problem. Here you take larger blocks (adding pads), apply resampling, and then cut the additional pad information in the result.

@iluxa we should add new method therefore. with resulting fps in Start callback then - default is 48k.

Initial implementation is on the branch issue_45
implementation is based on https://github.com/terrygta/SignalResampler
with padding

tested on RPi without triangular signal - CPU CORE usage is incremented about 10-15%
Future activities: test with triangular signal; memory copiyng optimizations

Tests with triangular signal:

Without resample
with 24K resample
with 5K resample

First without resample
Second with 24K resample
Third with 5K resample

@mkh-welsch expected result?

image

image

looks like the instability, we try to avoid with the padding. try to increase the padding size.

@iluxa : maybe dynamically increase the padding size with lower resample rate.

effect of not using paddings during resampling.
image

top: original without resample
middle: resampled without using padding logic
bottom: resampled with padding.

faec130
dynamic padding size is implemented

80c31d1
constant size slices

PR for merge
#62