Audio & Video Lip Sync

Share your advanced PureBasic knowledge/code with the community.
chris319
Enthusiast
Enthusiast
Posts: 782
Joined: Mon Oct 24, 2005 1:05 pm

Audio & Video Lip Sync

Post by chris319 »

Here is a program which is useful for checking audio and video sync, also known as "lip sync".

Sometimes in the digital domain, audio and video fall out of sync due to buffering, latency, etc.

Point a camera at the display and a microphone at the speaker. The white disk should appear simultaneously with the audible "beep". You may need to record this and examine audio and video closely in an editing program.

Code: Select all

InitSound()
LoadSound(1,"Sine1000Hz.wav")
SoundVolume(1,20)

Procedure DrawDisk()
Circle(640,360,100,#White)
PlaySound(1)
Delay(100)
StopSound(1)
Delay(900)
Box(0,0,1280,640,#Black)
EndProcedure

OpenWindow(1, 0, 0, 1280, 640, "", #PB_Window_SystemMenu)
StartDrawing(WindowOutput(1))
Box(0,0,1280,640,#Black)
    AddWindowTimer(1, 1, 2000)
    
    Repeat
      event = WaitWindowEvent()
      
      If event = #PB_Event_Timer And EventTimer() = 1

DrawDisk()

ElseIf event = #PB_Event_CloseWindow
StopDrawing()
  End

  EndIf
ForEver
In the olden days they used to use a clapper:

Image