Roll-up of SVN hotplug branch at most recent revision (r1677), based at the same point in the master revision history as it was originally applied.

This commit is contained in:
Ross Bencina 2016-09-03 22:22:52 +10:00
commit d13fcd8ea9
27 changed files with 2117 additions and 1435 deletions

View file

@ -9,7 +9,7 @@
@author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
* $Id: patest_leftright.c 1661 2011-04-28 18:54:46Z rob_bielik $
*
* This program uses the PortAudio Portable Audio Library.
* For more information see: http://www.portaudio.com
@ -90,17 +90,17 @@ static int patestCallback( const void *inputBuffer,
{
// 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 */
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. */
@ -118,7 +118,7 @@ int main(void)
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");
@ -159,7 +159,7 @@ int main(void)
printf("Play for several seconds.\n");
for( i=0; i<4; i++ )
{
{
printf("Hear low sound on left side.\n");
data.targetBalance = 0.01;
Pa_Sleep( 1000 );
@ -167,7 +167,7 @@ int main(void)
printf("Hear high sound on right side.\n");
data.targetBalance = 0.99;
Pa_Sleep( 1000 );
}
}
err = Pa_StopStream( stream );
if( err != paNoError ) goto error;

View file

@ -6,7 +6,7 @@
@author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
* $Id: patest_out_underflow.c 1661 2011-04-28 18:54:46Z rob_bielik $
*
* This program uses the PortAudio Portable Audio Library.
* For more information see: http://www.portaudio.com
@ -159,8 +159,8 @@ int main(void)
/* Determine number of sines required to get to 50% */
do
{
Pa_Sleep( 100 );
{
Pa_Sleep( 100 );
load = Pa_GetStreamCpuLoad( stream );
printf("sineCount = %d, CPU load = %f\n", data.sineCount, load );
@ -168,7 +168,7 @@ int main(void)
if( load < 0.3 )
{
data.sineCount += 10;
}
}
else if( load < 0.4 )
{
data.sineCount += 2;

View file

@ -89,7 +89,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
timeInfo->currentTime,
timeInfo->outputBufferDacTime );
printf( "getStreamTime() returns: %g\n", Pa_GetStreamTime(data->stream) - data->start );
printf( "getStreamTime() returns: %g\n", Pa_GetStreamTime(data->stream)-data->start );
for( i=0; i<framesPerBuffer; i++ )
{

View file

@ -4,7 +4,7 @@
@author Phil Burk <philburk@softsynth.com>
*/
/*
* $Id$
* $Id: patest_two_rates.c 1661 2011-04-28 18:54:46Z rob_bielik $
*
* Author: Phil Burk http://www.softsynth.com
*
@ -64,11 +64,11 @@ typedef struct
} 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().
*/
** 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 patestCallback( const void *inputBuffer, void *outputBuffer,
unsigned long framesPerBuffer,
unsigned long framesPerBuffer,
const PaStreamCallbackTimeInfo* timeInfo,
PaStreamCallbackFlags statusFlags,
void *userData )
@ -119,17 +119,17 @@ int main(void)
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
outputParameters.hostApiSpecificStreamInfo = NULL;
/* Start first stream. **********************/
/* Start first stream. **********************/
err = Pa_OpenStream(
&stream1,
&stream1,
NULL, /* no input */
&outputParameters,
SAMPLE_RATE_1,
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;
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;
@ -138,14 +138,14 @@ int main(void)
/* Start second stream. **********************/
err = Pa_OpenStream(
&stream2,
&stream2,
NULL, /* no input */
&outputParameters,
SAMPLE_RATE_2,
SAMPLE_RATE_2,
FRAMES_PER_BUFFER,
paClipOff, /* we won't output out of range samples so don't bother clipping them */
patestCallback,
&data2 );
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 );

View file

@ -0,0 +1,48 @@
#include <stdio.h>
#include <assert.h>
#include "portaudio.h"
void printDevices()
{
int deviceCount = Pa_GetDeviceCount();
int i;
for( i=0; i < deviceCount; ++i ){
const PaDeviceInfo *deviceInfo = Pa_GetDeviceInfo(i);
const PaHostApiInfo *hostApiInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
assert( deviceInfo != 0 );
printf( "%d %s (%s)\n", i, deviceInfo->name, hostApiInfo->name );
}
}
static void devicesChangedCallback(void* p)
{
(void)p;
printf( "Portaudio device list have changed!\n" );
}
int main(int argc, char* argv[])
{
Pa_Initialize();
Pa_SetDevicesChangedCallback(NULL, devicesChangedCallback);
for(;;){
printDevices();
printf( "press [enter] to update the device list. or q + [enter] to quit.\n" );
if( getchar() == 'q' )
break;
Pa_UpdateAvailableDeviceList();
}
Pa_Terminate();
return 0;
}