From 238d8db31a094eee59d187d734efd414245edb89 Mon Sep 17 00:00:00 2001 From: Ross Bencina Date: Thu, 21 Jan 2021 22:23:23 +1100 Subject: [PATCH] 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) --- examples/pa_devs.c | 26 +++---- examples/pa_fuzz.c | 20 ++--- examples/paex_mono_asio_channel_select.c | 24 +++--- examples/paex_ocean_shore.c | 50 ++++++------- examples/paex_pink.c | 42 +++++------ examples/paex_read_write_wire.c | 18 ++--- examples/paex_record.c | 18 ++--- examples/paex_record_file.c | 16 ++-- examples/paex_saw.c | 16 ++-- examples/paex_sine.c | 28 +++---- examples/paex_sine_c++.cpp | 16 ++-- examples/paex_wmme_ac3.c | 52 ++++++------- examples/paex_wmme_surround.c | 94 ++++++++++++------------ examples/paex_write_sine.c | 42 +++++------ examples/paex_write_sine_nonint.c | 42 +++++------ 15 files changed, 252 insertions(+), 252 deletions(-) diff --git a/examples/pa_devs.c b/examples/pa_devs.c index 595a05d..27acfd5 100644 --- a/examples/pa_devs.c +++ b/examples/pa_devs.c @@ -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; iname ); 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; diff --git a/examples/pa_fuzz.c b/examples/pa_fuzz.c index 337e06d..0c24d35 100644 --- a/examples/pa_fuzz.c +++ b/examples/pa_fuzz.c @@ -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; diff --git a/examples/paex_mono_asio_channel_select.c b/examples/paex_mono_asio_channel_select.c index 71b0198..4b55d31 100644 --- a/examples/paex_mono_asio_channel_select.c +++ b/examples/paex_mono_asio_channel_select.c @@ -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 - @author Phil Burk + @ingroup examples_src + @brief Play a monophonic sine wave on a specific ASIO channel. + @author Ross Bencina + @author Phil Burk */ /* * $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; diff --git a/examples/paex_ocean_shore.c b/examples/paex_ocean_shore.c index ae645d6..9424e8b 100644 --- a/examples/paex_ocean_shore.c +++ b/examples/paex_ocean_shore.c @@ -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.
-	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   
-
- 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 + 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 + + 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 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(); diff --git a/examples/paex_pink.c b/examples/paex_pink.c index cd84324..519f979 100644 --- a/examples/paex_pink.c +++ b/examples/paex_pink.c @@ -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.
-	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   
-
- 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 + + 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; diff --git a/examples/paex_read_write_wire.c b/examples/paex_read_write_wire.c index 813c74d..69f15ff 100644 --- a/examples/paex_read_write_wire.c +++ b/examples/paex_read_write_wire.c @@ -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" ); diff --git a/examples/paex_record.c b/examples/paex_record.c index 4c9105c..4407787 100644 --- a/examples/paex_record.c +++ b/examples/paex_record.c @@ -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); } diff --git a/examples/paex_record_file.c b/examples/paex_record_file.c index 1e1f473..c4e5b44 100644 --- a/examples/paex_record_file.c +++ b/examples/paex_record_file.c @@ -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); } diff --git a/examples/paex_saw.c b/examples/paex_saw.c index 6f477b8..caec0b0 100644 --- a/examples/paex_saw.c +++ b/examples/paex_saw.c @@ -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 */ diff --git a/examples/paex_sine.c b/examples/paex_sine.c index 99fecf7..50ef205 100644 --- a/examples/paex_sine.c +++ b/examples/paex_sine.c @@ -1,7 +1,7 @@ /** @file paex_sine.c - @ingroup examples_src - @brief Play a sine wave for several seconds. - @author Ross Bencina + @ingroup examples_src + @brief Play a sine wave for several seconds. + @author Ross Bencina @author Phil Burk */ /* @@ -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 @@ -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; isine[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(); diff --git a/examples/paex_sine_c++.cpp b/examples/paex_sine_c++.cpp index 64d7829..5d96522 100644 --- a/examples/paex_sine_c++.cpp +++ b/examples/paex_sine_c++.cpp @@ -1,7 +1,7 @@ /** @file paex_sine.c - @ingroup examples_src - @brief Play a sine wave for several seconds. - @author Ross Bencina + @ingroup examples_src + @brief Play a sine wave for several seconds. + @author Ross Bencina @author Phil Burk */ /* @@ -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 @@ -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; diff --git a/examples/paex_wmme_ac3.c b/examples/paex_wmme_ac3.c index ac9212a..67c2786 100644 --- a/examples/paex_wmme_ac3.c +++ b/examples/paex_wmme_ac3.c @@ -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 + @ingroup examples_src + @brief Use WMME-specific interface to send raw AC3 data to a S/PDIF output. + @author Ross Bencina */ /* * $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; ibuffer[ 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(); diff --git a/examples/paex_wmme_surround.c b/examples/paex_wmme_surround.c index dfccc99..86a7e37 100644 --- a/examples/paex_wmme_surround.c +++ b/examples/paex_wmme_surround.c @@ -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 + @ingroup examples_src + @brief Use WMME-specific channelMask to request 5.1 surround sound output. + @author Ross Bencina */ /* * $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; icurrentChannel && 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; } @@ -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 + @ingroup examples_src + @brief Play a sine wave for several seconds using the blocking API (Pa_WriteStream()) + @author Ross Bencina @author Phil Burk */ /* @@ -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; ierrorCode, 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; } diff --git a/examples/paex_write_sine_nonint.c b/examples/paex_write_sine_nonint.c index bc266c0..db78ed7 100644 --- a/examples/paex_write_sine_nonint.c +++ b/examples/paex_write_sine_nonint.c @@ -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 + @ingroup examples_src + @brief Play a non-interleaved sine wave using the blocking API (Pa_WriteStream()) + @author Ross Bencina @author Phil Burk */ /* @@ -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