Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
blocks:app-note:ltc_timecode [2025-04-24 12:48]
mattias [Setup the timecode reader software]
blocks:app-note:ltc_timecode [2025-04-28 11:46] (current)
fredrik [Use the timecode in Blocks]
Line 1: Line 1:
-=====LTC timecode as sync source===== 
- 
-This application note describes a method to receive analog timecode from an external source.  For simplicity I use a USB analog soundcard that i plug in to the blocks server. Such audio interface should be "class compliant" USB-A, that means to special driver is required for the device to operate basic functionality properly. 
-{{:blocks:app-note:ltc_timecode:i_face.jpg?600|}}  
- 
-I refer to the analog input on the Blocks server in the article, the application used can run on any linux computer, so if your source signal is elsewhere it may make sense to pickup the sync signal with another computer running the LTC_timecode reader software. One way of doing that is to use the blocks server image to create the computer. Disable the blocks service and then follow the instructions in this application not to make this into a LTC timecode reader device. 
- 
-====Setup the timecode reader software==== 
-Plug in the USB audio device to the blocks server. 
-Use a second computer to play [[https://int.pixilab.se/outgoing/permanent/wiki/LTC_10mins_30fps_44100x24.wav|some sample LTC timecode]], just for testing purposes. I just play the sample audio in my Windows laptops mediaplayer.  
-Plug an 3.5mm audio cable between the computers audio output with the line in/mic input of the analog audio card of the Blocks server. 
- 
-===Find out the ALSA name of the sound device=== 
-To capture the desired device we must figure out the ALSA name of the usb-device. To do so we open the terminal as the pixi-server user and type: 
-<code>aplay -l</code> 
-Look for an entry like:  
-<code>plughw:CARD=Device,DEV=0 
-    USB PnP Sound Device, USB Audio 
-    Hardware device with all software conversions 
-</code> 
- 
-The ALSA name is 
-<code>plughw:CARD=Device,DEV=0</code> 
- 
-If you have more than one USB audio device one can expect the next one to be named: 
-<code>plughw:CARD=Device_1,DEV=0</code> 
-and so on.  
- 
- 
-===Echo test=== 
-To test if we get any signal one can now plug in headphones in the USB card output and make an Echo test: 
-<code>arecord -D plughw:CARD=Device,DEV=0 -f cd | aplay</code> 
-You should hear the incoming timecode in the headphones.  
-Stop the echo test by hitting ctrl+c.  
- 
-===Test run the LTC reader software=== 
-Now we can dryrun also the LTC reader software by making it log the time using the -t parameter. 
-Change to the directory where the software is stored, on a Blocks server image is is stored in home/blocks/native/ 
- 
-<code>cd native</code> 
- 
-Run the program using the -d parameter to specify device and -t parameter to run in test mode.  
-<code>./timecode-reader -d plughw:CARD=Device,DEV=0 -t</code> 
- 
-We should see the time changing as the time source progress in the console output: 
-<code>New settings: i/2000/t/25/p/1633/n/1/c/0/w/150/f/2 
-01:57.11 signal, dbFS: -0.6 
-</code> 
- 
-In test mode we may also see some error logging while reading the signal, this is normal. 
-<code>Non contiguos 92925 with lastAccepted 92929 
-Minor error ignored. 92926 contiguous with lastReceived 92925</code> 
- 
 ====Use the timecode in Blocks==== ====Use the timecode in Blocks====
 There are a few steps to do before we can make use of the incoming analog timesource in blocks. There are a few steps to do before we can make use of the incoming analog timesource in blocks.
Line 58: Line 5:
 ===Enable the driver=== ===Enable the driver===
 The driver to handle the timedata from the LTC-reader software is not enabled by default.  The driver to handle the timedata from the LTC-reader software is not enabled by default. 
-To make a driver enabled one must make sure the driver files exist in the script/driver directory in the PIXILAB-Blocks-root. The TimecodeLTC driver are stored in the script/driver-archive/ directory and needs to be enabled:+To enable the driver you must make sure the driver files exist in the script/driver directory in the PIXILAB-Blocks-root. The TimecodeLTC driver is stored in the script/driver-archive/ directory and needs to be enabled:
  
 Change to the script directory:  Change to the script directory: 
Line 73: Line 20:
  
 Under the page Manage/Network we set up a new device and assign the TimecodeLTC driver. Under the page Manage/Network we set up a new device and assign the TimecodeLTC driver.
-The ports is predefined in the driver to match the default configuration to the Timecode reader on the server. +The port is predefined in the driver to match the default configuration to the Timecode reader on the server. 
 {{:blocks:app-note:ltc_timecode:timecodeblocksdevice.png?800|}} {{:blocks:app-note:ltc_timecode:timecodeblocksdevice.png?800|}}
  
-====Connect a Blocks timeline to sync with timecode====+===Configure the driver=== 
 + 
 +You must configure the driver for the expected timecode type. This can be done with one of the following methods: 
 + 
 +A. Set the 'type' property of this Network Device to the expected type. 
 +This can be done using a Task triggered on system start-up or the 'connected' appears on the network). 
 +{{:blocks:app-note:ltc_timecode:configtask.png?800|}} 
 +  
 +B. Set options using JSON data in the "Custom Options" field of the Network Device, like this: {"type": "29.97_drop", "offset": 0.0} Supported type values: "24","25","29.97_drop","29.97_nondrop","30".  
 +{{:blocks:app-note:ltc_timecode:driveroptions.png?800|}} 
 +===Connect a Blocks timeline to sync with timecode===
  
 Create a timeline block, it can be left empty for testing purposes.  Create a timeline block, it can be left empty for testing purposes. 
Line 84: Line 41:
 Apply any time offset as required. This timeline is now controlled by the timecode. Apply any time offset as required. This timeline is now controlled by the timecode.
  
-====Make the Timecode reader autostart==== 
- 
-To make the timecode reader autostart we must perform a few more steps. On a blocks server we have prepared whats called  a unit file used by systemd in most linux distros to manage running programs and services.   
- 
-Change to the users unit files directory:  
-<code>cd /home/pixi-server/.config/systemd/user</code> 
- 
-Edit the timecode-reader.service.config file. 
-<code>nano timecode-reader.service.config</code> 
-Edit the TIMECODE_READER_OPTIONS= line to make the software use the wanted device name. 
-In my case I set it to: 
- 
-<code>TIMECODE_READER_OPTIONS=-d plughw:CARD=Device,DEV=0</code> 
- 
-Next step is to enable the service at computer startup.  
- 
-<code>systemctl --user enable --now timecode-reader.service</code>