gknilsen / alphanumerics

2 stars 1 forks source link

Indexing seems off, tests broken. #1

Open jhughes2112 opened 9 months ago

jhughes2112 commented 9 months ago

Hi! I have been implementing my own phase vocoder and decided to try to figure out what I'm doing wrong by looking at what others are doing right. So I grabbed your code to take a look.

What I noticed is that your test code in Form1.cs around line 75 where it says "Now compare inputList and outputList" doesn't actually check anything. They don't match up. It appears that the input length is 1024 but the PhaseVocoder is being constructed with 128 as the winLength. So I bumped that up to 1024. Now I am getting errors in the prepFrame function because it expects the signal array to be longer than the FFT-size.

I'm a little confused exactly how it's supposed to work, but I'm guessing most of the testing was done on a whole-audio-block in memory, where the signal array was fully contiguous? Any thoughts on how I could make it work properly when frames are arriving in realtime?

Thanks, JH

jhughes2112 commented 9 months ago

Actually, that particular test case is doing a 2x tempo change, so the output being shorter seems fine, but rather than condensing 8192 samples down to 4096, it ends up with 4212 and the rest are zeros out to 5184. When using that as input to the next test, it doesn't handle odd-length arrays at all. So I pad it out to a multiple of 1024. The tempo expands back to 8308 samples, and they are not "identity" or numerically comparable. Maybe they sound right, I haven't written that out to disk to check.

Anyway, details details... what I was hoping to understand is the relationship between the winLength passed into the PhaseVocoder in the last parameter, and what it actually expects as inputs. It seems strange for it to be a factor of 8 larger? Generally the window length is how many samples are going to be FFT'd and the hopSize is 1/4 of that for Hann windowing. So far, your code is the easiest to look at and digest, so I'd love to understand what I'm missing here, and maybe fix my own library up.

Thanks!