PortAudio  2.0
Data Structures | Macros | Typedefs | Functions | Variables
paqa.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <memory.h>
#include <math.h>
#include <string.h>
#include "portaudio.h"
#include "qa_tools.h"
#include "paqa_tools.h"
#include "audio_analyzer.h"
#include "test_audio_analyzer.h"

Data Structures

struct  TestParameters_s
 
struct  LoopbackContext_s
 
struct  UserOptions_s
 

Macros

#define MAX_NUM_GENERATORS   (8)
 
#define MAX_NUM_RECORDINGS   (8)
 
#define MAX_BACKGROUND_NOISE_RMS   (0.0004)
 
#define LOOPBACK_DETECTION_DURATION_SECONDS   (0.8)
 
#define DEFAULT_FRAMES_PER_BUFFER   (0)
 
#define PAQA_WAIT_STREAM_MSEC   (100)
 
#define PAQA_TEST_DURATION   (1.2)
 
#define PAQA_FLAG_TWO_STREAMS   (1<<0)
 
#define PAQA_FLAG_USE_BLOCKING_IO   (1<<1)
 
#define BIG_BUFFER_SIZE   (sizeof(float) * 2 * 2 * 1024)
 
#define MAX_CONVERSION_SAMPLES   (2 * 32 * 1024)
 
#define CONVERSION_BUFFER_SIZE   (sizeof(float) * 2 * MAX_CONVERSION_SAMPLES)
 

Typedefs

typedef struct TestParameters_s TestParameters
 
typedef struct LoopbackContext_s LoopbackContext
 
typedef struct UserOptions_s UserOptions
 

Functions

int PaQa_RunLoopbackFullDuplex (LoopbackContext *loopbackContext)
 
int PaQa_WaitForStream (LoopbackContext *loopbackContext)
 
int PaQa_RunLoopbackHalfDuplex (LoopbackContext *loopbackContext)
 
int PaQa_RunInputOnly (LoopbackContext *loopbackContext)
 
int PaQa_RunLoopbackHalfDuplexBlockingIO (LoopbackContext *loopbackContext)
 
int PaQa_RunLoopbackFullDuplexBlockingIO (LoopbackContext *loopbackContext)
 
int PaQa_RunLoopback (LoopbackContext *loopbackContext)
 
int PaQa_CheckForClippedLoopback (LoopbackContext *loopbackContextPtr)
 
int PaQa_MeasureBackgroundNoise (LoopbackContext *loopbackContextPtr, double *rmsPtr)
 
int PaQa_CheckForLoopBack (UserOptions *userOptions, PaDeviceIndex inputDevice, PaDeviceIndex outputDevice)
 
int TestSampleFormatConversion (void)
 
void usage (const char *name)
 
int main (int argc, char **argv)
 

Variables

int g_testsPassed = 0
 
int g_testsFailed = 0
 
const char * s_FlagOnNames []
 
const char * s_FlagOffNames []
 

Macro Definition Documentation

#define BIG_BUFFER_SIZE   (sizeof(float) * 2 * 2 * 1024)
#define CONVERSION_BUFFER_SIZE   (sizeof(float) * 2 * MAX_CONVERSION_SAMPLES)
#define DEFAULT_FRAMES_PER_BUFFER   (0)
#define LOOPBACK_DETECTION_DURATION_SECONDS   (0.8)

Referenced by PaQa_CheckForLoopBack().

#define MAX_BACKGROUND_NOISE_RMS   (0.0004)

Referenced by PaQa_CheckForLoopBack().

#define MAX_CONVERSION_SAMPLES   (2 * 32 * 1024)
#define MAX_NUM_GENERATORS   (8)
#define MAX_NUM_RECORDINGS   (8)
#define PAQA_FLAG_TWO_STREAMS   (1<<0)
#define PAQA_FLAG_USE_BLOCKING_IO   (1<<1)

Referenced by PaQa_RunLoopback().

#define PAQA_TEST_DURATION   (1.2)

Referenced by PaQa_WaitForStream().

#define PAQA_WAIT_STREAM_MSEC   (100)

Typedef Documentation

Parameters that describe a single test run.

typedef struct UserOptions_s UserOptions

Function Documentation

