* Clean up whitespace in test/ in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF.
/** @file pa_minlat.c
- @ingroup test_src
+ @ingroup test_src
@brief Experiment with different numbers of buffers to determine the
- minimum latency for a computer.
- @author Phil Burk http://www.softsynth.com
+ minimum latency for a computer.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
int framesPerBuffer;
double sampleRate = 44100.0;
char str[256];
- char *line;
+ char *line;
printf("pa_minlat - Determine minimum latency for your computer.\n");
printf(" usage: pa_minlat {userBufferSize}\n");
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output. */
outputParameters.suggestedLatency = (double)outLatency / sampleRate; /* In seconds. */
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
printf("Latency = %d frames = %6.1f msec.\n", outLatency, outputParameters.suggestedLatency * 1000.0 );
err = Pa_OpenStream(
printf("\nMove windows around to see if the sound glitches.\n");
printf("Latency now %d, enter new number of frames, or 'q' to quit: ", outLatency );
line = fgets( str, 256, stdin );
- if( line == NULL )
- {
- go = 0;
- }
- else
- {
- {
- /* Get rid of newline */
- size_t l = strlen( str ) - 1;
- if( str[ l ] == '\n')
- str[ l ] = '\0';
- }
-
-
- if( str[0] == 'q' ) go = 0;
- else
- {
- outLatency = atol( str );
- if( outLatency < minLatency )
- {
- printf( "Latency below minimum of %d! Set to minimum!!!\n", minLatency );
- outLatency = minLatency;
- }
- }
-
- }
- /* Stop sound until ENTER hit. */
+ if( line == NULL )
+ {
+ go = 0;
+ }
+ else
+ {
+ {
+ /* Get rid of newline */
+ size_t l = strlen( str ) - 1;
+ if( str[ l ] == '\n')
+ str[ l ] = '\0';
+ }
+
+
+ if( str[0] == 'q' ) go = 0;
+ else
+ {
+ outLatency = atol( str );
+ if( outLatency < minLatency )
+ {
+ printf( "Latency below minimum of %d! Set to minimum!!!\n", minLatency );
+ outLatency = minLatency;
+ }
+ }
+
+ }
+ /* Stop sound until ENTER hit. */
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( stream );
/** @file patest1.c
- @ingroup test_src
- @brief Ring modulate the audio input with a sine wave for 20 seconds.
- @author Ross Bencina <rossb@audiomulch.com>
+ @ingroup test_src
+ @brief Ring modulate the audio input with a sine wave for 20 seconds.
+ @author Ross Bencina <rossb@audiomulch.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
*out++ = 0; /* left */
*out++ = 0; /* right */
}
-
+
return finished;
}
printf("patest1.c\n"); fflush(stdout);
printf("Ring modulate input for 20 seconds.\n"); fflush(stdout);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<100; i++ )
data.sine[i] = sin( ((double)i/100.) * M_PI * 2. );
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No input default device.\n");
- goto done;
+ printf(stderr,"Error: No input default device.\n");
+ goto done;
}
inputParameters.channelCount = 2; /* stereo input */
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point input */
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto done;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto done;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
err = Pa_StartStream( stream );
if( err != paNoError ) goto done;
-
+
printf( "Press any key to end.\n" ); fflush(stdout);
-
+
getc( stdin ); /* wait for input before exiting */
err = Pa_AbortStream( stream );
if( err != paNoError ) goto done;
-
+
printf( "Waiting for stream to complete...\n" );
/* sleep until playback has finished */
/** @file patest_buffer.c
- @ingroup test_src
- @brief Test opening streams with different buffer sizes.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Test opening streams with different buffer sizes.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
PaError err;
printf("Test opening streams with different buffer sizes\n");
if( argc > 1 ) {
- device=atoi( args[1] );
- printf("Using device number %d.\n\n", device );
+ device=atoi( args[1] );
+ printf("Using device number %d.\n\n", device );
} else {
- printf("Using default device.\n\n" );
+ printf("Using default device.\n\n" );
}
for (i = 0 ; i < BUFFER_TABLE; i++)
data.sampsToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
if( device == -1 )
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
else
outputParameters.device = device ;
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
/** @file patest_callbackstop.c
- @ingroup test_src
- @brief Test the paComplete callback result code.
- @author Ross Bencina <rossb@audiomulch.com>
+ @ingroup test_src
+ @brief Test the paComplete callback result code.
+ @author Ross Bencina <rossb@audiomulch.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
(void) timeInfo;
(void) statusFlags;
-
+
if( data->callbackReturnedPaComplete )
data->callbackInvokedAfterReturningPaComplete = 1;
for( i=0; i<frameCount; i++ )
{
/* generate tone */
-
+
x = data->sine[ data->phase++ ];
if( data->phase >= TABLE_SIZE )
data->phase -= TABLE_SIZE;
-
+
*out++ = x; /* left */
*out++ = x; /* right */
}
*/
static void StreamFinished( void* userData )
{
- TestData *data = (TestData *) userData;
- printf( "Stream Completed: %s\n", data->message );
+ TestData *data = (TestData *) userData;
+ printf( "Stream Completed: %s\n", data->message );
}
TestData data;
int i, j;
-
+
printf( "PortAudio Test: output sine wave. SR = %d, BufSize = %d\n",
SAMPLE_RATE, FRAMES_PER_BUFFER );
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
if( err != paNoError ) goto error;
printf("Repeating test %d times.\n", NUM_LOOPS );
-
+
for( i=0; i < NUM_LOOPS; ++i )
{
data.phase = 0;
/* wait for stream to become inactive,
or for a timeout of approximately NUM_SECONDS
*/
-
+
j = 0;
while( (err = Pa_IsStreamActive( stream )) == 1 && j < NUM_SECONDS * 2 )
{
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_clip.c
- @ingroup test_src
- @brief Play a sine wave for several seconds at an amplitude
- that would require clipping.
+ @ingroup test_src
+ @brief Play a sine wave for several seconds at an amplitude
+ that would require clipping.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
fflush(stdout);
err = PlaySine( &data, paClipOff, 1.1f );
if( err < 0 ) goto error;
-
+
return 0;
error:
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
data->left_phase = data->right_phase = 0;
data->amplitude = amplitude;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
err = Pa_OpenStream(
&stream,
NULL, /* no input */
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
return paNoError;
error:
/** @file patest_converters.c
- @ingroup test_src
- @brief Tests the converter functions in pa_converters.c
- @author Ross Bencina <rossb@audiomulch.com>
+ @ingroup test_src
+ @brief Tests the converter functions in pa_converters.c
+ @author Ross Bencina <rossb@audiomulch.com>
Link with pa_dither.c and pa_converters.c
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
#define SAMPLE_FORMAT_COUNT (6)
-static PaSampleFormat sampleFormats_[ SAMPLE_FORMAT_COUNT ] =
+static PaSampleFormat sampleFormats_[ SAMPLE_FORMAT_COUNT ] =
{ paFloat32, paInt32, paInt24, paInt16, paInt8, paUInt8 }; /* all standard PA sample formats */
-static const char* sampleFormatNames_[SAMPLE_FORMAT_COUNT] =
+static const char* sampleFormatNames_[SAMPLE_FORMAT_COUNT] =
{ "paFloat32", "paInt32", "paInt24", "paInt16", "paInt8", "paUInt8" };
-static const char* abbreviatedSampleFormatNames_[SAMPLE_FORMAT_COUNT] =
+static const char* abbreviatedSampleFormatNames_[SAMPLE_FORMAT_COUNT] =
{ "f32", "i32", "i24", "i16", " i8", "ui8" };
unsigned char *out = (unsigned char*)buffer;
for( i=0; i < frameCount; ++i ){
signed long temp = (PaInt32)(.9 * sin( ((double)i/(double)frameCount) * 2. * M_PI ) * 0x7FFFFFFF);
-
+
#if defined(PA_LITTLE_ENDIAN)
out[0] = (unsigned char)(temp >> 8) & 0xFF;
out[1] = (unsigned char)(temp >> 16) & 0xFF;
int i;
for( i=0; i < size; ++i ){
-
+
if( *p != 0 )
return 1;
++p;
- }
+ }
return 0;
}
}
return result;
-}
+}
int main( const char **argv, int argc )
{
passFailMatrix[sourceFormatIndex][destinationFormatIndex] = 0;
}
-
+
/* try to measure the noise floor (comparing output signal to a float32 sine wave) */
if( passFailMatrix[sourceFormatIndex][destinationFormatIndex] ){
(*converter)( sourceBuffer, 1, destinationBuffer, 1, MAX_PER_CHANNEL_FRAME_COUNT, &ditherState );
if( TestNonZeroPresent( sourceBuffer, MAX_PER_CHANNEL_FRAME_COUNT * My_Pa_GetSampleSize( paFloat32 ) ) ){
-
+
noiseAmplitudeMatrix[sourceFormatIndex][destinationFormatIndex] = MaximumAbsDifference( (float*)sourceBuffer, (float*)referenceBuffer, MAX_PER_CHANNEL_FRAME_COUNT );
-
+
}else{
/* can't test noise floor because there is no conversion from dest format to float available */
noiseAmplitudeMatrix[sourceFormatIndex][destinationFormatIndex] = -1; // mark as failed
/** @file patest_dither.c
- @ingroup test_src
- @brief Attempt to hear difference between dithered and non-dithered signal.
+ @ingroup test_src
+ @brief Attempt to hear difference between dithered and non-dithered signal.
- This only has an effect if the native format is 16 bit.
+ This only has an effect if the native format is 16 bit.
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
int right_phase;
}
paTestData;
-
+
/* This routine will be called by the PortAudio engine when audio is needed.
** It may called at interrupt level on some machines so don't do anything
** that could mess up the system like calling malloc() or free().
*/
static int sineCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo *timeInfo,
- PaStreamCallbackFlags statusFlags, void *userData )
+ const PaStreamCallbackTimeInfo *timeInfo,
+ PaStreamCallbackFlags statusFlags, void *userData )
{
paTestData *data = (paTestData*)userData;
float *out = (float*)outputBuffer;
float amplitude = data->amplitude;
unsigned int i;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
*out++ = amplitude * data->sine[data->left_phase]; /* left */
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto done;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto done;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.hostApiSpecificStreamInfo = NULL;
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output. */
/* When you change this, also */
- /* adapt the callback routine! */
+ /* adapt the callback routine! */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )
->defaultLowOutputLatency; /* Low latency. */
err = Pa_OpenStream( &stream,
Pa_Sleep( NUM_SECONDS * 1000 );
printf("CPULoad = %8.6f\n", Pa_GetStreamCpuLoad(stream));
-
+
err = Pa_CloseStream( stream );
done:
Pa_Sleep( 250 ); /* Just a small silence. */
paTestData DATA;
int i;
float amplitude = 4.0 / (1<<15);
-
+
printf("PortAudio Test: output EXTREMELY QUIET sine wave with and without dithering.\n");
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <time.h>
#include <math.h>
-#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
+#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
#include <windows.h>
//#include <mmsystem.h> /* required when using pa_win_wmme.h */
osVersionInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx( &osVersionInfoEx );
-
+
if( osVersionInfoEx.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ){
switch( osVersionInfoEx.dwMinorVersion ){
case 0: osName = "Windows 95"; break;
- case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
+ case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
// on osInfo.Version.Revision.ToString() == "2222A")
case 90: osName = "Windows Me"; break;
}
}break;
}break;
case 6:switch( osVersionInfoEx.dwMinorVersion ){
- case 0:
+ case 0:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows Vista";
else
osName = "Windows Server 2008";
break;
- case 1:
+ case 1:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows 7";
else
}
else if(osVersionInfoEx.wProductType == VER_NT_SERVER)
{
- if(osVersionInfoEx.dwMinorVersion == 0)
+ if(osVersionInfoEx.dwMinorVersion == 0)
{
if((osVersionInfoEx.wSuiteMask & VER_SUITE_DATACENTER) == VER_SUITE_DATACENTER)
osProductType = "Datacenter Server"; // Windows 2000 Datacenter Server
fprintf( fp, "OS name and edition: %s %s\n", osName, osProductType );
- fprintf( fp, "OS version: %d.%d.%d %S\n",
- osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
+ fprintf( fp, "OS version: %d.%d.%d %S\n",
+ osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
osVersionInfoEx.dwBuildNumber, osVersionInfoEx.szCSDVersion );
fprintf( fp, "Processor architecture: %s\n", processorArchitecture );
fprintf( fp, "WoW64 process: %s\n", IsWow64() ? "Yes" : "No" );
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
double phaseIncrement;
volatile int fadeIn;
volatile int fadeOut;
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
float x = data->sine[(int)data->phase];
data->phase += data->phaseIncrement;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
x *= data->amp;
if( data->fadeIn ){
data->amp -= .001;
}
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
if( data->amp > 0 )
return paContinue;
else
#define NO 0
-static int playUntilKeyPress( int deviceIndex, float sampleRate,
+static int playUntilKeyPress( int deviceIndex, float sampleRate,
int framesPerUserBuffer, int framesPerDSoundBuffer )
{
PaStreamParameters outputParameters;
outputParameters.hostApiSpecificStreamInfo = NULL;
directSoundStreamInfo.size = sizeof(PaWinDirectSoundStreamInfo);
- directSoundStreamInfo.hostApiType = paDirectSound;
+ directSoundStreamInfo.hostApiType = paDirectSound;
directSoundStreamInfo.version = 2;
directSoundStreamInfo.flags = paWinDirectSoundUseLowLevelLatencyParameters;
directSoundStreamInfo.framesPerBuffer = framesPerDSoundBuffer;
}
/*
- ideas:
+ ideas:
o- could be testing with 80% CPU load
o- could test with different channel counts
*/
if( argc > 3 )
usage(dsoundHostApiIndex);
- deviceIndex = dsoundHostApiInfo->defaultOutputDevice;
- if( argc >= 2 ){
+ deviceIndex = dsoundHostApiInfo->defaultOutputDevice;
+ if( argc >= 2 ){
deviceIndex = -1;
- if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
+ if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
usage(dsoundHostApiInfo);
if( deviceIndex < 0 || deviceIndex >= Pa_GetDeviceCount() || Pa_GetDeviceInfo(deviceIndex)->hostApi != dsoundHostApiIndex ){
usage(dsoundHostApiInfo);
}
- }
+ }
printf( "Using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
printf( "Testing with sample rate %f.\n", (float)sampleRate );
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
- data.phase = 0;
+ data.phase = 0;
resultsFp = fopen( "results.txt", "at" );
fprintf( resultsFp, "*** DirectSound smallest working output buffer sizes\n" );
printTimeAndDate( resultsFp );
printWindowsVersionInfo( resultsFp );
-
+
fprintf( resultsFp, "audio device: %s\n", Pa_GetDeviceInfo( deviceIndex )->name );
fflush( resultsFp );
}else{
min = mid + 1;
}
-
+
}while( (min <= max) && (testResult == YES || testResult == NO) );
smallestWorkingBufferingLatencyFrames = smallestWorkingBufferSize; /* not strictly true, but we're using an unspecified callback size, so kind of */
}
}while( (dsoundBufferSize <= (int)(sampleRate * .3)) && testResult == NO );
-
+
smallestWorkingBufferingLatencyFrames = smallestWorkingBufferSize; /* not strictly true, but we're using an unspecified callback size, so kind of */
fprintf( resultsFp, "%d, %d, %f\n", smallestWorkingBufferSize, smallestWorkingBufferingLatencyFrames, smallestWorkingBufferingLatencyFrames / sampleRate );
fprintf( resultsFp, "###\n" );
fclose( resultsFp );
-
+
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
}
paTestData;
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
float x = data->sine[(int)data->phase];
data->phase += 20;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
return paContinue;
}
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
- if( argc == 2 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
+ if( argc == 2 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
- data.phase = 0;
+ data.phase = 0;
outputParameters.device = deviceIndex;
outputParameters.channelCount = CHANNEL_COUNT;
outputParameters.hostApiSpecificStreamInfo = NULL;
dsoundStreamInfo.size = sizeof(PaWinDirectSoundStreamInfo);
- dsoundStreamInfo.hostApiType = paDirectSound;
+ dsoundStreamInfo.hostApiType = paDirectSound;
dsoundStreamInfo.version = 2;
dsoundStreamInfo.flags = paWinDirectSoundUseLowLevelLatencyParameters;
dsoundStreamInfo.framesPerBuffer = DSOUND_FRAMES_PER_HOST_BUFFER;
outputParameters.hostApiSpecificStreamInfo = &dsoundStreamInfo;
-
- if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
- printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
- }else{
- printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
- }
+
+ if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
+ printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
+ }else{
+ printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
+ }
err = Pa_OpenStream(
&stream,
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
typedef struct
{
float sine[TABLE_SIZE];
- int phase;
- int currentChannel;
- int cycleCount;
+ int phase;
+ int currentChannel;
+ int cycleCount;
}
paTestData;
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
- for( j = 0; j < CHANNEL_COUNT; ++j ){
- if( j == data->currentChannel && data->cycleCount < 4410 ){
- *out++ = data->sine[data->phase];
- data->phase += 1 + j; // play each channel at a different pitch so they can be distinguished
- if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
- }else{
- *out++ = 0;
- }
- }
-
- data->cycleCount++;
- if( data->cycleCount > 44100 ){
- data->cycleCount = 0;
-
- ++data->currentChannel;
- if( data->currentChannel >= CHANNEL_COUNT )
- data->currentChannel -= CHANNEL_COUNT;
- }
- }
-
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
+ if( j == data->currentChannel && data->cycleCount < 4410 ){
+ *out++ = data->sine[data->phase];
+ data->phase += 1 + j; // play each channel at a different pitch so they can be distinguished
+ if( data->phase >= TABLE_SIZE ){
+ data->phase -= TABLE_SIZE;
+ }
+ }else{
+ *out++ = 0;
+ }
+ }
+
+ data->cycleCount++;
+ if( data->cycleCount > 44100 ){
+ data->cycleCount = 0;
+
+ ++data->currentChannel;
+ if( data->currentChannel >= CHANNEL_COUNT )
+ data->currentChannel -= CHANNEL_COUNT;
+ }
+ }
+
return paContinue;
}
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
- if( argc == 2 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paDirectSound ) )->defaultOutputDevice;
+ if( argc == 2 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
- data.phase = 0;
- data.currentChannel = 0;
- data.cycleCount = 0;
+ data.phase = 0;
+ data.currentChannel = 0;
+ data.cycleCount = 0;
outputParameters.device = deviceIndex;
outputParameters.channelCount = CHANNEL_COUNT;
output. But if you want to be sure which channel mask PortAudio will use
then you should supply one */
directSoundStreamInfo.size = sizeof(PaWinDirectSoundStreamInfo);
- directSoundStreamInfo.hostApiType = paDirectSound;
+ directSoundStreamInfo.hostApiType = paDirectSound;
directSoundStreamInfo.version = 1;
directSoundStreamInfo.flags = paWinDirectSoundUseChannelMask;
directSoundStreamInfo.channelMask = PAWIN_SPEAKER_5POINT1; /* request 5.1 output format */
outputParameters.hostApiSpecificStreamInfo = &directSoundStreamInfo;
- if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
- printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
- }else{
- printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
- }
+ if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
+ printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
+ }else{
+ printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
+ }
err = Pa_OpenStream(
&stream,
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_hang.c
- @ingroup test_src
- @brief Play a sine then hang audio callback to test watchdog.
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @ingroup test_src
+ @brief Play a sine then hang audio callback to test watchdog.
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
int finished = 0;
double phaseInc = 0.02;
double phase = data->phase;
-
+
(void) inputBuffer; /* Prevent unused argument warning. */
for( i=0; i<framesPerBuffer; i++ )
/* This is not a very efficient way to calc sines. */
*out++ = (float) sin( phase ); /* mono */
}
-
+
if( data->sleepFor > 0 )
{
Pa_Sleep( data->sleepFor );
}
-
+
data->phase = phase;
return finished;
}
PaError err;
int i;
paTestData data = {0};
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n",
SAMPLE_RATE, FRAMES_PER_BUFFER );
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 1; /* Mono output. */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point. */
patestCallback,
&data);
if (err != paNoError) goto error;
-
+
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
data.sleepFor = i;
Pa_Sleep( ((i<1000) ? 1000 : i) );
}
-
+
printf("Suffer for 10 seconds.\n");
Pa_Sleep( 10000 );
-
+
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
err = Pa_CloseStream( stream );
/** @file patest_in_overflow.c
- @ingroup test_src
- @brief Count input overflows (using paInputOverflow flag) under
- overloaded and normal conditions.
+ @ingroup test_src
+ @brief Count input overflows (using paInputOverflow flag) under
+ overloaded and normal conditions.
This test uses the same method to overload the stream as does
patest_out_underflow.c -- it generates sine waves until the cpu load
exceeds a certain level. However this test is only concerned with
input and so doesn't output any sound.
-
+
@author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default input device.\n");
- goto error;
+ fprintf(stderr,"Error: No default input device.\n");
+ goto error;
}
inputParameters.channelCount = 1; /* mono output */
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
- &data );
+ &data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
load = Pa_GetStreamCpuLoad( stream );
printf("STRESSING: sineCount = %d, CPU load = %f\n", data.sineCount, load );
}
-
+
printf("Counting overflows for 5 seconds.\n");
data.countOverflows = 1;
Pa_Sleep( 5000 );
Pa_Sleep( 5000 );
safeOverflowCount = data.inputOverflowCount;
-
+
printf("Stop stream.\n");
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
if( stressedOverflowCount == 0 )
/** @file pa_test_jack_wasapi.c
- @ingroup test_src
- @brief Print out jack information for WASAPI endpoints
- @author Reid Bishop <rbish@attglobal.net>
+ @ingroup test_src
+ @brief Print out jack information for WASAPI endpoints
+ @author Reid Bishop <rbish@attglobal.net>
*/
/*
* $Id: pa_test_jack_wasapi.c 1368 2008-03-01 00:38:27Z rbishop $
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
*/
static int IsInMask(int val, int val2)
{
- return ((val & val2) == val2);
+ return ((val & val2) == val2);
}
/*
static void EnumIJackChannels(int channelMapping)
{
- printf("Channel Mapping: ");
- if(channelMapping == PAWIN_SPEAKER_DIRECTOUT)
- {
- printf("DIRECTOUT\n");
- return;
- }
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT))
- printf("FRONT_LEFT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT))
- printf("FRONT_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_CENTER))
- printf("FRONT_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_LOW_FREQUENCY))
- printf("LOW_FREQUENCY, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_LEFT))
- printf("BACK_LEFT, ");
- if(IsInMask(channelMapping,PAWIN_SPEAKER_BACK_RIGHT))
- printf("BACK_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER))
- printf("FRONT_LEFT_OF_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER))
- printf("FRONT_RIGHT_OF_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_CENTER))
- printf("BACK_CENTER, ");
- if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_LEFT))
- printf("SIDE_LEFT, ");
- if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_RIGHT))
- printf("SIDE_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_CENTER))
- printf("TOP_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_LEFT))
- printf("TOP_FRONT_LEFT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_CENTER))
- printf("TOP_FRONT_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_RIGHT))
- printf("TOP_FRONT_RIGHT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_LEFT))
- printf("TOP_BACK_LEFT, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_CENTER))
- printf("TOP_BACK_CENTER, ");
- if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_RIGHT))
- printf("TOP_BACK_RIGHT, ");
+ printf("Channel Mapping: ");
+ if(channelMapping == PAWIN_SPEAKER_DIRECTOUT)
+ {
+ printf("DIRECTOUT\n");
+ return;
+ }
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT))
+ printf("FRONT_LEFT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT))
+ printf("FRONT_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_CENTER))
+ printf("FRONT_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_LOW_FREQUENCY))
+ printf("LOW_FREQUENCY, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_LEFT))
+ printf("BACK_LEFT, ");
+ if(IsInMask(channelMapping,PAWIN_SPEAKER_BACK_RIGHT))
+ printf("BACK_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_LEFT_OF_CENTER))
+ printf("FRONT_LEFT_OF_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_FRONT_RIGHT_OF_CENTER))
+ printf("FRONT_RIGHT_OF_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_BACK_CENTER))
+ printf("BACK_CENTER, ");
+ if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_LEFT))
+ printf("SIDE_LEFT, ");
+ if(IsInMask(channelMapping,PAWIN_SPEAKER_SIDE_RIGHT))
+ printf("SIDE_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_CENTER))
+ printf("TOP_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_LEFT))
+ printf("TOP_FRONT_LEFT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_CENTER))
+ printf("TOP_FRONT_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_FRONT_RIGHT))
+ printf("TOP_FRONT_RIGHT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_LEFT))
+ printf("TOP_BACK_LEFT, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_CENTER))
+ printf("TOP_BACK_CENTER, ");
+ if(IsInMask(channelMapping, PAWIN_SPEAKER_TOP_BACK_RIGHT))
+ printf("TOP_BACK_RIGHT, ");
- printf("\n");
+ printf("\n");
}
/*
*/
static void EnumIJackConnectionType(int cType)
{
- printf("Connection Type: ");
- switch(cType)
- {
- case eJackConnTypeUnknown:
- printf("eJackConnTypeUnknown");
- break;
- case eJackConnType3Point5mm:
- printf("eJackConnType3Point5mm");
- break;
- case eJackConnTypeQuarter:
- printf("eJackConnTypeQuarter");
- break;
- case eJackConnTypeAtapiInternal:
- printf("eJackConnTypeAtapiInternal");
- break;
- case eJackConnTypeRCA:
- printf("eJackConnTypeRCA");
- break;
- case eJackConnTypeOptical:
- printf("eJackConnTypeOptical");
- break;
- case eJackConnTypeOtherDigital:
- printf("eJackConnTypeOtherDigital");
- break;
- case eJackConnTypeOtherAnalog:
- printf("eJackConnTypeOtherAnalog");
- break;
- case eJackConnTypeMultichannelAnalogDIN:
- printf("eJackConnTypeMultichannelAnalogDIN");
- break;
- case eJackConnTypeXlrProfessional:
- printf("eJackConnTypeXlrProfessional");
- break;
- case eJackConnTypeRJ11Modem:
- printf("eJackConnTypeRJ11Modem");
- break;
- case eJackConnTypeCombination:
- printf("eJackConnTypeCombination");
- break;
- }
- printf("\n");
+ printf("Connection Type: ");
+ switch(cType)
+ {
+ case eJackConnTypeUnknown:
+ printf("eJackConnTypeUnknown");
+ break;
+ case eJackConnType3Point5mm:
+ printf("eJackConnType3Point5mm");
+ break;
+ case eJackConnTypeQuarter:
+ printf("eJackConnTypeQuarter");
+ break;
+ case eJackConnTypeAtapiInternal:
+ printf("eJackConnTypeAtapiInternal");
+ break;
+ case eJackConnTypeRCA:
+ printf("eJackConnTypeRCA");
+ break;
+ case eJackConnTypeOptical:
+ printf("eJackConnTypeOptical");
+ break;
+ case eJackConnTypeOtherDigital:
+ printf("eJackConnTypeOtherDigital");
+ break;
+ case eJackConnTypeOtherAnalog:
+ printf("eJackConnTypeOtherAnalog");
+ break;
+ case eJackConnTypeMultichannelAnalogDIN:
+ printf("eJackConnTypeMultichannelAnalogDIN");
+ break;
+ case eJackConnTypeXlrProfessional:
+ printf("eJackConnTypeXlrProfessional");
+ break;
+ case eJackConnTypeRJ11Modem:
+ printf("eJackConnTypeRJ11Modem");
+ break;
+ case eJackConnTypeCombination:
+ printf("eJackConnTypeCombination");
+ break;
+ }
+ printf("\n");
}
/*
*/
static void EnumIJackGeoLocation(int iVal)
{
- printf("Geometric Location: ");
- switch(iVal)
- {
- case eJackGeoLocRear:
- printf("eJackGeoLocRear");
- break;
- case eJackGeoLocFront:
- printf("eJackGeoLocFront");
- break;
- case eJackGeoLocLeft:
- printf("eJackGeoLocLeft");
- break;
- case eJackGeoLocRight:
- printf("eJackGeoLocRight");
- break;
- case eJackGeoLocTop:
- printf("eJackGeoLocTop");
- break;
- case eJackGeoLocBottom:
- printf("eJackGeoLocBottom");
- break;
- case eJackGeoLocRearPanel:
- printf("eJackGeoLocRearPanel");
- break;
- case eJackGeoLocRiser:
- printf("eJackGeoLocRiser");
- break;
- case eJackGeoLocInsideMobileLid:
- printf("eJackGeoLocInsideMobileLid");
- break;
- case eJackGeoLocDrivebay:
- printf("eJackGeoLocDrivebay");
- break;
- case eJackGeoLocHDMI:
- printf("eJackGeoLocHDMI");
- break;
- case eJackGeoLocOutsideMobileLid:
- printf("eJackGeoLocOutsideMobileLid");
- break;
- case eJackGeoLocATAPI:
- printf("eJackGeoLocATAPI");
- break;
- }
- printf("\n");
+ printf("Geometric Location: ");
+ switch(iVal)
+ {
+ case eJackGeoLocRear:
+ printf("eJackGeoLocRear");
+ break;
+ case eJackGeoLocFront:
+ printf("eJackGeoLocFront");
+ break;
+ case eJackGeoLocLeft:
+ printf("eJackGeoLocLeft");
+ break;
+ case eJackGeoLocRight:
+ printf("eJackGeoLocRight");
+ break;
+ case eJackGeoLocTop:
+ printf("eJackGeoLocTop");
+ break;
+ case eJackGeoLocBottom:
+ printf("eJackGeoLocBottom");
+ break;
+ case eJackGeoLocRearPanel:
+ printf("eJackGeoLocRearPanel");
+ break;
+ case eJackGeoLocRiser:
+ printf("eJackGeoLocRiser");
+ break;
+ case eJackGeoLocInsideMobileLid:
+ printf("eJackGeoLocInsideMobileLid");
+ break;
+ case eJackGeoLocDrivebay:
+ printf("eJackGeoLocDrivebay");
+ break;
+ case eJackGeoLocHDMI:
+ printf("eJackGeoLocHDMI");
+ break;
+ case eJackGeoLocOutsideMobileLid:
+ printf("eJackGeoLocOutsideMobileLid");
+ break;
+ case eJackGeoLocATAPI:
+ printf("eJackGeoLocATAPI");
+ break;
+ }
+ printf("\n");
}
/*
*/
static void EnumIJackGenLocation(int iVal)
{
- printf("General Location: ");
- switch(iVal)
- {
- case eJackGenLocPrimaryBox:
- printf("eJackGenLocPrimaryBox");
- break;
- case eJackGenLocInternal:
- printf("eJackGenLocInternal");
- break;
- case eJackGenLocSeparate:
- printf("eJackGenLocSeparate");
- break;
- case eJackGenLocOther:
- printf("eJackGenLocOther");
- break;
- }
- printf("\n");
+ printf("General Location: ");
+ switch(iVal)
+ {
+ case eJackGenLocPrimaryBox:
+ printf("eJackGenLocPrimaryBox");
+ break;
+ case eJackGenLocInternal:
+ printf("eJackGenLocInternal");
+ break;
+ case eJackGenLocSeparate:
+ printf("eJackGenLocSeparate");
+ break;
+ case eJackGenLocOther:
+ printf("eJackGenLocOther");
+ break;
+ }
+ printf("\n");
}
/*
*/
static void EnumIJackPortConnection(int iVal)
{
- printf("Port Type: ");
- switch(iVal)
- {
- case eJackPortConnJack:
- printf("eJackPortConnJack");
- break;
- case eJackPortConnIntegratedDevice:
- printf("eJackPortConnIntegratedDevice");
- break;
- case eJackPortConnBothIntegratedAndJack:
- printf("eJackPortConnBothIntegratedAndJack");
- break;
- case eJackPortConnUnknown:
- printf("eJackPortConnUnknown");
- break;
- }
- printf("\n");
+ printf("Port Type: ");
+ switch(iVal)
+ {
+ case eJackPortConnJack:
+ printf("eJackPortConnJack");
+ break;
+ case eJackPortConnIntegratedDevice:
+ printf("eJackPortConnIntegratedDevice");
+ break;
+ case eJackPortConnBothIntegratedAndJack:
+ printf("eJackPortConnBothIntegratedAndJack");
+ break;
+ case eJackPortConnUnknown:
+ printf("eJackPortConnUnknown");
+ break;
+ }
+ printf("\n");
}
/*
static PaError GetJackInformation(int deviceId)
{
PaError err;
- int i;
- int jackCount = 0;
- PaWasapiJackDescription jackDesc;
+ int i;
+ int jackCount = 0;
+ PaWasapiJackDescription jackDesc;
- err = PaWasapi_GetJackCount(deviceId, &jackCount);
- if( err != paNoError ) return err;
+ err = PaWasapi_GetJackCount(deviceId, &jackCount);
+ if( err != paNoError ) return err;
- fprintf( stderr,"Number of Jacks: %d \n", jackCount );
+ fprintf( stderr,"Number of Jacks: %d \n", jackCount );
- for( i = 0; i<jackCount; i++ )
- {
- fprintf( stderr,"Jack #%d:\n", i );
+ for( i = 0; i<jackCount; i++ )
+ {
+ fprintf( stderr,"Jack #%d:\n", i );
- err = PaWasapi_GetJackDescription(deviceId, i, &jackDesc);
- if( err != paNoError )
- {
- fprintf( stderr,"Failed getting description." );
- continue;
- }
- else
- {
- printf("Is connected: %s\n",(jackDesc.isConnected)?"true":"false");
- EnumIJackChannels(jackDesc.channelMapping);
- EnumIJackConnectionType(jackDesc.connectionType);
- EnumIJackGeoLocation(jackDesc.geoLocation);
- EnumIJackGenLocation(jackDesc.genLocation);
- EnumIJackPortConnection(jackDesc.portConnection);
- printf("Jack Color: 0x%06X\n", jackDesc.color);
- printf("\n");
- }
- }
- return 0;
+ err = PaWasapi_GetJackDescription(deviceId, i, &jackDesc);
+ if( err != paNoError )
+ {
+ fprintf( stderr,"Failed getting description." );
+ continue;
+ }
+ else
+ {
+ printf("Is connected: %s\n",(jackDesc.isConnected)?"true":"false");
+ EnumIJackChannels(jackDesc.channelMapping);
+ EnumIJackConnectionType(jackDesc.connectionType);
+ EnumIJackGeoLocation(jackDesc.geoLocation);
+ EnumIJackGenLocation(jackDesc.genLocation);
+ EnumIJackPortConnection(jackDesc.portConnection);
+ printf("Jack Color: 0x%06X\n", jackDesc.color);
+ printf("\n");
+ }
+ }
+ return 0;
}
int main(void)
{
PaError err;
- const PaDeviceInfo *device;
+ const PaDeviceInfo *device;
int i;
- int jackCount = 0;
- int isInput = 0;
+ int jackCount = 0;
+ int isInput = 0;
- printf("PortAudio Test: WASAPI Jack Configuration");
+ printf("PortAudio Test: WASAPI Jack Configuration");
err = Pa_Initialize();
if( err != paNoError ) goto error;
- /* Find all WASAPI devices */
- for( i = 0; i < Pa_GetDeviceCount(); ++i )
- {
- device = Pa_GetDeviceInfo(i);
- if( Pa_GetDeviceInfo(i)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI) )
- {
- if( device->maxOutputChannels == 0 )
- {
- isInput = 1;
- }
- printf("------------------------------------------\n");
- printf("Device: %s",device->name);
- if(isInput)
- printf(" (Input) %d Channels\n",device->maxInputChannels);
- else
- printf(" (Output) %d Channels\n",device->maxOutputChannels);
- // Try to see if this WASAPI device can provide Jack information
- err = GetJackInformation(i);
- if( err != paNoError ) goto error;
- }
- }
+ /* Find all WASAPI devices */
+ for( i = 0; i < Pa_GetDeviceCount(); ++i )
+ {
+ device = Pa_GetDeviceInfo(i);
+ if( Pa_GetDeviceInfo(i)->hostApi == Pa_HostApiTypeIdToHostApiIndex(paWASAPI) )
+ {
+ if( device->maxOutputChannels == 0 )
+ {
+ isInput = 1;
+ }
+ printf("------------------------------------------\n");
+ printf("Device: %s",device->name);
+ if(isInput)
+ printf(" (Input) %d Channels\n",device->maxInputChannels);
+ else
+ printf(" (Output) %d Channels\n",device->maxOutputChannels);
+ // Try to see if this WASAPI device can provide Jack information
+ err = GetJackInformation(i);
+ if( err != paNoError ) goto error;
+ }
+ }
Pa_Terminate();
printf("Test finished.\n");
return err;
/** @file
- @ingroup test_src
- @brief Hear the latency caused by big buffers.
- Play a sine wave and change frequency based on letter input.
- @author Phil Burk <philburk@softsynth.com>, and Darren Gibbs
+ @ingroup test_src
+ @brief Hear the latency caused by big buffers.
+ Play a sine wave and change frequency based on letter input.
+ @author Phil Burk <philburk@softsynth.com>, and Darren Gibbs
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
outputParameters.device = OUTPUT_DEVICE;
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
printf("Requested output latency = %.4f seconds.\n", outputParameters.suggestedLatency );
printf("%d frames per buffer.\n.", FRAMES_PER_BUFFER );
/** @file patest_leftright.c
- @ingroup test_src
- @brief Play different tone sine waves that
- alternate between left and right channel.
+ @ingroup test_src
+ @brief Play different tone sine waves that
+ alternate between left and right channel.
- The low tone should be on the left channel.
+ The low tone should be on the left channel.
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
for( i=0; i<framesPerBuffer; i++ )
{
- // Smoothly pan between left and right.
- if( data->currentBalance < data->targetBalance )
- {
- data->currentBalance += BALANCE_DELTA;
- }
- else if( data->currentBalance > data->targetBalance )
- {
- data->currentBalance -= BALANCE_DELTA;
- }
- // Apply left/right balance.
+ // Smoothly pan between left and right.
+ if( data->currentBalance < data->targetBalance )
+ {
+ data->currentBalance += BALANCE_DELTA;
+ }
+ else if( data->currentBalance > data->targetBalance )
+ {
+ data->currentBalance -= BALANCE_DELTA;
+ }
+ // Apply left/right balance.
*out++ = data->sine[data->left_phase] * (1.0f - data->currentBalance); /* left */
- *out++ = data->sine[data->right_phase] * data->currentBalance; /* right */
-
+ *out++ = data->sine[data->right_phase] * data->currentBalance; /* right */
+
data->left_phase += 1;
if( data->left_phase >= TABLE_SIZE ) data->left_phase -= TABLE_SIZE;
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
PaStreamParameters outputParameters;
PaError err;
paTestData data;
- int i;
+ int i;
printf("Play different tone sine waves that alternate between left and right channel.\n");
printf("The low tone should be on the left channel.\n");
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
patestCallback,
&data );
if( err != paNoError ) goto error;
-
+
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Play for several seconds.\n");
for( i=0; i<4; i++ )
- {
- printf("Hear low sound on left side.\n");
- data.targetBalance = 0.01;
+ {
+ printf("Hear low sound on left side.\n");
+ data.targetBalance = 0.01;
+ Pa_Sleep( 1000 );
+
+ printf("Hear high sound on right side.\n");
+ data.targetBalance = 0.99;
Pa_Sleep( 1000 );
-
- printf("Hear high sound on right side.\n");
- data.targetBalance = 0.99;
- Pa_Sleep( 1000 );
- }
+ }
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
/** @file patest_longsine.c
- @ingroup test_src
- @brief Play a sine wave until ENTER hit.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Play a sine wave until ENTER hit.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
-
+
#include <stdio.h>
#include <math.h>
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
/** @file patest_many.c
- @ingroup test_src
- @brief Start and stop the PortAudio Driver multiple times.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Start and stop the PortAudio Driver multiple times.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paInt16;
/** @file patest_maxsines.c
- @ingroup test_src
- @brief How many sine waves can we calculate and play in less than 80% CPU Load.
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @ingroup test_src
+ @brief How many sine waves can we calculate and play in less than 80% CPU Load.
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
numForScale = data->numSines;
if( numForScale < 8 ) numForScale = 8; /* prevent pops at beginning */
scaler = 1.0f / numForScale;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
float output = 0.0;
phase += phaseInc;
if( phase >= 1.0 ) phase -= 1.0;
- output += LookupSine(data, phase);
+ output += LookupSine(data, phase);
data->phases[j] = phase;
-
+
phaseInc *= 1.02f;
if( phaseInc > MAX_PHASE_INC ) phaseInc = MIN_PHASE_INC;
}
int main(void);
int main(void)
{
- int i;
+ int i;
PaStream* stream;
PaStreamParameters outputParameters;
PaError err;
goto error;
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* Stereo output. */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output. */
/** @file patest_mono.c
- @ingroup test_src
- @brief Play a monophonic sine wave using the Portable Audio api for several seconds.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Play a monophonic sine wave using the Portable Audio api for several seconds.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
data.sine[i] = (float) (AMPLITUDE * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ));
}
data.phase = 0;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Play for %d seconds.\n", NUM_SECONDS ); fflush(stdout);
Pa_Sleep( NUM_SECONDS * 1000 );
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
printf("Test finished.\n");
return err;
/** @file patest_multi_sine.c
- @ingroup test_src
- @brief Play a different sine wave on each channel.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Play a different sine wave on each channel.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
-
+
#include <stdio.h>
#include <math.h>
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device, max channels. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- return paInvalidDevice;
+ fprintf(stderr,"Error: No default output device.\n");
+ return paInvalidDevice;
}
pdi = Pa_GetDeviceInfo(outputParameters.device);
outputParameters.channelCount = pdi->maxOutputChannels;
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = pdi->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
data.interleaved = interleaved;
data.numChannels = outputParameters.channelCount;
for (n = 0; n < data.numChannels; n++)
}
Pa_CloseStream( stream );
}
- return err;
+ return err;
}
/** @file patest_out_underflow.c
- @ingroup test_src
- @brief Count output underflows (using paOutputUnderflow flag)
- under overloaded and normal conditions.
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @ingroup test_src
+ @brief Count output underflows (using paOutputUnderflow flag)
+ under overloaded and normal conditions.
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 1; /* mono output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
- &data );
+ &data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
/* Determine number of sines required to get to 50% */
do
- {
+ {
Pa_Sleep( 100 );
load = Pa_GetStreamCpuLoad( stream );
printf("sineCount = %d, CPU load = %f\n", data.sineCount, load );
-
+
if( load < 0.3 )
{
data.sineCount += 10;
load = Pa_GetStreamCpuLoad( stream );
printf("STRESSING: sineCount = %d, CPU load = %f\n", sineCount, load );
}
-
+
printf("Counting underflows for 2 seconds.\n");
data.countUnderflows = 1;
Pa_Sleep( 2000 );
Pa_Sleep( 5000 );
safeUnderflowCount = data.outputUnderflowCount;
-
+
printf("Stop stream.\n");
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
printf("suggestedLatency = %f\n", suggestedLatency);
/** @file patest_prime.c
- @ingroup test_src
- @brief Test stream priming mode.
- @author Ross Bencina http://www.audiomulch.com/~rossb
+ @ingroup test_src
+ @brief Test stream priming mode.
+ @author Ross Bencina http://www.audiomulch.com/~rossb
*/
/*
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
-
+
#include <stdio.h>
#include <math.h>
#include "portaudio.h"
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo *timeInfo,
- PaStreamCallbackFlags statusFlags, void *userData )
+ const PaStreamCallbackTimeInfo *timeInfo,
+ PaStreamCallbackFlags statusFlags, void *userData )
{
/* Cast data passed through stream to our structure. */
paTestData *data = (paTestData*)userData;
*out++ = 0.0; /* left */
*out++ = 0.0; /* right */
--data->idleCountdown;
-
+
if( data->idleCountdown <= 0 ) result = paComplete;
break;
break;
}
}
-
+
return result;
}
paTestData data;
PaStreamParameters outputParameters;
- InitializeTestData( &data );
+ InitializeTestData( &data );
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2;
outputParameters.hostApiSpecificStreamInfo = NULL;
/* Initialize library before making any other calls. */
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
printf("PortAudio Test: Testing stream playback with no priming.\n");
printf("PortAudio Test: you should see BEEP before you hear it.\n");
printf("BEEP %d times.\n", NUM_BEEPS );
/** @file patest_read_record.c
- @ingroup test_src
- @brief Record input into an array; Save array to a file; Playback recorded
+ @ingroup test_src
+ @brief Record input into an array; Save array to a file; Playback recorded
data. Implemented using the blocking API (Pa_ReadStream(), Pa_WriteStream() )
- @author Phil Burk http://www.softsynth.com
+ @author Phil Burk http://www.softsynth.com
@author Ross Bencina rossb@audiomulch.com
*/
/*
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
int numSamples;
int numBytes;
SAMPLE max, average, val;
-
-
+
+
printf("patest_read_record.c\n"); fflush(stdout);
totalFrames = NUM_SECONDS * SAMPLE_RATE; /* Record for a few seconds. */
inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default input device.\n");
- goto error;
+ fprintf(stderr,"Error: No default input device.\n");
+ goto error;
}
inputParameters.channelCount = NUM_CHANNELS;
inputParameters.sampleFormat = PA_SAMPLE_TYPE;
err = Pa_ReadStream( stream, recordedSamples, totalFrames );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
#endif
/* Playback recorded data. -------------------------------------------- */
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = NUM_CHANNELS;
outputParameters.sampleFormat = PA_SAMPLE_TYPE;
/** @file patest_ringmix.c
- @ingroup test_src
- @brief Ring modulate inputs to left output, mix inputs to right output.
+ @ingroup test_src
+ @brief Ring modulate inputs to left output, mix inputs to right output.
*/
/*
- * $Id$
+ * $Id$
*
* This program uses the PortAudio Portable Audio Library.
* For more information see: http://www.portaudio.com
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
void *userData )
{
const float *in = (const float *) inputBuffer;
- float *out = (float *) outputBuffer;
+ float *out = (float *) outputBuffer;
float leftInput, rightInput;
unsigned int i;
/** @file patest_sine8.c
- @ingroup test_src
- @brief Test 8 bit data: play a sine wave for several seconds.
- @author Ross Bencina <rossb@audiomulch.com>
+ @ingroup test_src
+ @brief Test 8 bit data: play a sine wave for several seconds.
+ @author Ross Bencina <rossb@audiomulch.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Default output device. */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* Stereo output. */
outputParameters.sampleFormat = TEST_FORMAT;
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
/** @file patest_sine_channelmaps.c
- @ingroup test_src
- @brief Plays sine waves using sme simple channel maps.
+ @ingroup test_src
+ @brief Plays sine waves using sme simple channel maps.
Designed for use with CoreAudio, but should made to work with other APIs
- @author Bjorn Roche <bjorn@xowave.com>
+ @author Bjorn Roche <bjorn@xowave.com>
@author Ross Bencina <rossb@audiomulch.com>
@author Phil Burk <philburk@softsynth.com>
*/
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
*out++ = data->sine[data->left_phase]; /* left */
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
#endif
int i;
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
printf("Output will be mapped to channels 2 and 3 instead of 0 and 1.\n");
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
data.left_phase = data.right_phase = 0;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
PaMacCore_SetupChannelMap( &macInfo, channelMap, 4 );
for( i=0; i<4; ++i )
- printf( "channel %d name: %s\n", i, PaMacCore_GetChannelName( Pa_GetDefaultOutputDevice(), i, false ) );
+ printf( "channel %d name: %s\n", i, PaMacCore_GetChannelName( Pa_GetDefaultOutputDevice(), i, false ) );
#else
printf( "Channel mapping not supported on this platform. Reverting to normal sine test.\n" );
#endif
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_sine_formats.c
- @ingroup test_src
- @brief Play a sine wave for several seconds. Test various data formats.
- @author Phil Burk
+ @ingroup test_src
+ @brief Play a sine wave for several seconds. Test various data formats.
+ @author Phil Burk
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
/** @file patest_sine_srate_mac.c
- @ingroup test_src
- @brief Plays sine waves at 44100 and 48000,
+ @ingroup test_src
+ @brief Plays sine waves at 44100 and 48000,
and forces the hardware to change if this is a mac.
Designed for use with CoreAudio.
- @author Bjorn Roche <bjorn@xowave.com>
+ @author Bjorn Roche <bjorn@xowave.com>
@author Ross Bencina <rossb@audiomulch.com>
@author Phil Burk <philburk@softsynth.com>
*/
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
*out++ = data->sine[data->left_phase]; /* left */
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
outputParameters.hostApiSpecificStreamInfo = NULL;
#endif
err = Pa_OpenStream(
- &stream,
- NULL, /* no input */
- &outputParameters,
- sr,
- FRAMES_PER_BUFFER,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &data );
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
-
- printf("Play for %d seconds.\n", NUM_SECONDS );
- Pa_Sleep( NUM_SECONDS * 1000 );
-
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
+ &stream,
+ NULL, /* no input */
+ &outputParameters,
+ sr,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &data );
+ if( err != paNoError ) goto error;
+
+ err = Pa_StartStream( stream );
+ if( err != paNoError ) goto error;
+
+ printf("Play for %d seconds.\n", NUM_SECONDS );
+ Pa_Sleep( NUM_SECONDS * 1000 );
+
+ err = Pa_StopStream( stream );
+ if( err != paNoError ) goto error;
+
+ err = Pa_CloseStream( stream );
+ if( err != paNoError ) goto error;
}
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_sine_time.c
- @ingroup test_src
- @brief Play a sine wave for several seconds, pausing in the middle.
- Uses the Pa_GetStreamTime() call.
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @ingroup test_src
+ @brief Play a sine wave for several seconds, pausing in the middle.
+ Uses the Pa_GetStreamTime() call.
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
static void ReportStreamTime( PaStream *stream, paTestData *data )
{
PaTime streamTime, latency, outTime;
-
+
streamTime = Pa_GetStreamTime( stream );
outTime = data->outTime;
if( outTime < 0.0 )
patestCallback,
&data );
if( err != paNoError ) goto error;
-
+
/* Watch until sound is halfway finished. */
printf("Play for %d seconds.\n", NUM_SECONDS/2 ); fflush(stdout);
ReportStreamTime( stream, &data );
Pa_Sleep(100);
} while( (Pa_GetStreamTime( stream ) - startTime) < (NUM_SECONDS/2) );
-
+
/* Stop sound for 2 seconds. */
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Pause for 2 seconds.\n"); fflush(stdout);
Pa_Sleep( 2000 );
if( err != paNoError ) goto error;
startTime = Pa_GetStreamTime( stream );
-
+
printf("Play until sound is finished.\n"); fflush(stdout);
do
{
ReportStreamTime( stream, &data );
Pa_Sleep(100);
} while( (Pa_GetStreamTime( stream ) - startTime) < (NUM_SECONDS/2) );
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
Pa_Terminate();
printf("Test finished.\n");
return err;
-
+
error:
Pa_Terminate();
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
/** @file patest_start_stop.c
- @ingroup test_src
- @brief Play a sine wave for several seconds. Start and stop the stream multiple times.
-
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @ingroup test_src
+ @brief Play a sine wave for several seconds. Start and stop the stream multiple times.
+
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
*out++ = data->sine[data->left_phase]; /* left */
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
paTestData data;
int i;
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
data.left_phase = data.right_phase = 0;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_stop.c
- @ingroup test_src
- @brief Test different ways of stopping audio.
+ @ingroup test_src
+ @brief Test different ways of stopping audio.
- Test the three ways of stopping audio:
- - calling Pa_StopStream(),
- - calling Pa_AbortStream(),
- - and returning a 1 from the callback function.
+ Test the three ways of stopping audio:
+ - calling Pa_StopStream(),
+ - calling Pa_AbortStream(),
+ - and returning a 1 from the callback function.
- A long latency is set up so that you can hear the difference.
- Then a simple 8 note sequence is repeated twice.
- The program will print what you should hear.
+ A long latency is set up so that you can hear the difference.
+ Then a simple 8 note sequence is repeated twice.
+ The program will print what you should hear.
- @author Phil Burk <philburk@softsynth.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
float LookupWaveform( paTestData *data, float phase );
/******************************************************
- * Convert phase between 0.0 and 1.0 to waveform value
+ * Convert phase between 0.0 and 1.0 to waveform value
* using linear interpolation.
*/
float LookupWaveform( paTestData *data, float phase )
/* data->outTime = outTime; */
-
+
if( !data->done )
{
for( i=0; i<framesPerBuffer; i++ )
paTestData data;
int i;
float simpleTune[] = { NOTE_0, NOTE_1, NOTE_2, NOTE_3, NOTE_4, NOTE_3, NOTE_2, NOTE_1 };
-
+
printf("PortAudio Test: play song and test stopping. ask for %f seconds latency\n", LATENCY_SECONDS );
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
PaStreamParameters outputParameters;
PaStream *stream;
PaError err;
-
+
data->done = 0;
data->phase = 0.0;
data->frameCounter = 0;
data->noteCounter = 0;
data->repeatCounter = 0;
data->phase_increment = data->tune[data->noteCounter];
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = LATENCY_SECONDS;
outputParameters.hostApiSpecificStreamInfo = NULL;
-
+
err = Pa_OpenStream(
&stream,
NULL, /* no input */
/** @file patest_stop_playout.c
- @ingroup test_src
- @brief Test whether all queued samples are played when Pa_StopStream()
+ @ingroup test_src
+ @brief Test whether all queued samples are played when Pa_StopStream()
is used with a callback or read/write stream, or when the callback
returns paComplete.
- @author Ross Bencina <rossb@audiomulch.com>
+ @author Ross Bencina <rossb@audiomulch.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
float sine[TABLE_SIZE+1];
int repeatCount;
-
+
double phase;
double lowIncrement, highIncrement;
-
+
int gap1Length, toneLength, toneFadesLength, gap2Length, blipLength;
int gap1Countdown, toneCountdown, gap2Countdown, blipCountdown;
}
data->sine[TABLE_SIZE] = data->sine[0]; /* guard point for linear interpolation */
-
+
data->lowIncrement = (330. / SAMPLE_RATE) * TABLE_SIZE;
data->highIncrement = (1760. / SAMPLE_RATE) * TABLE_SIZE;
data->gap1Countdown -= count;
framesGenerated += count;
}
-
+
if( framesGenerated < frameCount && data->toneCountdown > 0 ){
count = MIN( frameCount - framesGenerated, data->toneCountdown );
for( i=0; i < count; ++i )
/* cosine-bell fade out at end */
output *= (-cos(((float)data->toneCountdown / (float)data->toneFadesLength) * M_PI) + 1.) * .5;
}
- else if( data->toneCountdown > data->toneLength - data->toneFadesLength )
+ else if( data->toneCountdown > data->toneLength - data->toneFadesLength )
{
/* cosine-bell fade in at start */
output *= (cos(((float)(data->toneCountdown - (data->toneLength - data->toneFadesLength)) / (float)data->toneFadesLength) * M_PI) + 1.) * .5;
}
output *= .5; /* play tone half as loud as blip */
-
+
*stereo++ = output;
*stereo++ = output;
data->toneCountdown--;
- }
+ }
framesGenerated += count;
}
/* cosine-bell envelope over whole blip */
output *= (-cos( ((float)data->blipCountdown / (float)data->blipLength) * 2. * M_PI) + 1.) * .5;
-
+
*stereo++ = output;
*stereo++ = output;
{
RetriggerTestSignalGenerator( data );
data->repeatCount++;
- }
+ }
}
if( framesGenerated < frameCount )
if( IsTestSignalFinished( (TestData*)userData ) )
testCallback2Finished = 1;
-
+
return paContinue;
}
PaError err;
TestData data;
float writeBuffer[ FRAMES_PER_BUFFER * 2 ];
-
+
printf("PortAudio Test: check that stopping stream plays out all queued samples. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
InitTestSignalGenerator( &data );
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
ResetTestSignalGenerator( &data );
testCallback2Finished = 0;
-
+
err = Pa_OpenStream(
&stream,
NULL, /* no input */
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
GenerateTestSignal( &data, writeBuffer, FRAMES_PER_BUFFER );
err = Pa_WriteStream( stream, writeBuffer, FRAMES_PER_BUFFER );
if( err != paNoError ) goto error;
-
+
}while( !IsTestSignalFinished( &data ) );
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
/* -------------------------------------------------------------------------- */
-
+
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
-
+
error:
Pa_Terminate();
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
/** @file patest_suggested_vs_streaminfo_latency.c
- @ingroup test_src
- @brief Print suggested vs. PaStreamInfo reported actual latency
- @author Ross Bencina <rossb@audiomulch.com>
-
- Opens streams with a sequence of suggested latency values
- from 0 to 2 seconds in .5ms intervals and gathers the resulting actual
- latency values. Output a csv file and graph suggested vs. actual. Run
- with framesPerBuffer unspecified, powers of 2 and multiples of 50 and
- prime number buffer sizes.
+ @ingroup test_src
+ @brief Print suggested vs. PaStreamInfo reported actual latency
+ @author Ross Bencina <rossb@audiomulch.com>
+
+ Opens streams with a sequence of suggested latency values
+ from 0 to 2 seconds in .5ms intervals and gathers the resulting actual
+ latency values. Output a csv file and graph suggested vs. actual. Run
+ with framesPerBuffer unspecified, powers of 2 and multiples of 50 and
+ prime number buffer sizes.
*/
/*
* $Id: patest_sine.c 1368 2008-03-01 00:38:27Z rossb $
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <stdio.h>
if( inputParameters.device == -1 ){
inputParameters.device = Pa_GetDefaultInputDevice();
if (inputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default input device available.\n");
- goto error;
+ fprintf(stderr,"Error: No default input device available.\n");
+ goto error;
}
}else{
deviceInfo = Pa_GetDeviceInfo(inputParameters.device);
usage();
}
}
-
+
inputParameters.channelCount = NUM_CHANNELS;
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
inputParameters.hostApiSpecificStreamInfo = NULL;
if( outputParameters.device == -1 ){
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device available.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device available.\n");
+ goto error;
}
}else{
deviceInfo = Pa_GetDeviceInfo(outputParameters.device);
err = Pa_OpenStream(
&stream,
- &inputParameters,
+ &inputParameters,
NULL, /* no output */
sampleRate,
framesPerBuffer,
err = Pa_OpenStream(
&stream,
- &inputParameters,
+ &inputParameters,
&outputParameters,
sampleRate,
framesPerBuffer,
Pa_Terminate();
printf("# Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
individualPlotFramesPerBufferValues = [0,64,128,256,512] #output separate plots for these
-isFirst = True
+isFirst = True
for framesPerBuffer in compositeTestFramesPerBufferValues:
commandString = testExeName + " " + str(inputDeviceIndex) + " " + str(outputDeviceIndex) + " " + str(sampleRate) + " " + str(framesPerBuffer) + ' > ' + dataFileName
gcf().text(0.1, 0.0,
"patest_suggested_vs_streaminfo_latency\n%s\n%s\n%s\n"%(d.inputDevice,d.outputDevice,d.sampleRate))
pdfFile.savefig()
-
-
+
+
figure(2) # composite plot, includes all compositeTestFramesPerBufferValues
if isFirst:
plot( d.suggestedLatency, d.suggestedLatency, label="Suggested latency" )
-
+
plot( d.suggestedLatency, d.halfDuplexOutputLatency )
plot( d.suggestedLatency, d.halfDuplexInputLatency )
plot( d.suggestedLatency, d.fullDuplexOutputLatency )
/** @file patest_sync.c
- @ingroup test_src
- @brief Test time stamping and synchronization of audio and video.
+ @ingroup test_src
+ @brief 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.
+ 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:
- -# Foreground requests a beep.
- -# Background randomly schedules a beep.
- -# Foreground waits for the beep to be heard based on PaUtil_GetTime().
- -# Foreground outputs video (printf) in sync with audio.
- -# Repeat.
-
- @author Phil Burk http://www.softsynth.com
+ Sequence of events:
+ -# Foreground requests a beep.
+ -# Background randomly schedules a beep.
+ -# Foreground waits for the beep to be heard based on PaUtil_GetTime().
+ -# Foreground outputs video (printf) in sync with audio.
+ -# Repeat.
+
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo *timeInfo,
- PaStreamCallbackFlags statusFlags, void *userData )
+ const PaStreamCallbackTimeInfo *timeInfo,
+ PaStreamCallbackFlags statusFlags, void *userData )
{
/* Cast data passed through stream to our structure. */
paTestData *data = (paTestData*)userData;
/* Initialize library before making any other calls. */
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice();
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
outputParameters.suggestedLatency = (double)LATENCY_MSEC / 1000;
/* Open an audio I/O stream. */
- err = Pa_OpenStream(
- &stream,
- NULL, /* no input */
- &outputParameters,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &DATA );
- if( err != paNoError ) goto error;
+ err = Pa_OpenStream(
+ &stream,
+ NULL, /* no input */
+ &outputParameters,
+ SAMPLE_RATE,
+ FRAMES_PER_BUFFER, /* frames per buffer */
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &DATA );
+ if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
/** @file patest_timing.c
- @ingroup test_src
- @brief Play a sine wave for several seconds, and spits out a ton of timing info while it's at it. Based on patest_sine.c
- @author Bjorn Roche
- @author Ross Bencina <rossb@audiomulch.com>
+ @ingroup test_src
+ @brief Play a sine wave for several seconds, and spits out a ton of timing info while it's at it. Based on patest_sine.c
+ @author Bjorn Roche
+ @author Ross Bencina <rossb@audiomulch.com>
@author Phil Burk <philburk@softsynth.com>
*/
/*
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
timeInfo->outputBufferDacTime );
printf( "getStreamTime() returns: %g\n", Pa_GetStreamTime(data->stream) - data->start );
-
+
for( i=0; i<framesPerBuffer; i++ )
{
*out++ = data->sine[data->left_phase]; /* left */
data->right_phase += 3; /* higher pitch so we can distinguish left and right. */
if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
}
-
+
return paContinue;
}
paTestData data;
int i;
-
+
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
data.left_phase = data.right_phase = 0;
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
Pa_Terminate();
printf("Test finished.\n");
printf("The tone should have been heard for about 5 seconds and all the timing info above should report that about 5 seconds elapsed (except Adc, which is undefined since there was no input device opened).\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_toomanysines.c
- @ingroup test_src
- @brief Play more sine waves than we can handle in real time as a stress test.
+ @ingroup test_src
+ @brief Play more sine waves than we can handle in real time as a stress test.
@todo This may not be needed now that we have "patest_out_overflow.c".
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
- &data );
+ &data );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
load = Pa_GetStreamCpuLoad( stream );
printf("numSines = %d, CPU load = %f\n", data.numSines, load );
-
- if( load < 0.3 )
- {
- data.numSines += 10;
- }
- else if( load < 0.4 )
- {
- data.numSines += 2;
- }
- else
- {
- data.numSines += 1;
- }
-
+
+ if( load < 0.3 )
+ {
+ data.numSines += 10;
+ }
+ else if( load < 0.4 )
+ {
+ data.numSines += 2;
+ }
+ else
+ {
+ data.numSines += 1;
+ }
+
}
while( load < 0.5 );
-
+
/* Calculate target stress value then ramp up to that level*/
numStress = (int) (2.0 * data.numSines * MAX_LOAD );
if( numStress > MAX_SINES )
- numStress = MAX_SINES;
+ numStress = MAX_SINES;
for( ; data.numSines < numStress; data.numSines+=2 )
{
Pa_Sleep( 200 );
load = Pa_GetStreamCpuLoad( stream );
printf("STRESSING: numSines = %d, CPU load = %f\n", data.numSines, load );
}
-
+
printf("Suffer for 5 seconds.\n");
Pa_Sleep( 5000 );
-
+
printf("Stop stream.\n");
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;
-
+
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
-
+
Pa_Terminate();
printf("Test finished.\n");
return err;
/** @file patest_two_rates.c
- @ingroup test_src
- @brief Play two streams at different rates to make sure they don't interfere.
- @author Phil Burk <philburk@softsynth.com>
+ @ingroup test_src
+ @brief Play two streams at different rates to make sure they don't interfere.
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
** that could mess up the system like calling malloc() or free().
*/
static int patestCallback( const void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
+ void *userData )
{
paTestData *data = (paTestData*)userData;
float *out = (float*)outputBuffer;
data->phase += FREQ_INCR;
if( data->phase >= (2.0 * M_PI) ) data->phase -= (2.0 * M_PI);
}
- data->numFrames += 1;
+ data->numFrames += 1;
return 0;
}
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
- fprintf(stderr,"Error: No default output device.\n");
- goto error;
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
}
outputParameters.channelCount = 2; /* stereo output */
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
- /* Start first stream. **********************/
+ /* Start first stream. **********************/
err = Pa_OpenStream(
- &stream1,
- NULL, /* no input */
- &outputParameters,
- SAMPLE_RATE_1,
- FRAMES_PER_BUFFER,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &data1 );
- if( err != paNoError ) goto error;
+ &stream1,
+ NULL, /* no input */
+ &outputParameters,
+ SAMPLE_RATE_1,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &data1 );
+ if( err != paNoError ) goto error;
err = Pa_StartStream( stream1 );
if( err != paNoError ) goto error;
/* Start second stream. **********************/
err = Pa_OpenStream(
- &stream2,
- NULL, /* no input */
- &outputParameters,
- SAMPLE_RATE_2,
- FRAMES_PER_BUFFER,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &data2 );
+ &stream2,
+ NULL, /* no input */
+ &outputParameters,
+ SAMPLE_RATE_2,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ patestCallback,
+ &data2 );
if( err != paNoError ) goto error;
err = Pa_StartStream( stream2 );
if( err != paNoError ) goto error;
Pa_Sleep( 3 * 1000 );
-
+
err = Pa_StopStream( stream2 );
if( err != paNoError ) goto error;
Pa_Sleep( 3 * 1000 );
-
+
err = Pa_StopStream( stream1 );
if( err != paNoError ) goto error;
Pa_CloseStream( stream2 );
Pa_CloseStream( stream1 );
-
+
Pa_Terminate();
-
+
printf("NumFrames = %d on stream1, %d on stream2.\n", data1.numFrames, data2.numFrames );
printf("Test finished.\n");
return err;
/** @file patest_underflow.c
- @ingroup test_src
- @brief Simulate an output buffer underflow condition.
- Tests whether the stream can be stopped when underflowing buffers.
- @author Ross Bencina <rossb@audiomulch.com>
- @author Phil Burk <philburk@softsynth.com>
+ @ingroup test_src
+ @brief Simulate an output buffer underflow condition.
+ Tests whether the stream can be stopped when underflowing buffers.
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
data.left_phase = data.right_phase = data.sleepTime = 0;
err = Pa_Initialize();
if( err != paNoError ) goto error;
-
+
outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
if (outputParameters.device == paNoDevice) {
fprintf(stderr,"Error: No default output device.\n");
/** @file patest_unplug.c
- @ingroup test_src
- @brief Debug a crash involving unplugging a USB device.
- @author Phil Burk http://www.softsynth.com
+ @ingroup test_src
+ @brief Debug a crash involving unplugging a USB device.
+ @author Phil Burk http://www.softsynth.com
*/
/*
* $Id$
printf("Test unplugging a USB device.\n");
if( argc > 1 ) {
- inputDevice = outputDevice = atoi( args[1] );
- printf("Using device number %d.\n\n", inputDevice );
+ inputDevice = outputDevice = atoi( args[1] );
+ printf("Using device number %d.\n\n", inputDevice );
} else {
- printf("Using default device.\n\n" );
+ printf("Using default device.\n\n" );
}
memset(&data, 0, sizeof(data));
/** @file patest_wire.c
- @ingroup test_src
- @brief Pass input directly to output.
+ @ingroup test_src
+ @brief Pass input directly to output.
- Note that some HW devices, for example many ISA audio cards
- on PCs, do NOT support full duplex! For a PC, you normally need
- a PCI based audio card such as the SBLive.
+ Note that some HW devices, for example many ISA audio cards
+ on PCs, do NOT support full duplex! For a PC, you normally need
+ a PCI based audio card such as the SBLive.
+
+ @author Phil Burk http://www.softsynth.com
- @author Phil Burk http://www.softsynth.com
-
While adapting to V19-API, I excluded configs with framesPerCallback=0
because of an assert in file pa_common/pa_process.c. Pieter, Oct 9, 2003.
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
if( (statusFlags & paOutputOverflow) != 0 ) config->numOutputOverflows += 1;
if( (statusFlags & paPrimingOutput) != 0 ) config->numPrimingOutputs += 1;
config->numCallbacks += 1;
-
+
inChannel=0, outChannel=0;
while( !(inDone && outDone) )
{
}
else if( err != paNoError ) goto error;
}
- }
+ }
}
}
}
PaError err = paNoError;
PaStream *stream;
PaStreamParameters inputParameters, outputParameters;
-
+
printf("input %sinterleaved!\n", (config->isInputInterleaved ? " " : "NOT ") );
printf("output %sinterleaved!\n", (config->isOutputInterleaved ? " " : "NOT ") );
printf("input channels = %d\n", config->numInputChannels );
wireCallback,
config );
if( err != paNoError ) goto error;
-
+
err = Pa_StartStream( stream );
if( err != paNoError ) goto error;
-
+
printf("Now recording and playing. - Hit ENTER for next configuration, or 'q' to quit.\n"); fflush(stdout);
c = getchar();
-
+
printf("Closing stream.\n");
err = Pa_CloseStream( stream );
if( err != paNoError ) goto error;
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
#include <time.h>
#include <math.h>
-#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
+#define _WIN32_WINNT 0x0501 /* for GetNativeSystemInfo */
#include <windows.h> /* required when using pa_win_wmme.h */
#include <mmsystem.h> /* required when using pa_win_wmme.h */
osVersionInfoEx.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
GetVersionEx( &osVersionInfoEx );
-
+
if( osVersionInfoEx.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS ){
switch( osVersionInfoEx.dwMinorVersion ){
case 0: osName = "Windows 95"; break;
- case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
+ case 10: osName = "Windows 98"; break; // could also be 98SE (I've seen code discriminate based
// on osInfo.Version.Revision.ToString() == "2222A")
case 90: osName = "Windows Me"; break;
}
}break;
}break;
case 6:switch( osVersionInfoEx.dwMinorVersion ){
- case 0:
+ case 0:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows Vista";
else
osName = "Windows Server 2008";
break;
- case 1:
+ case 1:
if( osVersionInfoEx.wProductType == VER_NT_WORKSTATION )
osName = "Windows 7";
else
}
else if(osVersionInfoEx.wProductType == VER_NT_SERVER)
{
- if(osVersionInfoEx.dwMinorVersion == 0)
+ if(osVersionInfoEx.dwMinorVersion == 0)
{
if((osVersionInfoEx.wSuiteMask & VER_SUITE_DATACENTER) == VER_SUITE_DATACENTER)
osProductType = "Datacenter Server"; // Windows 2000 Datacenter Server
fprintf( fp, "OS name and edition: %s %s\n", osName, osProductType );
- fprintf( fp, "OS version: %d.%d.%d %S\n",
- osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
+ fprintf( fp, "OS version: %d.%d.%d %S\n",
+ osVersionInfoEx.dwMajorVersion, osVersionInfoEx.dwMinorVersion,
osVersionInfoEx.dwBuildNumber, osVersionInfoEx.szCSDVersion );
fprintf( fp, "Processor architecture: %s\n", processorArchitecture );
fprintf( fp, "WoW64 process: %s\n", IsWow64() ? "Yes" : "No" );
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
double phaseIncrement;
volatile int fadeIn;
volatile int fadeOut;
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
float x = data->sine[(int)data->phase];
data->phase += data->phaseIncrement;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
x *= data->amp;
if( data->fadeIn ){
data->amp -= .001;
}
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
if( data->amp > 0 )
return paContinue;
else
#define NO 0
-static int playUntilKeyPress( int deviceIndex, float sampleRate,
+static int playUntilKeyPress( int deviceIndex, float sampleRate,
int framesPerUserBuffer, int framesPerWmmeBuffer, int wmmeBufferCount )
{
PaStreamParameters outputParameters;
outputParameters.hostApiSpecificStreamInfo = NULL;
wmmeStreamInfo.size = sizeof(PaWinMmeStreamInfo);
- wmmeStreamInfo.hostApiType = paMME;
+ wmmeStreamInfo.hostApiType = paMME;
wmmeStreamInfo.version = 1;
wmmeStreamInfo.flags = paWinMmeUseLowLevelLatencyParameters | paWinMmeDontThrottleOverloadedProcessingThread;
wmmeStreamInfo.framesPerBuffer = framesPerWmmeBuffer;
}
/*
- ideas:
+ ideas:
o- could be testing with 80% CPU load
o- could test with different channel counts
*/
if( argc > 5 )
usage(wmmeHostApiIndex);
- deviceIndex = wmmeHostApiInfo->defaultOutputDevice;
- if( argc >= 2 ){
+ deviceIndex = wmmeHostApiInfo->defaultOutputDevice;
+ if( argc >= 2 ){
deviceIndex = -1;
- if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
+ if( sscanf( argv[1], "%d", &deviceIndex ) != 1 )
usage(wmmeHostApiIndex);
if( deviceIndex < 0 || deviceIndex >= Pa_GetDeviceCount() || Pa_GetDeviceInfo(deviceIndex)->hostApi != wmmeHostApiIndex ){
usage(wmmeHostApiIndex);
}
- }
+ }
printf( "Using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
- data.phase = 0;
+ data.phase = 0;
resultsFp = fopen( "results.txt", "at" );
fprintf( resultsFp, "*** WMME smallest working output buffer sizes\n" );
printTimeAndDate( resultsFp );
printWindowsVersionInfo( resultsFp );
-
+
fprintf( resultsFp, "audio device: %s\n", Pa_GetDeviceInfo( deviceIndex )->name );
fflush( resultsFp );
fprintf( resultsFp, "Buffer count, Smallest working buffer size (frames), Smallest working buffering latency (frames), Smallest working buffering latency (Seconds)\n" );
for( wmmeBufferCount = wmmeMinBufferCount; wmmeBufferCount <= wmmeMaxBufferCount; ++wmmeBufferCount ){
-
+
printf( "Test %d of %d\n", (wmmeBufferCount - wmmeMinBufferCount) + 1, (wmmeMaxBufferCount-wmmeMinBufferCount) + 1 );
printf( "Testing with %d buffers...\n", wmmeBufferCount );
}else{
min = mid + 1;
}
-
+
}while( (min <= max) && (testResult == YES || testResult == NO) );
smallestWorkingBufferingLatencyFrames = smallestWorkingBufferSize * (wmmeBufferCount - 1);
fprintf( resultsFp, "###\n" );
fclose( resultsFp );
-
+
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
typedef struct
{
float sine[TABLE_SIZE];
- double phase;
+ double phase;
}
paTestData;
(void) timeInfo; /* Prevent unused variable warnings. */
(void) statusFlags;
(void) inputBuffer;
-
+
for( i=0; i<framesPerBuffer; i++ )
{
float x = data->sine[(int)data->phase];
data->phase += 20;
if( data->phase >= TABLE_SIZE ){
- data->phase -= TABLE_SIZE;
- }
+ data->phase -= TABLE_SIZE;
+ }
- for( j = 0; j < CHANNEL_COUNT; ++j ){
+ for( j = 0; j < CHANNEL_COUNT; ++j ){
*out++ = x;
- }
- }
-
+ }
+ }
+
return paContinue;
}
err = Pa_Initialize();
if( err != paNoError ) goto error;
- deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
- if( argc == 2 ){
- sscanf( argv[1], "%d", &deviceIndex );
- }
+ deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
+ if( argc == 2 ){
+ sscanf( argv[1], "%d", &deviceIndex );
+ }
- printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
+ printf( "using device id %d (%s)\n", deviceIndex, Pa_GetDeviceInfo(deviceIndex)->name );
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
- data.phase = 0;
+ data.phase = 0;
outputParameters.device = deviceIndex;
outputParameters.channelCount = CHANNEL_COUNT;
outputParameters.hostApiSpecificStreamInfo = NULL;
wmmeStreamInfo.size = sizeof(PaWinMmeStreamInfo);
- wmmeStreamInfo.hostApiType = paMME;
+ wmmeStreamInfo.hostApiType = paMME;
wmmeStreamInfo.version = 1;
wmmeStreamInfo.flags = paWinMmeUseLowLevelLatencyParameters | paWinMmeDontThrottleOverloadedProcessingThread;
wmmeStreamInfo.framesPerBuffer = WMME_FRAMES_PER_BUFFER;
wmmeStreamInfo.bufferCount = WMME_BUFFER_COUNT;
outputParameters.hostApiSpecificStreamInfo = &wmmeStreamInfo;
-
- if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
- printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
- }else{
- printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
- }
+
+ if( Pa_IsFormatSupported( 0, &outputParameters, SAMPLE_RATE ) == paFormatIsSupported ){
+ printf( "Pa_IsFormatSupported reports device will support %d channels.\n", CHANNEL_COUNT );
+ }else{
+ printf( "Pa_IsFormatSupported reports device will not support %d channels.\n", CHANNEL_COUNT );
+ }
err = Pa_OpenStream(
&stream,
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_write_stop.c
- @brief Play a few seconds of silence followed by a few cycles of a sine wave. Tests to make sure that pa_StopStream() completes playback in blocking I/O
- @author Bjorn Roche of XO Audio (www.xoaudio.com)
- @author Ross Bencina
- @author Phil Burk
+ @brief Play a few seconds of silence followed by a few cycles of a sine wave. Tests to make sure that pa_StopStream() completes playback in blocking I/O
+ @author Bjorn Roche of XO Audio (www.xoaudio.com)
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$
*/
/*
- * The text above constitutes the entire PortAudio license; however,
+ * The text above constitutes the entire PortAudio license; however,
* the PortAudio community also makes the following non-binding requests:
*
* Any person wishing to distribute modifications to the Software is
* requested to send the modifications to the original developer so that
- * they can be incorporated into the canonical version. It is also
- * requested that these non-binding requests be included along with the
+ * they can be incorporated into the canonical version. It is also
+ * requested that these non-binding requests be included along with the
* license above.
*/
const int framesBy2 = FRAMES_PER_BUFFER >> 1;
const float framesBy2f = (float) framesBy2 ;
-
+
printf( "PortAudio Test: output silence, followed by one buffer of a ramped sine wave. SR = %d, BufSize = %d\n",
SAMPLE_RATE, FRAMES_PER_BUFFER);
-
+
/* initialise sinusoidal wavetable */
for( i=0; i<TABLE_SIZE; i++ )
{
sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
}
-
+
err = Pa_Initialize();
if( err != paNoError ) goto error;
{
err = Pa_WriteStream( stream, buffer, FRAMES_PER_BUFFER );
if( err != paNoError ) goto error;
- }
+ }
/* play a non-silent buffer once */
for( j=0; j < FRAMES_PER_BUFFER; j++ )
{
float ramp = 1;
if( j < framesBy2 )
- ramp = j / framesBy2f;
+ ramp = j / framesBy2f;
else
- ramp = (FRAMES_PER_BUFFER - j) / framesBy2f ;
+ ramp = (FRAMES_PER_BUFFER - j) / framesBy2f ;
buffer[j][0] = sine[left_phase] * ramp; /* left */
buffer[j][1] = sine[right_phase] * ramp; /* right */
Pa_Terminate();
printf("Test finished.\n");
-
+
return err;
error:
Pa_Terminate();
/** @file patest_write_stop_threads.c
- @brief Call Pa_StopStream() from another thread to see if PortAudio hangs.
- @author Bjorn Roche of XO Audio (www.xoaudio.com)
- @author Ross Bencina
- @author Phil Burk
+ @brief Call Pa_StopStream() from another thread to see if PortAudio hangs.
+ @author Bjorn Roche of XO Audio (www.xoaudio.com)
+ @author Ross Bencina
+ @author Phil Burk
*/
/*
* $Id$