User avatar
scrishton
Posts: 49
Joined: Mon May 07, 2012 8:48 pm
Location: Settle, in the Yorkshire Dales
Contact: Website

Generating SMPTE timecode on the 3.5mm jack

Tue Dec 17, 2013 11:50 pm

As part of my next crazy project on the Pi I'm trying to generate time of day linear timecode in order to jam a real timecode generator.

I have written a Python function which runs in the background as a daemon thread. It gets the time from time.time, converts it to local hours, minutes, seconds and frames, then turns those into a string of 0 and 255 ascii characters, complete with phase correction bit and end of packet marker. This is a total of 10 bytes of 8 bits each, with each bit represented by 4 audio samples, 25 times per second, total 8000 samples per second. This string is then sent to the /dev/dsp device through ossaudiodev.

It almost works, and is probably good enough for most purposes. But there are two things I'm not happy about. First is that there are occasional stutters. When I first start the thread it hesitates a couple of times. It then stutters every few seconds. The second issue is that there is about a one second delay from sending the packet to the audio being output. If I flush the buffer after sending each packet, there is a pause of about a second after each packet.

It's obviously going to be a bit tight trying to regularly output 320 samples in 1/25th of a second at 8000 samples per second, so I'm prepared to compromise and shorten the last bit of the end of packet marker, leaving just 319 samples. But the Pi seems determined to buffer its audio driver. Anyone know how to send an audio stream without buffering? Or to shorten the buffer to 319 bytes?

Simon R.

vadim
Posts: 129
Joined: Wed Sep 18, 2013 1:47 pm
Location: Nottingham

Re: Generating SMPTE timecode on the 3.5mm jack

Wed Dec 18, 2013 12:07 am

Why do you need to send data to output 25 times per second? I mean it's a known sequence so you can prepare a couple of seconds worth data and write it to the device less regularly. Or am I missing something?

User avatar
scrishton
Posts: 49
Joined: Mon May 07, 2012 8:48 pm
Location: Settle, in the Yorkshire Dales
Contact: Website

Re: Generating SMPTE timecode on the 3.5mm jack

Wed Dec 18, 2013 12:24 am

Thankyou Vadim! I knew I was missing something obvious somewhere. I do want to be able to override the time sometimes - it's useful to be able to over write tapes with timecode later than anything you're going to record that day so if you play beyond the end of your recordings it knows which way to search - but sending one second bursts would be much more efficient.

Simon R.

carmine
Posts: 1
Joined: Mon Aug 11, 2014 7:39 am

Re: Generating SMPTE timecode on the 3.5mm jack

Mon Aug 11, 2014 7:59 am

hello is possible to generating a smpte time code from raspberry pi? i need 23.97 , 24 , 25 , 29,97, 30 fps thank you

edwar64896
Posts: 6
Joined: Tue Aug 07, 2018 2:26 pm

Re: Generating SMPTE timecode on the 3.5mm jack

Tue Aug 07, 2018 2:28 pm

Just wanted to let you guys know I have just completed an alpha version of a timecode generator. I'm using NTP to synch the timecode output which is pretty solid and locking the timer process to a single CPU. LTC is generated out of the GPIO ports.

Will post a demo video over the next couple of days when I get a mo.

cheers,
mark.

Return to “Graphics, sound and multimedia”

Who is online

Users browsing this forum: Mayki and 10 guests