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

Decoder - "d->biphase_tics[d->biphase_tic]" assembled incorrectly #60

Open
mungewell opened this issue Jul 29, 2020 · 2 comments
Open

Comments

@mungewell
Copy link

The function 'biphase_decode2()' is called twice for each bit in the LTC frame.
https://github.com/x42/libltc/blob/master/src/decoder.c#L307

Since 'biphase_tic' is increased each time, it overflows (is limited by '% LTC_FRAME_BIT_COUNT') and the array is first filled with the early bits and then overwritten with later bits in the frame.
https://github.com/x42/libltc/blob/master/src/decoder.c#L264

	d->biphase_tics[d->biphase_tic] = d->snd_to_biphase_period;
	d->biphase_tic = (d->biphase_tic + 1) % LTC_FRAME_BIT_COUNT;

Either the array should only be filled on the 2nd calling/phase of the bitstream, or the array should be bigger to hold all 1/2 phases.

@mungewell
Copy link
Author

Have a solution in process, but it looks nicer to store d->snd_to_biphase_cnt in the array. This wouldn't need to be float, but does no harm. The man page suggest this should be the case, rather than storing the computed period (which is not actually what that tic really did).

Data Fields:
           float biphase_tics[LTC_FRAME_BIT_COUNT] detailed timing info: phase of the LTC signal; the time between
           each bit in the LTC-frame in audio-frames. Summing all 80 values in the array will yield audio-frames/LTC-
           frame = (off_end - off_start + 1).

@x42
Copy link
Owner

x42 commented Jul 30, 2020

carry on.. but keep in mind that his library is used in production and also in some hardware solutions, so the API and ABI must not be changed in in compatible ways.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants