Platforms to show: All Mac Windows Linux Cross-Platform

/Tools/LTC/Listen for TimeCode


Required plugins for this example: MBS Audio Plugin, MBS Tools Plugin

You find this example project in your Plugins Download as a Xojo project file within the examples folder: /Tools/LTC/Listen for TimeCode

This example is the version from Sun, 9th May 2020.

Project "Listen for TimeCode.xojo_binary_project"
Class App Inherits Application
Const kEditClear = "&Delete"
Const kFileQuit = "&Quit"
Const kFileQuitShortcut = ""
EventHandler Sub Open() // we keep library here: // https://www.monkeybreadsoftware.de/xojo/download/plugin/Libs/ Dim f As FolderItem #If TargetMacOS Then // MacOS f = GetFolderItem("libltc.mac.dylib") #ElseIf TargetWin32 Then // Windows #If Target64Bit Then f = GetFolderItem("libltcWin64.dll") #Else f = GetFolderItem("libltcWin32.dll") #EndIf #Else // Linux f = GetFolderItem("libltc.so") #EndIf If LTCMBS.LoadLibrary(f) Then // okay Else MsgBox LTCMBS.LibraryLoadErrorMessage Quit End If End EventHandler
End Class
Class MainWindow Inherits Window
Control List Inherits Listbox
ControlInstance List Inherits Listbox
End Control
Control Timer1 Inherits Timer
ControlInstance Timer1 Inherits Timer
EventHandler Sub Action() If stream <> Nil Then 'Dim FramesAvailable As Integer = stream.FramesAvailable 'System.DebugLog "FramesAvailable: "+Str(FramesAvailable) Dim FramesRead As Integer = stream.ReadFrames(buffer, buffer.size) If FramesRead > 0 Then ProcessFrames buffer, FramesRead End If End If End EventHandler
End Control
EventHandler Sub Open() // init decoder Dim apv As Integer = 1920 // = 48000 / 25 decoder = New LTCDecoderMBS(apv, 32) // init portaudio portaudio = New PortAudioMBS stream = New PortAudioStream(1024*1024) buffer = New MemoryBlock(1920 * 4 * 10) // 1 frame * 4 bytes * 10 Dim e As Integer = stream.OpenDefaultStream(1, 48000) If e <> portaudio.kErrorNoError Then Break MsgBox "Failed to open stream." Else e = stream.Start If e <> portaudio.kErrorNoError Then Break MsgBox "Failed to start stream." Else // okay timer1.Mode = timer.ModeMultiple End If End If End EventHandler
Sub ProcessFrames(Buffer as Ptr, FramesRead as integer) Dim frame As New LTCFrameExtMBS dim stime as new LTCSMPTETimecodeMBS decoder.WriteSingle(buffer, FramesRead, total) While decoder.read(frame) LTCMBS.FrameToTime(stime, frame, LTCMBS.LTC_USE_DATE) Dim d As date = stime.Date Dim l1 As String = d.SQLDateTime Dim year As Integer = If((stime.years < 67), 2000+stime.years, 1900+stime.years) Dim l2 As String = Str(year, "0000")+"-"+_ Str(stime.months, "00")+"-"+_ Str(stime.days, "00")+" "+_ stime.TimeZone Dim l3 As String = Str(stime.Hours, "00")+":"+_ Str(stime.mins, "00")+":"+_ Str(stime.secs, "00")+_ If (frame.dfbit = 1, ".", ":")+_ Str(stime.frame, "00")+" | "+_ Str(frame.offStart, "00000000")+" "+_ Str(frame.offEnd, "00000000")+" "+_ If (frame.reverse = 1, " R", "") Log l1+" "+l2+" "+l3 Wend total = total + FramesRead System.DebugLog "total: "+Str(total) End Sub
Sub log(s as string) List.AddRow s End Sub
Property Stream As PortAudioStream
Property buffer As MemoryBlock
Property decoder As LTCDecoderMBS
Property portaudio As PortAudioMBS
Property total As int64
End Class
MenuBar MainMenuBar
MenuItem FileMenu = "&File"
MenuItem FileQuit = "#App.kFileQuit"
MenuItem EditMenu = "&Edit"
MenuItem EditUndo = "&Undo"
MenuItem EditSeparator1 = "-"
MenuItem EditCut = "Cu&t"
MenuItem EditCopy = "&Copy"
MenuItem EditPaste = "&Paste"
MenuItem EditClear = "#App.kEditClear"
MenuItem EditSeparator2 = "-"
MenuItem EditSelectAll = "Select &All"
End MenuBar
Class PortAudioStream Inherits PortAudioStreamRecorderMBS
End Class
ExternalFile info
End ExternalFile
End Project

The items on this page are in the following plugins: MBS Tools Plugin.


The biggest plugin in space...