I’m struggling to understand the output of the fl.convolution object. from my understanding of the source code it’s doing a frequency domain multiplication of the two signals, and is applying some form of scaling (part of which I believe occurs at SpectralProcessing.hpp [line 486]: 0.25 / (T)sizes.fft()). A similar process occurs for correlation I believe.
Comparing the results to what I would expect to be the equivelant functions in python and Matlab don’t quite add up to be the same, as I’ve demonstrated in this patch:
----------begin_max5_patcher----------
1825.3oc6Z01aaaCD9yo.8+.g6WZAhY4w2jTA5G19x9CLLfglhBEaZG0IKYn
WRSZw1u8cjTxww0wltQNIMa.IVhTj7tm6NduPou8xWbxnyKuxTOh7NxGHmbx
2vdNw0msmS563jQKRuZRdZsafiVXpqSmaFcZ2CaLW03d.jrpuh1EksM4lF2T
f9tyl5FX44edrjsZvKSalbQVw7OUYlz34EQrlxNkHkQ1KJl8WNmxHereR9ku
45kF+LFM5lmgTOqnm3bWm+8Keg8Jd4zfAZg4KHm9837q4zbSwcfU9VvpHd2X
U5vJiauHhBAqm9Ph27xzommVL+.ztJXWHVwTVPBwtKp3.Pri92AhgmDHlE.h
UIO1H9N27xnDfR3ThfRjThhRzTRDkDSIIzCYe8ts00NnqSb6nA4SqM1yxoMk
3H+mCAuIgfWkaWsleOf6SYctd2x.m+MND+rQmKC.ucd2djz4SJWrvTz7838O
RyaM0j4lBSUZiYJ4KYMWPVdcyEkEjIkSMu6rhyJxVrrrpgfLyxqIo0jhk1du
h7d7NZZE5Zx7Zf8FxqHSpL3xPRqpRulTNiboe8mUUtffZZxXzThcVA1cse1S
JqpL43bd8UmRv+Vfz78mMZVad9YidyJFNOqvLorsvw05sqaXaS2H1oe3Hv4.
1aKp8oWDmrtx4+.JfhKKyub6xebAuUGui76WXHnLeYaCIqlzfsrOgLMqFoLR
XqhJsh3W01lLDEHWXGWVANoZ5YEuh7K4MlphzlrKM4WeVgi4pmjs7ZZc17hz
bRGdmMqom8vQcSCGudGFGIGfwAO.iiH9Z1Ff.NBFGKZyaxpyylZpNjzHUAv8
cgV49VfPbHIRVm8U2SfjaHTU5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V.FBVHncpapbdLXgMjUa3OSyrNvTdWtBFrp0wR0wChoECm4ZXwdGPO.AE6kO
bwdgfh8BwGQSw.YA0NCs5ME09WrkPIW05HYJBAs+YyHjako4J+2GbhXUqGUl
FhtCkM+giEzAnr4p0U1tVGKKzfxCPbL2iDDG.r.L2.Q7ZtqcsNVlaA4tFFN2
0PPtqggqTIHH20aV6vvJjYgliZHYyzUvZ5xkWZpp6VCOww52+boaRwm5amU3
a6q3dTk4xr9on7ckVgEa2fUZ2V434QWo6JEejsX9ph1rdtvBeKoqatN+6JVt
HcgYsiM3WyaMi6OYSDwyRaya1PPkNYhonYRYtmG+.gQEPjVFgRKpVISXb6cI
1t.T3rdMXm1qCpvkvwPNh2SP2wzuR+ca81Fb5eZxyK+x930YkHY5Nj8OP.L.
fJgwhuQesEvDyUfCKQwPLXuAmjRpNFPocw4lpeqLe5OfP2JeYZK+oR3fxwx.
CRz2Wgdmop6HkrrZ8xT+FC2QO8xWfC4eAD7JvjA
-----------end_max5_patcher-----------
For the convolution at least I’m looking for output that just follows the equation in the notes of this function: https://numpy.org/doc/stable/reference/generated/numpy.convolve.html
The overall aim of this is to build an fl.yin~ object that follows a Python implementation that has been used for previous experiments which is why I’m really keen on equivelance if possible.
So there are two issues here - if the numbers in your patch are what you get out then the build you are working with is still producing incorrect results. I’m working with the most up to date branch on Mac which doesn’t have the same issues (see pasted patch below).It could be that the FFT is broken on master. However, my results are still different to the numpy examples, which I need to investigate.I can explain the correlation result much more easily than I can explain the convolution result, so let’s start there.
For correlation you have negative and positive lags. fl.correlate~ starts its output at lag zero, and then puts the negative lags after that, whereas numpy appears to place lag zero in the centre - thus the two results are just rotations of one another.
For convolution I suspect your numpy result is wrong, not least of all, because the output should be 19 values long and it isn’t so I’d advise you to check that:
----------begin_max5_patcher----------
1637.3oc2ZssaaiCD8YmuBB2WZART4Uco.8gceY+AVr.KpWTnHS6ntxTFRTo
wsn8aeGRJ63jn3vDKo3t.I1hTjZlyLCGdFZ88ylL8xx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Rvcg9gMyOMgt2AvPvwmb3ObD146UB96p.DrAvTZMCLJzB
J5.gQuWNeIT7Rm1knQvtzxwhxCGwCl4BfpzEtSmwPUxPpB9GnifD.qoXSelN
HgFpXXysgLzHJyPoxLJp8tIlO3vMhIccZNjwHrhG4xmRSFBy2AITQYiNgpn9
pZIJm+5TsjGAcPkuPjmoYDd6UbCsdBM.pKtqPMJcLJGhRbj2CEidrFI5WVx6
zvvSLx6iAYm1Xkwk7NgLRj2a+UCOE3tSniF2c2IychQcmvFgnYBleZRcmfGC
p6DdxIJ0c1HPw5UB8aOH9W.wc9XXUhaIRE8LrJ1gXOIx68RyXEio+6ZppKap
x1p6ai2Q2Jo4xZct4G4.1N31AAvGQ1MlxJCkhG08zuRlemAsSz3iSzDODsYe
.yfNNIQ8QRr9PRLejzcs4qxmutLWoaicBwABCgJ6xRFlrqUua+8QWYc64Oxf
NtOVov6Du2oUhJXtpEusUuak7RWi51LQGdQad0xdpfIpv8Rgkv10p2coI9Xl
DOsKMLt82PguqUu6R8RWiGhHepOoaojdHSD0mrqTdeHIextR6irqTeVPXN12
mZAgv8xR1lc01puCx7SWCGjfLgOhNZHnS3kn4ICAch6YKO.pO5vvHexejzCR
h4IsviVN9jrfI5CIE6CjvtXyiRRdsuceX739HI9AYyvhb6LSbuC2I7csNVcy
ms5LuetGR2hb6D2paw6Zcj5lvm8BY8wdgBu1K7gUZ3pqKc85qkU0si1JDnX2
uTZyYYO5dvjobMY1lUxqy2Nd6Kd3zzJnbSMTqYSkqPzahc+LJSMk8VoZxay8
Bv6r1BVuWsjpzUx8ps92KZjWzdvf.hVj1TnuqYHMKSpzYkENU6SHb.iDExi.
XFDJ3IXp4pDSWDH.3VG54sV2JX92u1Y2IZuMc89di6of+srnn7qGVEWTBBn8
jo+Dh.7REIXb7NOUGPHlJHVDDEC0pat.lifK5U.zr5RY0eTVL+YagMFSbnQs
DIThvpoDLII7kagg47iy9Oz8tMCA
-----------end_max5_patcher-----------
Sorry I should have updated this thread after the discussion over on github (https://github.com/AlexHarker/FrameLib/issues/60). The patch I posted over there is also updated and accounts for both the wrong numbers quoted from Numpy for convolution and the understandable discrepency between outputs of FL and Numpy for correlation.
At the moment I believe the master branch is still broken and I am currently using the solution I proposed (https://github.com/AlexHarker/FrameLib/pull/61) to fix the results of both objects. As you mentioned in the issue you’ve also fixed the issue in the “time-smoothing-decisions” branch, but I’m having some issues with that branch on Windows (despite it appearing to build correctly) which I’ve highlighted in this issue: https://github.com/AlexHarker/FrameLib/issues/62
Ah - sorry - I just got a notification and thought this was more recent!