|
PortAudio 2.0
|
#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 [] |
| #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) |
Referenced by PaQa_CheckForLoopBack(), and PaQa_RunLoopback().
| #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) |
Referenced by PaQa_RunLoopbackFullDuplex(), and PaQa_WaitForStream().
| typedef struct LoopbackContext_s LoopbackContext |
| typedef struct TestParameters_s TestParameters |
Parameters that describe a single test run.
| typedef struct UserOptions_s UserOptions |
| int main | ( | int | argc, |
| char ** | argv ) |
References UserOptions_s::framesPerBuffer, g_testsFailed, g_testsPassed, UserOptions_s::inputDevice, UserOptions_s::inputLatency, UserOptions_s::outputDevice, UserOptions_s::outputLatency, Pa_GetDeviceCount(), Pa_GetVersion(), Pa_GetVersionText(), Pa_Initialize(), Pa_Terminate(), paNoDevice, PaQa_ListAudioDevices(), PaQa_TestAnalyzer(), UserOptions_s::sampleRate, UserOptions_s::saveBadWaves, TestSampleFormatConversion(), usage(), UserOptions_s::verbose, and UserOptions_s::waveFilePath.
| int PaQa_CheckForClippedLoopback | ( | LoopbackContext * | loopbackContextPtr | ) |
| int PaQa_CheckForLoopBack | ( | UserOptions * | userOptions, |
| PaDeviceIndex | inputDevice, | ||
| PaDeviceIndex | outputDevice ) |
Output a sine wave then try to detect it on input.
References TestParameters_s::amplitude, LoopbackContext_s::callbackCount, PaDeviceInfo::defaultHighInputLatency, PaDeviceInfo::defaultHighOutputLatency, PaDeviceInfo::defaultLowInputLatency, PaDeviceInfo::defaultLowOutputLatency, TestParameters_s::flags, PaQaSineGenerator_s::frequency, LoopbackContext_s::generators, LOOPBACK_DETECTION_DURATION_SECONDS, MAX_BACKGROUND_NOISE_RMS, TestParameters_s::maxFrames, PaDeviceInfo::maxInputChannels, PaDeviceInfo::maxOutputChannels, PaDeviceInfo::name, Pa_GetDeviceInfo(), paInvalidDevice, paNoError, PaQa_CheckForClippedLoopback(), PaQa_CorrelateSine(), PAQA_FLAG_TWO_STREAMS, PaQa_MeasureBackgroundNoise(), PaQa_RunLoopback(), QA_ASSERT_TRUE, LoopbackContext_s::recordings, and TestParameters_s::sampleRate.
| int PaQa_MeasureBackgroundNoise | ( | LoopbackContext * | loopbackContextPtr, |
| double * | rmsPtr ) |
References PaQaRecording_s::buffer, PaQaRecording_s::numFrames, PaQa_MeasureRootMeanSquare(), PaQa_RunInputOnly(), and LoopbackContext_s::recordings.
Referenced by PaQa_CheckForLoopBack().
| int PaQa_RunInputOnly | ( | LoopbackContext * | loopbackContext | ) |
Open one audio streams, just for input. Record background level. Then close the stream.
References LoopbackContext_s::done, Pa_CloseStream(), Pa_OpenStream(), Pa_StartStream(), Pa_StopStream(), paClipOff, paNoError, PaQa_WaitForStream(), LoopbackContext_s::test, and test().
Referenced by PaQa_MeasureBackgroundNoise().
| int PaQa_RunLoopback | ( | LoopbackContext * | loopbackContext | ) |
Run some kind of loopback test.
References Pa_GetErrorText(), paNoError, PAQA_FLAG_TWO_STREAMS, PAQA_FLAG_USE_BLOCKING_IO, PaQa_RunLoopbackFullDuplex(), PaQa_RunLoopbackFullDuplexBlockingIO(), PaQa_RunLoopbackHalfDuplex(), PaQa_RunLoopbackHalfDuplexBlockingIO(), LoopbackContext_s::test, and test().
Referenced by PaQa_CheckForLoopBack().
| 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.
References LoopbackContext_s::done, Pa_CloseStream(), Pa_OpenStream(), Pa_Sleep(), Pa_StartStream(), Pa_StopStream(), paClipOff, paNoError, PAQA_WAIT_STREAM_MSEC, LoopbackContext_s::test, and 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.
References Pa_CloseStream(), Pa_OpenStream(), Pa_StartStream(), Pa_StopStream(), paClipOff, paNoError, LoopbackContext_s::test, and 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.
References LoopbackContext_s::done, Pa_CloseStream(), Pa_OpenStream(), Pa_StartStream(), Pa_StopStream(), paNoError, PaQa_WaitForStream(), LoopbackContext_s::test, and 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.
References Pa_CloseStream(), Pa_OpenStream(), Pa_StartStream(), Pa_StopStream(), paClipOff, paNoError, LoopbackContext_s::test, and 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.
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 | ) |
References paInt16, paInt32, paInt8, PaQa_ConvertFromFloat(), PaQa_ConvertToFloat(), paUInt8, QA_ASSERT_CLOSE, QA_ASSERT_CLOSE_INT, and QA_ASSERT_EQUALS.
Referenced by main().
| 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[] |
| const char* s_FlagOnNames[] |