Forum Rule: Always post complete source code & details to reproduce any issue!
Page 6 of 6 FirstFirst ... 4 5 6
Results 126 to 140 of 140

Thread: Audio Library for Linear Timecode (LTC)?

  1. #126
    Senior Member
    Join Date
    Dec 2015
    Posts
    177
    Hi Frank,

    I've been doing a bunch of testing with the LTC library, and I've noticed something. It works perfectly when playing audio over USB. But...less so when playing audio in via Line In on the audio shield.

    Here's a link to a 1 minute file I have been testing with:

    https://www.dropbox.com/s/7celrklbl9...ns_30.wav?dl=0

    When I play this back via USB to the Teensy (3.2 for the moment) I can read the LTC and when I print it back via the serial port I see every frame, like this:
    01:02:37.25
    01:02:37.26
    01:02:37.27
    01:02:37.28
    01:02:37.29
    01:02:38.00
    01:02:38.01
    01:02:38.02
    01:02:38.03

    When I play back from the analog of my computer to the line in on the audio shield, I get this:

    01:02:13.00
    01:02:13.02
    02:04:26.01
    01:02:13.04
    01:02:13.05
    01:02:13.03
    01:02:13.09

    So clearly I'm not managing to decode each frame, and I get spurious misreads every once in a while.

    I put a peak detector into my program so I can verify that both are coming in at the same level, and we are good there. I'm not exactly sure where to start on next. Any thoughts?

    As I'm just using the decoder as a display for the moment the missing frames aren't the worst, I can't see individual frames anyway, they go by too fast. Those spurious reads way off in the middle of nowhere aren't great though, they cause the display to jump which is quite visible as a glitch.

    Thank you!

  2. #127
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    7,002
    Yup, seems to to be the startbit problem. It is repsonsible for exactly this : "doubled" time. Seems to work not reliable if the time between two frames is longer /shorter than the program is able to compensate.
    Or maybe it takes a little too long to set everything right for the first bit. You can test it with a faster Teensy. Please report back if it helps.

    You may want to add some plausibility checks to detect this condition (doubled time) and shift the whole info one bit back.

  3. #128
    Senior Member
    Join Date
    Dec 2015
    Posts
    177
    Hi Frank,

    I will check it out. I just got some new T4 in so I should be able to try them at some point.

    I had thought about adding a plausibility check and just not displaying the frame if it didn't seem to be from the right time, I will look into implementing that.

    Do you have any theories on why this only happens on the analog input? The exact same file plays ok via USB.

    Thanks!

  4. #129
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    7,002
    No, not really.
    Might be a signal degration or too high or low levels.

    If you detect the "doubled" values, just shift it one bit to the right and you'll get the correct number. ( >> 1)

  5. #130
    Senior Member
    Join Date
    Dec 2015
    Posts
    177
    Hi Frank,

    Just had a minute to solder up a T4 with an audio shield and test. I'm seeing similar results over line in:

    01:02:05.19
    01:02:05.21
    01:02:05.22
    02:04:10.01
    01:02:05.24
    01:02:06.01
    01:02:06.03
    01:02:06.04
    01:02:06.06
    01:02:06.07
    01:02:06.08
    01:02:06.09
    01:02:06.15
    01:02:06.17
    01:02:06.18
    01:02:06.19

    Via USB it looks like this:
    01:02:03.18
    01:02:03.19
    01:02:03.21
    01:02:03.22
    01:02:03.25
    01:02:03.27
    01:02:03.28
    01:02:04.00
    01:02:04.01
    01:02:04.03
    01:02:04.04
    01:02:04.06
    01:02:04.07
    01:02:04.10
    01:02:04.12
    01:02:04.14
    01:02:04.15

    Still missing some frames, but no doubles. Not the worst for my purposes though.

  6. #131
    Senior Member
    Join Date
    Dec 2015
    Posts
    177
    Just a further note, I went back to my T3.2 setup and tried the ADC input. I'm seeing more glitches there, even a few quadruples! I played with input level a bit, and there does seem to be a sweet spot where the errors get less frequent.

    I'll keep playing with it, but wanted to share my findings. I had a look at your code and while I have a vague understanding of where you are decoding the stream, I am not enough of an expert to try to figure out if I can improve something to help with this issue.

    Thanks!

  7. #132
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    685
    Interesting, I wonder if anything changed since I tested it a long time ago, I don’t remember seeing any missed or doubled frames, but I didn’t think to look for them either. I’m going to setup my rig again later and actually pay attention to glitches this time.

  8. #133
    Senior Member+ Frank B's Avatar
    Join Date
    Apr 2014
    Location
    Germany NRW
    Posts
    7,002
    Feel free to change whatever you want (and do a Pullrequest)
    From the beginning on, the code was meant as a starting point only, not a complete reday to use application.

    I will be not here for some weeks, maybe months. But I'll keep watching github.

  9. #134
    Senior Member
    Join Date
    Dec 2015
    Posts
    177
    vjmuzik - I'd love to see if you're seeing similar results to what I am. If the link above to the file I am using to test doesn't work for some reason, just let me know.

    Just to recap, I am seeing this on the analog inputs. While the USB input does sometimes miss frames, I don't see the doubling effect.

    Frank - I hope you are ok! If I ever manage to figure things out to a level that I can to a PR, I will. You happen to be a much better programmer than I though!

  10. #135
    Senior Member vjmuzik's Avatar
    Join Date
    Apr 2017
    Posts
    685
    I can test the audio file, but I have a Sync I/O that’s known good and it’s what I used last time.

  11. #136
    Senior Member
    Join Date
    Dec 2015
    Posts
    177
    I'd be very curious to see if the Sync I/O worked ok and the audio file didn't. Maybe that could help narrow down where this problem is creeping in.

  12. #137
    Junior Member
    Join Date
    Aug 2017
    Posts
    11
    hello
    I am interested on a LTC (audio) to MTC (digital ) converter, if somebody could jumpstart me on the argument would be very kindly.
    thank you in advance

  13. #138
    Senior Member
    Join Date
    Jul 2020
    Posts
    460
    Quote Originally Posted by Frank B View Post
    Before I do something meaningless. :
    The audio library uses 128 samples per block by default (but there is the possibility to use shorter blocks). At about 44.1 kHz this means 128*1/44100Hz = ~2.9ms per block. The output will therefore be inaccurate by at least this amount (possibly twice as much). Can you live with that?
    If not, the audio library may be not the optimal place for it.
    Why any inaccuracy? Single-sample granularity is just a case of returning the sample number for each timestamp,
    or you can generate a click on a generated click-track stream to provide synchronization to the
    sample granularity. You won't see more than one click per block so each click has an unambiguous timestamp.

    By also recording the sample number of the latest two timestamps you allow easy time interpolation by sample number.

  14. #139
    Senior Member
    Join Date
    Dec 2015
    Posts
    177
    Quote Originally Posted by rozzilla View Post
    hello
    I am interested on a LTC (audio) to MTC (digital ) converter, if somebody could jumpstart me on the argument would be very kindly.
    thank you in advance
    I've never done this and I'm not really sure how MTC actually works at a low level. However, I can say that using this library you will be able to derive the incoming time code. I did a quick google search and there do seem to be some projects for Teensy and Arduino that talk about being able to send MTC. Perhaps you can graft these two ideas together to make the converter you're looking for!

  15. #140
    Junior Member
    Join Date
    Aug 2017
    Posts
    11
    Quote Originally Posted by jkoffman View Post
    I've never done this and I'm not really sure how MTC actually works at a low level. However, I can say that using this library you will be able to derive the incoming time code. I did a quick google search and there do seem to be some projects for Teensy and Arduino that talk about being able to send MTC. Perhaps you can graft these two ideas together to make the converter you're looking for!
    ok i will work on it
    Last edited by rozzilla; 10-13-2020 at 04:28 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •