PortAudio  2.0
Data Structures | Macros | Functions
patest_sync.c File Reference

Test time stamping and synchronization of audio and video. More...

#include <stdio.h>
#include <math.h>
#include "portaudio.h"
#include "pa_util.h"

Data Structures

struct  paTestData
 

Macros

#define NUM_BEEPS   (6)
 
#define SAMPLE_RATE   (44100)
 
#define SAMPLE_PERIOD   (1.0/44100.0)
 
#define FRAMES_PER_BUFFER   (256)
 
#define BEEP_DURATION   (400)
 
#define LATENCY_MSEC   (2000)
 
#define SLEEP_MSEC   (10)
 
#define TIMEOUT_MSEC   (15000)
 
#define STATE_BKG_IDLE   (0)
 
#define STATE_BKG_PENDING   (1)
 
#define STATE_BKG_BEEPING   (2)
 

Functions

int main (void)
 

Detailed Description

Test time stamping and synchronization of audio and video.

A high latency is used so we can hear the difference in time. Random durations are used so we know we are hearing the right beep and not the one before or after.

Sequence of events:

  1. Foreground requests a beep.
  2. Background randomly schedules a beep.
  3. Foreground waits for the beep to be heard based on PaUtil_GetTime().
  4. Foreground outputs video (printf) in sync with audio.
  5. Repeat.
Author
Phil Burk http://www.softsynth.com

Macro Definition Documentation

#define BEEP_DURATION   (400)
#define FRAMES_PER_BUFFER   (256)
#define LATENCY_MSEC   (2000)
#define NUM_BEEPS   (6)
#define SAMPLE_PERIOD   (1.0/44100.0)
#define SAMPLE_RATE   (44100)
#define SLEEP_MSEC   (10)
#define STATE_BKG_BEEPING   (2)
#define STATE_BKG_IDLE   (0)
#define STATE_BKG_PENDING   (1)
#define TIMEOUT_MSEC   (15000)

Function Documentation

int main ( void  )