Clean up whitespace in examples/ in preparation for .editorconfig. Convert tabs to 4 spaces. Indent by 4 spaces. Strip trailing whitespace. Ensure EOL at EOF. (#416)
This commit is contained in:
parent
f476839ab8
commit
238d8db31a
15 changed files with 252 additions and 252 deletions
|
|
@ -1,7 +1,7 @@
|
|||
/** @file pa_devs.c
|
||||
@ingroup examples_src
|
||||
@ingroup examples_src
|
||||
@brief List available devices, including device information.
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
|
||||
@note Define PA_USE_ASIO=0 to compile this code on Windows without
|
||||
ASIO support.
|
||||
|
|
@ -34,13 +34,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -106,14 +106,14 @@ int main(void)
|
|||
PaStreamParameters inputParameters, outputParameters;
|
||||
PaError err;
|
||||
|
||||
|
||||
|
||||
err = Pa_Initialize();
|
||||
if( err != paNoError )
|
||||
{
|
||||
printf( "ERROR: Pa_Initialize returned 0x%x\n", err );
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
printf( "PortAudio version: 0x%08X\n", Pa_GetVersion());
|
||||
printf( "Version text: '%s'\n", Pa_GetVersionInfo()->versionText );
|
||||
|
||||
|
|
@ -124,13 +124,13 @@ int main(void)
|
|||
err = numDevices;
|
||||
goto error;
|
||||
}
|
||||
|
||||
|
||||
printf( "Number of devices = %d\n", numDevices );
|
||||
for( i=0; i<numDevices; i++ )
|
||||
{
|
||||
deviceInfo = Pa_GetDeviceInfo( i );
|
||||
printf( "--------------------------------------- device #%d\n", i );
|
||||
|
||||
|
||||
/* Mark global and API specific default devices */
|
||||
defaultDisplayed = 0;
|
||||
if( i == Pa_GetDefaultInputDevice() )
|
||||
|
|
@ -144,7 +144,7 @@ int main(void)
|
|||
printf( "[ Default %s Input", hostInfo->name );
|
||||
defaultDisplayed = 1;
|
||||
}
|
||||
|
||||
|
||||
if( i == Pa_GetDefaultOutputDevice() )
|
||||
{
|
||||
printf( (defaultDisplayed ? "," : "[") );
|
||||
|
|
@ -154,7 +154,7 @@ int main(void)
|
|||
else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultOutputDevice )
|
||||
{
|
||||
const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
|
||||
printf( (defaultDisplayed ? "," : "[") );
|
||||
printf( (defaultDisplayed ? "," : "[") );
|
||||
printf( " Default %s Output", hostInfo->name );
|
||||
defaultDisplayed = 1;
|
||||
}
|
||||
|
|
@ -188,7 +188,7 @@ int main(void)
|
|||
long minLatency, maxLatency, preferredLatency, granularity;
|
||||
|
||||
err = PaAsio_GetAvailableLatencyValues( i,
|
||||
&minLatency, &maxLatency, &preferredLatency, &granularity );
|
||||
&minLatency, &maxLatency, &preferredLatency, &granularity );
|
||||
|
||||
printf( "ASIO minimum buffer size = %ld\n", minLatency );
|
||||
printf( "ASIO maximum buffer size = %ld\n", maxLatency );
|
||||
|
|
@ -210,7 +210,7 @@ int main(void)
|
|||
inputParameters.sampleFormat = paInt16;
|
||||
inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
|
||||
inputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
|
||||
|
||||
outputParameters.device = i;
|
||||
outputParameters.channelCount = deviceInfo->maxOutputChannels;
|
||||
outputParameters.sampleFormat = paInt16;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file pa_fuzz.c
|
||||
@ingroup examples_src
|
||||
@ingroup examples_src
|
||||
@brief Distort input like a fuzz box.
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -116,7 +116,7 @@ static int fuzzCallback( const void *inputBuffer, void *outputBuffer,
|
|||
*out++ = *in++; /* right - clean */
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return paContinue;
|
||||
}
|
||||
|
||||
|
|
@ -133,8 +133,8 @@ int main(void)
|
|||
|
||||
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 = 2; /* stereo input */
|
||||
inputParameters.sampleFormat = PA_SAMPLE_TYPE;
|
||||
|
|
@ -143,8 +143,8 @@ int main(void)
|
|||
|
||||
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 = PA_SAMPLE_TYPE;
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
/** @file paex_mono_asio_channel_select.c
|
||||
@ingroup examples_src
|
||||
@brief Play a monophonic sine wave on a specific ASIO channel.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@author Phil Burk <philburk@softsynth.com>
|
||||
@ingroup examples_src
|
||||
@brief Play a monophonic sine wave on a specific ASIO channel.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@author Phil Burk <philburk@softsynth.com>
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
|
|
@ -36,13 +36,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -114,7 +114,7 @@ int main(void)
|
|||
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;
|
||||
|
||||
|
|
@ -123,7 +123,7 @@ int main(void)
|
|||
outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
|
||||
outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
|
||||
|
||||
/* Use an ASIO specific structure. WARNING - this is not portable. */
|
||||
/* Use an ASIO specific structure. WARNING - this is not portable. */
|
||||
asioOutputInfo.size = sizeof(PaAsioStreamInfo);
|
||||
asioOutputInfo.hostApiType = paASIO;
|
||||
asioOutputInfo.version = 1;
|
||||
|
|
@ -145,16 +145,16 @@ int main(void)
|
|||
|
||||
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;
|
||||
|
|
|
|||
|
|
@ -1,21 +1,21 @@
|
|||
/** @file paex_ocean_shore.c
|
||||
@ingroup examples_src
|
||||
@brief Generate Pink Noise using Gardner method, and make "waves". Provides an example of how to
|
||||
/** @file paex_ocean_shore.c
|
||||
@ingroup examples_src
|
||||
@brief Generate Pink Noise using Gardner method, and make "waves". Provides an example of how to
|
||||
post stuff to/from the audio callback using lock-free FIFOs implemented by the PA ringbuffer.
|
||||
|
||||
Optimization suggested by James McCartney uses a tree
|
||||
to select which random value to replace.
|
||||
Optimization suggested by James McCartney uses a tree
|
||||
to select which random value to replace.
|
||||
<pre>
|
||||
x x x x x x x x x x x x x x x x
|
||||
x x x x x x x x
|
||||
x x x x
|
||||
x x
|
||||
x
|
||||
</pre>
|
||||
Tree is generated by counting trailing zeros in an increasing index.
|
||||
When the index is zero, no random number is selected.
|
||||
x x x x x x x x x x x x x x x x
|
||||
x x x x x x x x
|
||||
x x x x
|
||||
x x
|
||||
x
|
||||
</pre>
|
||||
Tree is generated by counting trailing zeros in an increasing index.
|
||||
When the index is zero, no random number is selected.
|
||||
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
Robert Bielik
|
||||
*/
|
||||
/*
|
||||
|
|
@ -46,13 +46,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -80,7 +80,7 @@ typedef struct
|
|||
}
|
||||
PinkNoise;
|
||||
|
||||
typedef struct
|
||||
typedef struct
|
||||
{
|
||||
float bq_b0;
|
||||
float bq_b1;
|
||||
|
|
@ -213,7 +213,7 @@ unsigned GenerateWave( OceanWave* wave, float* output, unsigned noOfFrames )
|
|||
targetLevel = wave->wave_envelope_max_level;
|
||||
}
|
||||
/* Calculate lowpass biquad coeffs
|
||||
|
||||
|
||||
alpha = sin(w0)/(2*Q)
|
||||
|
||||
b0 = (1 - cos(w0))/2
|
||||
|
|
@ -324,8 +324,8 @@ paTestData;
|
|||
static int patestCallback(const void* inputBuffer,
|
||||
void* outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo* timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
const PaStreamCallbackTimeInfo* timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
void* userData)
|
||||
{
|
||||
int i;
|
||||
|
|
@ -427,8 +427,8 @@ int main(void)
|
|||
/* Open a stereo PortAudio stream so we can hear the result. */
|
||||
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Take the 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, most likely supported. */
|
||||
outputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
|
|
@ -518,7 +518,7 @@ int main(void)
|
|||
{
|
||||
PaUtil_FreeMemory(data.rBufFromRTData);
|
||||
}
|
||||
|
||||
|
||||
Pa_Sleep(1000);
|
||||
|
||||
Pa_Terminate();
|
||||
|
|
|
|||
|
|
@ -1,20 +1,20 @@
|
|||
/** @file paex_pink.c
|
||||
@ingroup examples_src
|
||||
@brief Generate Pink Noise using Gardner method.
|
||||
@ingroup examples_src
|
||||
@brief Generate Pink Noise using Gardner method.
|
||||
|
||||
Optimization suggested by James McCartney uses a tree
|
||||
to select which random value to replace.
|
||||
Optimization suggested by James McCartney uses a tree
|
||||
to select which random value to replace.
|
||||
<pre>
|
||||
x x x x x x x x x x x x x x x x
|
||||
x x x x x x x x
|
||||
x x x x
|
||||
x x
|
||||
x
|
||||
</pre>
|
||||
Tree is generated by counting trailing zeros in an increasing index.
|
||||
When the index is zero, no random number is selected.
|
||||
x x x x x x x x x x x x x x x x
|
||||
x x x x x x x x
|
||||
x x x x
|
||||
x x
|
||||
x
|
||||
</pre>
|
||||
Tree is generated by counting trailing zeros in an increasing index.
|
||||
When the index is zero, no random number is selected.
|
||||
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
|
|
@ -44,13 +44,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -172,8 +172,8 @@ paTestData;
|
|||
static int patestCallback(const void* inputBuffer,
|
||||
void* outputBuffer,
|
||||
unsigned long framesPerBuffer,
|
||||
const PaStreamCallbackTimeInfo* timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
const PaStreamCallbackTimeInfo* timeInfo,
|
||||
PaStreamCallbackFlags statusFlags,
|
||||
void* userData)
|
||||
{
|
||||
int finished;
|
||||
|
|
@ -214,7 +214,7 @@ int main(void)
|
|||
int totalSamps;
|
||||
static const double SR = 44100.0;
|
||||
static const int FPB = 2048; /* Frames per buffer: 46 ms buffers. */
|
||||
|
||||
|
||||
/* Initialize two pink noise signals with different numbers of rows. */
|
||||
InitializePinkNoise( &data.leftPink, 12 );
|
||||
InitializePinkNoise( &data.rightPink, 16 );
|
||||
|
|
@ -237,8 +237,8 @@ int main(void)
|
|||
/* Open a stereo PortAudio stream so we can hear the result. */
|
||||
outputParameters.device = Pa_GetDefaultOutputDevice(); /* Take the 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, most likely supported. */
|
||||
outputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_read_write_wire.c
|
||||
@ingroup examples_src
|
||||
@brief Tests full duplex blocking I/O by passing input straight to output.
|
||||
@author Bjorn Roche. XO Audio LLC for Z-Systems Engineering.
|
||||
@ingroup examples_src
|
||||
@brief Tests full duplex blocking I/O by passing input straight to output.
|
||||
@author Bjorn Roche. XO Audio LLC for Z-Systems Engineering.
|
||||
@author based on code by: Phil Burk http://www.softsynth.com
|
||||
@author based on code by: Ross Bencina rossb@audiomulch.com
|
||||
*/
|
||||
|
|
@ -179,22 +179,22 @@ int main(void)
|
|||
xrun:
|
||||
printf("err = %d\n", err); fflush(stdout);
|
||||
if( stream ) {
|
||||
Pa_AbortStream( stream );
|
||||
Pa_CloseStream( stream );
|
||||
Pa_AbortStream( stream );
|
||||
Pa_CloseStream( stream );
|
||||
}
|
||||
free( sampleBlock );
|
||||
Pa_Terminate();
|
||||
if( err & paInputOverflow )
|
||||
fprintf( stderr, "Input Overflow.\n" );
|
||||
fprintf( stderr, "Input Overflow.\n" );
|
||||
if( err & paOutputUnderflow )
|
||||
fprintf( stderr, "Output Underflow.\n" );
|
||||
fprintf( stderr, "Output Underflow.\n" );
|
||||
return -2;
|
||||
error1:
|
||||
free( sampleBlock );
|
||||
error2:
|
||||
if( stream ) {
|
||||
Pa_AbortStream( stream );
|
||||
Pa_CloseStream( stream );
|
||||
Pa_AbortStream( stream );
|
||||
Pa_CloseStream( stream );
|
||||
}
|
||||
Pa_Terminate();
|
||||
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_record.c
|
||||
@ingroup examples_src
|
||||
@brief Record input into an array; Save array to a file; Playback recorded data.
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
@ingroup examples_src
|
||||
@brief Record input into an array; Save array to a file; Playback recorded data.
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -326,15 +326,15 @@ int main(void)
|
|||
{
|
||||
err = Pa_StartStream( stream );
|
||||
if( err != paNoError ) goto done;
|
||||
|
||||
|
||||
printf("Waiting for playback to finish.\n"); fflush(stdout);
|
||||
|
||||
while( ( err = Pa_IsStreamActive( stream ) ) == 1 ) Pa_Sleep(100);
|
||||
if( err < 0 ) goto done;
|
||||
|
||||
|
||||
err = Pa_CloseStream( stream );
|
||||
if( err != paNoError ) goto done;
|
||||
|
||||
|
||||
printf("Done.\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_record_file.c
|
||||
@ingroup examples_src
|
||||
@brief Record input into a file, then playback recorded data from file (Windows only at the moment)
|
||||
@author Robert Bielik
|
||||
@ingroup examples_src
|
||||
@brief Record input into a file, then playback recorded data from file (Windows only at the moment)
|
||||
@author Robert Bielik
|
||||
*/
|
||||
/*
|
||||
* $Id: paex_record_file.c 1752 2011-09-08 03:21:55Z philburk $
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -433,12 +433,12 @@ int main(void)
|
|||
}
|
||||
if( err < 0 ) goto done;
|
||||
}
|
||||
|
||||
|
||||
err = Pa_CloseStream( stream );
|
||||
if( err != paNoError ) goto done;
|
||||
|
||||
fclose(data.file);
|
||||
|
||||
|
||||
printf("Done.\n"); fflush(stdout);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_saw.c
|
||||
@ingroup examples_src
|
||||
@brief Play a simple (aliasing) sawtooth wave.
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
@ingroup examples_src
|
||||
@brief Play a simple (aliasing) sawtooth wave.
|
||||
@author Phil Burk http://www.softsynth.com
|
||||
*/
|
||||
/*
|
||||
* $Id$
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -92,14 +92,14 @@ int main(void)
|
|||
{
|
||||
PaStream *stream;
|
||||
PaError err;
|
||||
|
||||
|
||||
printf("PortAudio Test: output sawtooth wave.\n");
|
||||
/* Initialize our data for use by callback. */
|
||||
data.left_phase = data.right_phase = 0.0;
|
||||
/* Initialize library before making any other calls. */
|
||||
err = Pa_Initialize();
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
|
||||
/* Open an audio I/O stream. */
|
||||
err = Pa_OpenDefaultStream( &stream,
|
||||
0, /* no input channels */
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_sine.c
|
||||
@ingroup examples_src
|
||||
@brief Play a sine wave for several seconds.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@ingroup examples_src
|
||||
@brief Play a sine wave for several seconds.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@author Phil Burk <philburk@softsynth.com>
|
||||
*/
|
||||
/*
|
||||
|
|
@ -32,13 +32,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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>
|
||||
|
|
@ -80,7 +80,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
|
|||
(void) timeInfo; /* Prevent unused variable warnings. */
|
||||
(void) statusFlags;
|
||||
(void) inputBuffer;
|
||||
|
||||
|
||||
for( i=0; i<framesPerBuffer; i++ )
|
||||
{
|
||||
*out++ = data->sine[data->left_phase]; /* left */
|
||||
|
|
@ -90,7 +90,7 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
@ -99,8 +99,8 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
|
|||
*/
|
||||
static void StreamFinished( void* userData )
|
||||
{
|
||||
paTestData *data = (paTestData *) userData;
|
||||
printf( "Stream Completed: %s\n", data->message );
|
||||
paTestData *data = (paTestData *) userData;
|
||||
printf( "Stream Completed: %s\n", data->message );
|
||||
}
|
||||
|
||||
/*******************************************************************/
|
||||
|
|
@ -121,14 +121,14 @@ int main(void)
|
|||
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;
|
||||
|
||||
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 */
|
||||
|
|
@ -164,7 +164,7 @@ int main(void)
|
|||
|
||||
Pa_Terminate();
|
||||
printf("Test finished.\n");
|
||||
|
||||
|
||||
return err;
|
||||
error:
|
||||
Pa_Terminate();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_sine.c
|
||||
@ingroup examples_src
|
||||
@brief Play a sine wave for several seconds.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@ingroup examples_src
|
||||
@brief Play a sine wave for several seconds.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@author Phil Burk <philburk@softsynth.com>
|
||||
*/
|
||||
/*
|
||||
|
|
@ -32,13 +32,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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>
|
||||
|
|
@ -189,7 +189,7 @@ private:
|
|||
PaStreamCallbackFlags statusFlags,
|
||||
void *userData )
|
||||
{
|
||||
/* Here we cast userData to Sine* type so we can call the instance method paCallbackMethod, we can do that since
|
||||
/* Here we cast userData to Sine* type so we can call the instance method paCallbackMethod, we can do that since
|
||||
we called Pa_OpenStream with 'this' for userData */
|
||||
return ((Sine*)userData)->paCallbackMethod(inputBuffer, outputBuffer,
|
||||
framesPerBuffer,
|
||||
|
|
@ -247,7 +247,7 @@ int main(void)
|
|||
Sine sine;
|
||||
|
||||
printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
|
||||
|
||||
|
||||
ScopedPaHandler paInit;
|
||||
if( paInit.result() != paNoError ) goto error;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_wmme_ac3.c
|
||||
@ingroup examples_src
|
||||
@brief Use WMME-specific interface to send raw AC3 data to a S/PDIF output.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@ingroup examples_src
|
||||
@brief Use WMME-specific interface to send raw AC3 data to a S/PDIF output.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -91,17 +91,17 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
|
|||
(void) inputBuffer;
|
||||
|
||||
/* stream out contents of data->buffer looping at end */
|
||||
|
||||
|
||||
for( i=0; i<framesPerBuffer; i++ )
|
||||
{
|
||||
for( j = 0; j < CHANNEL_COUNT; ++j ){
|
||||
for( j = 0; j < CHANNEL_COUNT; ++j ){
|
||||
*out++ = data->buffer[ data->playbackIndex++ ];
|
||||
|
||||
if( data->playbackIndex >= data->bufferSampleCount )
|
||||
data->playbackIndex = 0; /* loop at end of buffer */
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
return paContinue;
|
||||
}
|
||||
|
||||
|
|
@ -120,10 +120,10 @@ int main(int argc, char* argv[])
|
|||
|
||||
printf("usage: patest_wmme_ac3 fileName [paDeviceIndex]\n");
|
||||
printf("**IMPORTANT*** The provided file must include the spdif preamble at the start of every AC-3 frame. Using a normal ac3 file won't work.\n");
|
||||
printf("PortAudio Test: output a raw spdif ac3 stream. SR = %d, BufSize = %d, Chans = %d\n",
|
||||
printf("PortAudio Test: output a raw spdif ac3 stream. SR = %d, BufSize = %d, Chans = %d\n",
|
||||
SAMPLE_RATE, FRAMES_PER_BUFFER, CHANNEL_COUNT);
|
||||
|
||||
|
||||
|
||||
if( argc >= 2 )
|
||||
fileName = argv[1];
|
||||
|
||||
|
|
@ -154,14 +154,14 @@ int main(int argc, char* argv[])
|
|||
err = Pa_Initialize();
|
||||
if( err != paNoError ) goto error;
|
||||
|
||||
deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
|
||||
if( argc >= 3 ){
|
||||
sscanf( argv[1], "%d", &deviceIndex );
|
||||
}
|
||||
deviceIndex = Pa_GetHostApiInfo( Pa_HostApiTypeIdToHostApiIndex( paMME ) )->defaultOutputDevice;
|
||||
if( argc >= 3 ){
|
||||
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 );
|
||||
|
||||
|
||||
outputParameters.device = deviceIndex;
|
||||
outputParameters.channelCount = CHANNEL_COUNT;
|
||||
outputParameters.sampleFormat = paInt16; /* IMPORTANT must use paInt16 for WMME AC3 */
|
||||
|
|
@ -169,17 +169,17 @@ int main(int argc, char* argv[])
|
|||
outputParameters.hostApiSpecificStreamInfo = NULL;
|
||||
|
||||
wmmeStreamInfo.size = sizeof(PaWinMmeStreamInfo);
|
||||
wmmeStreamInfo.hostApiType = paMME;
|
||||
wmmeStreamInfo.hostApiType = paMME;
|
||||
wmmeStreamInfo.version = 1;
|
||||
wmmeStreamInfo.flags = paWinMmeWaveFormatDolbyAc3Spdif;
|
||||
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,
|
||||
|
|
@ -207,7 +207,7 @@ int main(int argc, char* argv[])
|
|||
Pa_Terminate();
|
||||
free( data.buffer );
|
||||
printf("Test finished.\n");
|
||||
|
||||
|
||||
return err;
|
||||
error:
|
||||
Pa_Terminate();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_wmme_surround.c
|
||||
@ingroup examples_src
|
||||
@brief Use WMME-specific channelMask to request 5.1 surround sound output.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@ingroup examples_src
|
||||
@brief Use WMME-specific channelMask to request 5.1 surround sound output.
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
*/
|
||||
/*
|
||||
* $Id: $
|
||||
|
|
@ -31,13 +31,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -67,9 +67,9 @@
|
|||
typedef struct
|
||||
{
|
||||
float sine[TABLE_SIZE];
|
||||
int phase;
|
||||
int currentChannel;
|
||||
int cycleCount;
|
||||
int phase;
|
||||
int currentChannel;
|
||||
int cycleCount;
|
||||
}
|
||||
paTestData;
|
||||
|
||||
|
|
@ -90,31 +90,31 @@ static int patestCallback( const void *inputBuffer, void *outputBuffer,
|
|||
(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;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
++data->currentChannel;
|
||||
if( data->currentChannel >= CHANNEL_COUNT )
|
||||
data->currentChannel -= CHANNEL_COUNT;
|
||||
}
|
||||
}
|
||||
|
||||
return paContinue;
|
||||
}
|
||||
|
||||
|
|
@ -134,12 +134,12 @@ int main(int argc, char* argv[])
|
|||
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++ )
|
||||
|
|
@ -147,9 +147,9 @@ int main(int argc, char* argv[])
|
|||
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;
|
||||
|
|
@ -161,18 +161,18 @@ int main(int argc, char* argv[])
|
|||
output. But if you want to be sure which channel mask PortAudio will use
|
||||
then you should supply one */
|
||||
wmmeStreamInfo.size = sizeof(PaWinMmeStreamInfo);
|
||||
wmmeStreamInfo.hostApiType = paMME;
|
||||
wmmeStreamInfo.hostApiType = paMME;
|
||||
wmmeStreamInfo.version = 1;
|
||||
wmmeStreamInfo.flags = paWinMmeUseChannelMask;
|
||||
wmmeStreamInfo.channelMask = PAWIN_SPEAKER_5POINT1; /* request 5.1 output format */
|
||||
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,
|
||||
|
|
@ -199,7 +199,7 @@ int main(int argc, char* argv[])
|
|||
|
||||
Pa_Terminate();
|
||||
printf("Test finished.\n");
|
||||
|
||||
|
||||
return err;
|
||||
error:
|
||||
Pa_Terminate();
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_write_sine.c
|
||||
@ingroup examples_src
|
||||
@brief Play a sine wave for several seconds using the blocking API (Pa_WriteStream())
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@ingroup examples_src
|
||||
@brief Play a sine wave for several seconds using the blocking API (Pa_WriteStream())
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@author Phil Burk <philburk@softsynth.com>
|
||||
*/
|
||||
/*
|
||||
|
|
@ -32,13 +32,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -71,23 +71,23 @@ int main(void)
|
|||
int right_inc = 3; /* higher pitch so we can distinguish left and right. */
|
||||
int i, j, k;
|
||||
int bufferCount;
|
||||
|
||||
|
||||
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++ )
|
||||
{
|
||||
sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
|
||||
}
|
||||
|
||||
|
||||
|
||||
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 */
|
||||
|
|
@ -107,7 +107,7 @@ int main(void)
|
|||
|
||||
|
||||
printf( "Play 3 times, higher each time.\n" );
|
||||
|
||||
|
||||
for( k=0; k < 3; ++k )
|
||||
{
|
||||
err = Pa_StartStream( stream );
|
||||
|
|
@ -131,7 +131,7 @@ int main(void)
|
|||
|
||||
err = Pa_WriteStream( stream, buffer, FRAMES_PER_BUFFER );
|
||||
if( err != paNoError ) goto error;
|
||||
}
|
||||
}
|
||||
|
||||
err = Pa_StopStream( stream );
|
||||
if( err != paNoError ) goto error;
|
||||
|
|
@ -147,20 +147,20 @@ int main(void)
|
|||
|
||||
Pa_Terminate();
|
||||
printf("Test finished.\n");
|
||||
|
||||
|
||||
return err;
|
||||
|
||||
error:
|
||||
fprintf( stderr, "An error occurred while using the portaudio stream\n" );
|
||||
fprintf( stderr, "Error number: %d\n", err );
|
||||
fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
|
||||
// Print more information about the error.
|
||||
if( err == paUnanticipatedHostError )
|
||||
{
|
||||
const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo();
|
||||
fprintf( stderr, "Host API error = #%ld, hostApiType = %d\n", hostErrorInfo->errorCode, hostErrorInfo->hostApiType );
|
||||
fprintf( stderr, "Host API error = %s\n", hostErrorInfo->errorText );
|
||||
}
|
||||
// Print more information about the error.
|
||||
if( err == paUnanticipatedHostError )
|
||||
{
|
||||
const PaHostErrorInfo *hostErrorInfo = Pa_GetLastHostErrorInfo();
|
||||
fprintf( stderr, "Host API error = #%ld, hostApiType = %d\n", hostErrorInfo->errorCode, hostErrorInfo->hostApiType );
|
||||
fprintf( stderr, "Host API error = %s\n", hostErrorInfo->errorText );
|
||||
}
|
||||
Pa_Terminate();
|
||||
return err;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/** @file paex_write_sine_nonint.c
|
||||
@ingroup examples_src
|
||||
@brief Play a non-interleaved sine wave using the blocking API (Pa_WriteStream())
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@ingroup examples_src
|
||||
@brief Play a non-interleaved sine wave using the blocking API (Pa_WriteStream())
|
||||
@author Ross Bencina <rossb@audiomulch.com>
|
||||
@author Phil Burk <philburk@softsynth.com>
|
||||
*/
|
||||
/*
|
||||
|
|
@ -32,13 +32,13 @@
|
|||
*/
|
||||
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
|
|
@ -63,11 +63,11 @@ int main(void)
|
|||
PaStreamParameters outputParameters;
|
||||
PaStream *stream;
|
||||
PaError err;
|
||||
|
||||
float leftBuffer[FRAMES_PER_BUFFER];
|
||||
|
||||
float leftBuffer[FRAMES_PER_BUFFER];
|
||||
float rightBuffer[FRAMES_PER_BUFFER];
|
||||
void *buffers[2]; /* points to both non-interleaved buffers. */
|
||||
|
||||
|
||||
float sine[TABLE_SIZE]; /* sine wavetable */
|
||||
int left_phase = 0;
|
||||
int right_phase = 0;
|
||||
|
|
@ -76,23 +76,23 @@ int main(void)
|
|||
int i, j, k;
|
||||
int bufferCount;
|
||||
|
||||
|
||||
|
||||
printf("PortAudio Test: output sine wave NON-INTERLEAVED. 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;
|
||||
|
||||
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 | paNonInterleaved; /* 32 bit floating point output NON-INTERLEAVED */
|
||||
|
|
@ -112,11 +112,11 @@ int main(void)
|
|||
|
||||
|
||||
printf( "Play 3 times, higher each time.\n" );
|
||||
|
||||
/* Set up array of buffer pointers for Pa_WriteStream */
|
||||
buffers[0] = leftBuffer;
|
||||
buffers[1] = rightBuffer;
|
||||
|
||||
|
||||
/* Set up array of buffer pointers for Pa_WriteStream */
|
||||
buffers[0] = leftBuffer;
|
||||
buffers[1] = rightBuffer;
|
||||
|
||||
for( k=0; k < 3; ++k )
|
||||
{
|
||||
err = Pa_StartStream( stream );
|
||||
|
|
@ -140,7 +140,7 @@ int main(void)
|
|||
|
||||
err = Pa_WriteStream( stream, buffers, FRAMES_PER_BUFFER );
|
||||
if( err != paNoError ) goto error;
|
||||
}
|
||||
}
|
||||
|
||||
err = Pa_StopStream( stream );
|
||||
if( err != paNoError ) goto error;
|
||||
|
|
@ -156,7 +156,7 @@ int main(void)
|
|||
|
||||
Pa_Terminate();
|
||||
printf("Test finished.\n");
|
||||
|
||||
|
||||
return err;
|
||||
error:
|
||||
Pa_Terminate();
|
||||
|
|
|
|||
Loading…
Reference in a new issue