int main ( int  argc,
char **  argv 
)
int PaQa_CheckForClippedLoopback ( LoopbackContext loopbackContextPtr)
int PaQa_CheckForLoopBack ( UserOptions userOptions,
PaDeviceIndex  inputDevice,
PaDeviceIndex  outputDevice 
)
int PaQa_MeasureBackgroundNoise ( LoopbackContext loopbackContextPtr,
double *  rmsPtr 
)
int PaQa_RunInputOnly ( LoopbackContext loopbackContext)
int PaQa_RunLoopback ( LoopbackContext loopbackContext)
int PaQa_RunLoopbackFullDuplex ( LoopbackContext loopbackContext)

Open a full duplex audio stream. Generate sine waves on the output channels and record the input channels. Then close the stream.

Returns
0 if OK or negative error.

References LoopbackContext_s::done, TestParameters_s::framesPerBuffer, TestParameters_s::inputParameters, TestParameters_s::outputParameters, Pa_CloseStream(), Pa_OpenStream(), Pa_Sleep(), Pa_StartStream(), Pa_StopStream(), paClipOff, paNoError, PAQA_WAIT_STREAM_MSEC, TestParameters_s::sampleRate, test(), and LoopbackContext_s::test.

Referenced by PaQa_RunLoopback().

int PaQa_RunLoopbackFullDuplexBlockingIO ( LoopbackContext loopbackContext)

Open one audio stream with non-blocking IO. Generate sine waves on the output channels and record the input channels. Then close the stream.

Returns
0 if OK or negative error.

References TestParameters_s::framesPerBuffer, TestParameters_s::inputParameters, TestParameters_s::outputParameters, Pa_CloseStream(), Pa_OpenStream(), Pa_StartStream(), Pa_StopStream(), paClipOff, paNoError, TestParameters_s::sampleRate, and LoopbackContext_s::test.

Referenced by PaQa_RunLoopback().

int PaQa_RunLoopbackHalfDuplex ( LoopbackContext loopbackContext)

Open two audio streams, one for input and one for output. Generate sine waves on the output channels and record the input channels. Then close the stream.

Returns
0 if OK or negative error.

References LoopbackContext_s::done, TestParameters_s::framesPerBuffer, TestParameters_s::inputParameters, TestParameters_s::outputParameters, Pa_CloseStream(), Pa_OpenStream(), Pa_StartStream(), Pa_StopStream(), paNoError, PaQa_WaitForStream(), TestParameters_s::sampleRate, TestParameters_s::streamFlags, test(), and LoopbackContext_s::test.

Referenced by PaQa_RunLoopback().

int PaQa_RunLoopbackHalfDuplexBlockingIO ( LoopbackContext loopbackContext)

Open two audio streams with non-blocking IO. Generate sine waves on the output channels and record the input channels. Then close the stream.

Returns
0 if OK or negative error.

References TestParameters_s::framesPerBuffer, TestParameters_s::inputParameters, TestParameters_s::outputParameters, Pa_CloseStream(), Pa_OpenStream(), Pa_StartStream(), Pa_StopStream(), paClipOff, paNoError, TestParameters_s::sampleRate, and LoopbackContext_s::test.

Referenced by PaQa_RunLoopback().

int PaQa_WaitForStream ( LoopbackContext loopbackContext)

Open two audio streams, one for input and one for output. Generate sine waves on the output channels and record the input channels. Then close the stream.

Returns
0 if OK or paTimedOut.

References LoopbackContext_s::done, Pa_Sleep(), PAQA_TEST_DURATION, PAQA_WAIT_STREAM_MSEC, and paTimedOut.

Referenced by PaQa_RunInputOnly(), and PaQa_RunLoopbackHalfDuplex().

int TestSampleFormatConversion ( void  )
void usage ( const char *  name)

Referenced by main().

Variable Documentation

int g_testsFailed = 0

Referenced by main().

int g_testsPassed = 0

Accumulate counts for how many tests pass or fail.

Referenced by main().

const char* s_FlagOffNames[]
Initial value:
=
{
"One Stream (Full Duplex)",
"Callback"
}
const char* s_FlagOnNames[]
Initial value:
=
{
"Two Streams (Half Duplex)",
"Blocking Read/Write"
}