Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hifi-decode speed mismatch #117

Open
oyvindln opened this issue Dec 3, 2023 · 2 comments
Open

Hifi-decode speed mismatch #117

oyvindln opened this issue Dec 3, 2023 · 2 comments
Labels
Audio Related to HiFi-Decode or Audio Only Tapes bug Something isn't working

Comments

@oyvindln
Copy link
Owner

oyvindln commented Dec 3, 2023

There seems to be a slight issue with the output from hifi-decode not beeing entirely correct speed-wise

From discord:

09:11]rewolf: @oln I'm currently looking into the HiFi (mis-)alignement topic for sync captures, and I found something interesting. What I did was I added some code to hifi decode to record the hifi-rf-input stream position and the corresponding decoded audio output position. The good news is there is no sudden jumps or anything like that. But there is a (tiny) speed mismatch that leads to outputting less than expected decoded samples. The image shows the error accumulating over the course of that 27 min (PAL) tape, about 70ms in total.

I did a bit of math: the rf was sampled at 10MSps (8Bit) and for every 10000000 samples going into hifi decode, I would have expected to get 192000 (stereo) samples out. But its actually more like 191991.9 (rounded to one decimal), so about 8-ish samples short ...

Any idea where this comes from?

If I correct the hifi output by this drift, it seems to align with the linear audio I recorded, which would make fully automated alignment possible.

I attached the patch and added file for recording those positions just as a reference (based off fa841d0).

[14:38] VideoMem: I don't remember it well if i did that or not, but it could be the rational aproximation in the resampling.
There are two resampling stages.

One from input samplerate to ~8MHz and other at the end from ~8Mhz to audio rate. (endret)

[14:39]VideoMem: That's seems to be the accumulated error of the two

[14:53]VideoMem: I'll try omitting the rationalization of the scale factor and do the resampling by floating point.

@VideoMem
I'll try omitting the rationalization of the scale factor and do the resampling by floating point.
[17:29]rewolf: ahh yes, I was running into the same "rounding" issues when doing the auto alignment app, and I resorted to fractional math to get the error down predictable (endret)

[17:30]rewolf: I did some "back of the envelope" calculations here https://gitlab.com/wolfre/vhs-decode-auto-audio-align/-/blob/main/VhsDecodeAutoAudioAlign/Interpolation/ProjectionMisc.cs?ref_type=heads#L211 concerning the rounding error. maybe that gives some ideas

@oyvindln oyvindln added the bug Something isn't working label Dec 3, 2023
@harrypm harrypm added the Audio Related to HiFi-Decode or Audio Only Tapes label Dec 3, 2023
@VideoMem
Copy link
Collaborator

VideoMem commented Dec 5, 2023

Pretty sure the bug is here

limit_denominator(1000) there is losing precision.

The value of all max denominator limits should be increased.

@VideoMem
Copy link
Collaborator

VideoMem commented Jan 15, 2024

This should be solved on #119

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Audio Related to HiFi-Decode or Audio Only Tapes bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants