maxim-zhao / SidWizPlus

Oscilloscope view audio renderer originally based on SidWiz
MIT License
182 stars 3 forks source link

Add autocorrelation based trigger #2

Open maxim-zhao opened 5 years ago

maxim-zhao commented 5 years ago

From @maxim-zhao on October 18, 2018 6:6

Copied from original issue: maxim-zhao/SidWiz#2

nyanpasu64 commented 5 years ago

I develop ovgenpy, a related program based around an advanced correlation-based trigger. The main algorithm is located at:

https://github.com/jimbo1qaz/ovgenpy/blob/master/ovgenpy/triggers.py#L154

It only uses autocorrelation to adjust windowing, not to prioritize jumping by multiples of the period. But I hope to use the period someday (prioritize jumping by even multiples of the period to avoid octave errors).

If you port this algorithm to sidwizplus, I may be able to retire ovgenpy (which has graphing performance issues and doesn't have a gui yet).

maxim-zhao commented 5 years ago

My issue is that my mathematical grasp is not great :) I've implemented a dumb brute force correlation algorithm with weighting to prefer central matches, but it is not working (presumably due to a bug in the implementation, I'm working through it now) and horribly slow. I've read some stuff about faster autocorrelation computation via FFT but not managed to get far with it due to not having the maths to back it up - my last foray into this kind of thing was about 15 years ago and that mostly consisted of using statistical software to do the heavy lifting.

nyanpasu64 commented 5 years ago

I use numpy/scipy to do the fft correlation, I don't know how the fft works either ;)

To fix your trigger, you could use my unit tests (test_trigger and test_trigger_stride are good, and you can use my wave files too).

https://github.com/jimbo1qaz/ovgenpy/blob/master/tests/test_trigger.py#L39

maxim-zhao commented 5 years ago

I think there are some issues with the way I'm doing it - admittedly, I'm trying to start with the basics, which may explain the issues:

I suspect the answers to a lot of this lie in what you've one already,