aboutsummaryrefslogtreecommitdiff
path: root/pd/portaudio/pa_tests
diff options
context:
space:
mode:
Diffstat (limited to 'pd/portaudio/pa_tests')
-rw-r--r--pd/portaudio/pa_tests/debug_convert.c131
-rw-r--r--pd/portaudio/pa_tests/debug_dither_calc.c55
-rw-r--r--pd/portaudio/pa_tests/debug_dual.c183
-rw-r--r--pd/portaudio/pa_tests/debug_multi_in.c179
-rw-r--r--pd/portaudio/pa_tests/debug_multi_out.c144
-rw-r--r--pd/portaudio/pa_tests/debug_record.c339
-rw-r--r--pd/portaudio/pa_tests/debug_record_reuse.c351
-rw-r--r--pd/portaudio/pa_tests/debug_sine.c192
-rw-r--r--pd/portaudio/pa_tests/debug_sine_amp.c157
-rw-r--r--pd/portaudio/pa_tests/debug_sine_formats.c202
-rw-r--r--pd/portaudio/pa_tests/debug_srate.c265
-rw-r--r--pd/portaudio/pa_tests/debug_test1.c114
-rw-r--r--pd/portaudio/pa_tests/pa_devs.c199
-rw-r--r--pd/portaudio/pa_tests/pa_fuzz.c168
-rw-r--r--pd/portaudio/pa_tests/pa_minlat.c176
-rw-r--r--pd/portaudio/pa_tests/paqa_devs.c317
-rw-r--r--pd/portaudio/pa_tests/paqa_errs.c330
-rw-r--r--pd/portaudio/pa_tests/patest1.c119
-rw-r--r--pd/portaudio/pa_tests/patest_buffer.c181
-rw-r--r--pd/portaudio/pa_tests/patest_clip.c156
-rw-r--r--pd/portaudio/pa_tests/patest_dither.c152
-rw-r--r--pd/portaudio/pa_tests/patest_hang.c151
-rw-r--r--pd/portaudio/pa_tests/patest_latency.c176
-rw-r--r--pd/portaudio/pa_tests/patest_leftright.c168
-rw-r--r--pd/portaudio/pa_tests/patest_longsine.c137
-rw-r--r--pd/portaudio/pa_tests/patest_many.c194
-rw-r--r--pd/portaudio/pa_tests/patest_maxsines.c197
-rw-r--r--pd/portaudio/pa_tests/patest_multi_sine.c175
-rw-r--r--pd/portaudio/pa_tests/patest_pink.c245
-rw-r--r--pd/portaudio/pa_tests/patest_record.c327
-rw-r--r--pd/portaudio/pa_tests/patest_ringmix.c41
-rw-r--r--pd/portaudio/pa_tests/patest_saw.c118
-rw-r--r--pd/portaudio/pa_tests/patest_sine.c152
-rw-r--r--pd/portaudio/pa_tests/patest_sine8.c184
-rw-r--r--pd/portaudio/pa_tests/patest_sine_formats.c196
-rw-r--r--pd/portaudio/pa_tests/patest_sine_time.c194
-rw-r--r--pd/portaudio/pa_tests/patest_start_stop.c160
-rw-r--r--pd/portaudio/pa_tests/patest_stop.c288
-rw-r--r--pd/portaudio/pa_tests/patest_sync.c257
-rw-r--r--pd/portaudio/pa_tests/patest_toomanysines.c172
-rw-r--r--pd/portaudio/pa_tests/patest_underflow.c151
-rw-r--r--pd/portaudio/pa_tests/patest_wire.c277
42 files changed, 0 insertions, 8070 deletions
diff --git a/pd/portaudio/pa_tests/debug_convert.c b/pd/portaudio/pa_tests/debug_convert.c
deleted file mode 100644
index 8e9dc6d1..00000000
--- a/pd/portaudio/pa_tests/debug_convert.c
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * $Id: debug_convert.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * Convert tagged values.
- *
- * Author: Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDeviceID())
-//#define OUTPUT_DEVICE (11)
-#define NUM_SECONDS (8)
-#define SLEEP_DUR (800)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (256)
-
-#define NUM_BUFFERS (0)
-
-typedef struct
-{
- unsigned int framesToGo;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- short *out = (short*)outputBuffer;
- int i;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- if( data->framesToGo < framesPerBuffer ) finished = 1;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = 0x0000 + i; /* left */
- *out++ = 0x1000 + i; /* right */
- }
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- int totalSamps;
- printf("PortAudio Test: output debug values\n" );
- data.framesToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- printf("totalSamps = %d\n", totalSamps );
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- printf("PortAudio Test: output device = %d\n", OUTPUT_DEVICE );
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- OUTPUT_DEVICE,
- 2, /* stereo output */
- paInt16, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER,
- NUM_BUFFERS, /* number of buffers, if zero then use default minimum */
- paClipOff|paDitherOff, /* 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("Is callback being called?\n");
- for( i=0; i<((NUM_SECONDS+1)*1000); i+=SLEEP_DUR )
- {
- printf("data.framesToGo = %d\n", data.framesToGo ); fflush(stdout);
- Pa_Sleep( SLEEP_DUR );
- }
- /* Stop sound until ENTER hit. */
- printf("Call Pa_StopStream()\n");
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/debug_dither_calc.c b/pd/portaudio/pa_tests/debug_dither_calc.c
deleted file mode 100644
index d751ca39..00000000
--- a/pd/portaudio/pa_tests/debug_dither_calc.c
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * $Id: debug_dither_calc.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * Test Dither calculations.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#include "pa_host.h"
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- long max,min;
- int i;
-
- for( i=0; i<10000; i++ )
- {
- long dither = PaConvert_TriangularDither();
- // printf("dither = 0x%08X\n", dither );
- if( dither < min ) min = dither;
- else if( dither > max ) max = dither;
- }
- printf("min = 0x%08X = %d, max = 0x%08X = %d\n", min, min, max, max );
-}
diff --git a/pd/portaudio/pa_tests/debug_dual.c b/pd/portaudio/pa_tests/debug_dual.c
deleted file mode 100644
index b90ef290..00000000
--- a/pd/portaudio/pa_tests/debug_dual.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- * $Id: debug_dual.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * debug_dual.c
- * Try to open TWO streams on separate cards.
- * Play a sine sweep using the Portable Audio api for several seconds.
- * Hacked test for debugging PA.
- *
- * Author: Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define DEV_ID_1 (13)
-#define DEV_ID_2 (15)
-#define NUM_SECONDS (8)
-#define SLEEP_DUR (800)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (256)
-#if 0
-#define MIN_LATENCY_MSEC (200)
-#define NUM_BUFFERS ((MIN_LATENCY_MSEC * SAMPLE_RATE) / (FRAMES_PER_BUFFER * 1000))
-#else
-#define NUM_BUFFERS (0)
-#endif
-#define MIN_FREQ (100.0f)
-#define MAX_FREQ (4000.0f)
-#define FREQ_SCALAR (1.00002f)
-#define CalcPhaseIncrement(freq) (freq/SAMPLE_RATE)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (400)
-typedef struct
-{
- float sine[TABLE_SIZE + 1]; // add one for guard point for interpolation
- float phase_increment;
- float left_phase;
- float right_phase;
-}
-paTestData;
-/* Convert phase between and 1.0 to sine value
- * using linear interpolation.
- */
-float LookupSine( paTestData *data, float phase );
-float LookupSine( paTestData *data, float phase )
-{
- float fIndex = phase*TABLE_SIZE;
- int index = (int) fIndex;
- float fract = fIndex - index;
- float lo = data->sine[index];
- float hi = data->sine[index+1];
- float val = lo + fract*(hi-lo);
- return val;
-}
-/* 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned long i;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = LookupSine(data, data->left_phase); /* left */
- *out++ = LookupSine(data, data->right_phase); /* right */
- data->left_phase += data->phase_increment;
- if( data->left_phase >= 1.0f ) data->left_phase -= 1.0f;
- data->right_phase += (data->phase_increment * 1.5f); /* fifth above */
- if( data->right_phase >= 1.0f ) data->right_phase -= 1.0f;
- /* sweep frequency then start over. */
- data->phase_increment *= FREQ_SCALAR;
- if( data->phase_increment > CalcPhaseIncrement(MAX_FREQ) ) data->phase_increment = CalcPhaseIncrement(MIN_FREQ);
- }
- return 0;
-}
-
-PaError TestStart( PortAudioStream **streamPtr, PaDeviceID devID,
- paTestData *data );
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream1, *stream2;
- PaError err;
- paTestData DATA1, DATA2;
- printf("PortAudio Test: DUAL sine sweep. ask for %d buffers\n", NUM_BUFFERS );
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = TestStart( &stream1, DEV_ID_1, &DATA1 );
- if( err != paNoError ) goto error;
- err = TestStart( &stream2, DEV_ID_2, &DATA2 );
- if( err != paNoError ) goto error;
- printf("Hit ENTER\n");
- getchar();
- err = Pa_StopStream( stream1 );
- if( err != paNoError ) goto error;
- err = Pa_StopStream( stream2 );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
-PaError TestStart( PortAudioStream **streamPtr, PaDeviceID devID, paTestData *data )
-{
- PortAudioStream *stream;
- PaError err;
- int i;
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- data->sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
- }
- data->sine[TABLE_SIZE] = data->sine[0]; // set guard point
- data->left_phase = data->right_phase = 0.0;
- data->phase_increment = CalcPhaseIncrement(MIN_FREQ);
- printf("PortAudio Test: output device = %d\n", devID );
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- devID,
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER,
- NUM_BUFFERS, /* number of buffers, if zero then use default minimum */
- paClipOff|paDitherOff, /* 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;
- *streamPtr = stream;
- return 0;
-error:
- return err;
-}
diff --git a/pd/portaudio/pa_tests/debug_multi_in.c b/pd/portaudio/pa_tests/debug_multi_in.c
deleted file mode 100644
index ef1d4a19..00000000
--- a/pd/portaudio/pa_tests/debug_multi_in.c
+++ /dev/null
@@ -1,179 +0,0 @@
-/*
- * $Id: debug_multi_in.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * debug_multi_in.c
- * Pass output from each of multiple channels
- * to a stereo output using the Portable Audio api.
- * Hacked test for debugging PA.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include <string.h>
-#include "portaudio.h"
-//#define INPUT_DEVICE_NAME ("EWS88 MT Interleaved Rec")
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDeviceID())
-//#define OUTPUT_DEVICE (18)
-#define SAMPLE_RATE (22050)
-#define FRAMES_PER_BUFFER (256)
-#define MIN_LATENCY_MSEC (400)
-#define NUM_BUFFERS ((MIN_LATENCY_MSEC * SAMPLE_RATE) / (FRAMES_PER_BUFFER * 1000))
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-typedef struct
-{
- int liveChannel;
- int numChannels;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- float *in = (float*)inputBuffer;
- int i;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- if( in == NULL ) return 0;
- for( i=0; i<(int)framesPerBuffer; i++ )
- {
- /* Copy one channel of input to output. */
- *out++ = in[data->liveChannel];
- *out++ = in[data->liveChannel];
- in += data->numChannels;
- }
- return 0;
-}
-/*******************************************************************/
-int PaFindDeviceByName( const char *name )
-{
- int i;
- int numDevices;
- const PaDeviceInfo *pdi;
- int len = strlen( name );
- PaDeviceID result = paNoDevice;
- numDevices = Pa_CountDevices();
- for( i=0; i<numDevices; i++ )
- {
- pdi = Pa_GetDeviceInfo( i );
- if( strncmp( name, pdi->name, len ) == 0 )
- {
- result = i;
- break;
- }
- }
- return result;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- PaDeviceID inputDevice;
- const PaDeviceInfo *pdi;
- printf("PortAudio Test: input signal from each channel. %d buffers\n", NUM_BUFFERS );
- data.liveChannel = 0;
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-#ifdef INPUT_DEVICE_NAME
- printf("Try to use device: %s\n", INPUT_DEVICE_NAME );
- inputDevice = PaFindDeviceByName(INPUT_DEVICE_NAME);
- if( inputDevice == paNoDevice )
- {
- printf("Could not find %s. Using default instead.\n", INPUT_DEVICE_NAME );
- inputDevice = Pa_GetDefaultInputDeviceID();
- }
-#else
- printf("Using default input device.\n");
- inputDevice = Pa_GetDefaultInputDeviceID();
-#endif
- pdi = Pa_GetDeviceInfo( inputDevice );
- if( pdi == NULL )
- {
- printf("Could not get device info!\n");
- goto error;
- }
- data.numChannels = pdi->maxInputChannels;
- printf("Input Device name is %s\n", pdi->name );
- printf("Input Device has %d channels.\n", pdi->maxInputChannels);
- err = Pa_OpenStream(
- &stream,
- inputDevice,
- pdi->maxInputChannels,
- paFloat32, /* 32 bit floating point input */
- NULL,
- OUTPUT_DEVICE,
- 2,
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- NUM_BUFFERS, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patestCallback,
- &data );
- if( err != paNoError ) goto error;
- data.liveChannel = 0;
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- for( i=0; i<data.numChannels; i++ )
- {
- data.liveChannel = i;
- printf("Channel %d being sent to output. Hit ENTER for next channel.", i );
- fflush(stdout);
- getchar();
- }
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
-
- err = Pa_CloseStream( stream );
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/debug_multi_out.c b/pd/portaudio/pa_tests/debug_multi_out.c
deleted file mode 100644
index 6ff64ac6..00000000
--- a/pd/portaudio/pa_tests/debug_multi_out.c
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * $Id: debug_multi_out.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * debug_multi_out.c
- * Play a different sine wave on each channels,
- * using the Portable Audio api.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDeviceID())
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (256)
-#define FREQ_INCR (300.0 / SAMPLE_RATE)
-#define MAX_CHANNELS (64)
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-typedef struct
-{
- int numChannels;
- double phases[MAX_CHANNELS];
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- int frameIndex, channelIndex;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( frameIndex=0; frameIndex<(int)framesPerBuffer; frameIndex++ )
- {
- for( channelIndex=0; channelIndex<data->numChannels; channelIndex++ )
- {
- /* Output sine wave on every channel. */
- *out++ = (float) sin(data->phases[channelIndex]);
-
- /* Play each channel at a higher frequency. */
- data->phases[channelIndex] += FREQ_INCR * (4 + channelIndex);
- if( data->phases[channelIndex] >= (2.0 * M_PI) ) data->phases[channelIndex] -= (2.0 * M_PI);
- }
- }
-
- return 0;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- const PaDeviceInfo *pdi;
- paTestData data = {0};
- printf("PortAudio Test: output sine wave on each channel.\n" );
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- pdi = Pa_GetDeviceInfo( OUTPUT_DEVICE );
- data.numChannels = pdi->maxOutputChannels;
- if( data.numChannels > MAX_CHANNELS ) data.numChannels = MAX_CHANNELS;
- printf("Number of Channels = %d\n", data.numChannels );
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice, /* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- OUTPUT_DEVICE,
- data.numChannels,
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- 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("Hit ENTER to stop sound.\n");
- fflush(stdout);
- getchar();
-
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
-
- Pa_CloseStream( stream );
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/debug_record.c b/pd/portaudio/pa_tests/debug_record.c
deleted file mode 100644
index f82ea58c..00000000
--- a/pd/portaudio/pa_tests/debug_record.c
+++ /dev/null
@@ -1,339 +0,0 @@
-/*
- * $Id: debug_record.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * debug_record.c
- * Record input into an array.
- * Save array to a file.
- * Based on patest_record.c but with various ugly debug hacks thrown in.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include "portaudio.h"
-#define SAMPLE_RATE (22050)
-#define NUM_SECONDS (10)
-#define SLEEP_DUR_MSEC (200)
-#define FRAMES_PER_BUFFER (1<<10)
-#define NUM_REC_BUFS (0)
-
-#if 1
-#define PA_SAMPLE_TYPE paFloat32
-typedef float SAMPLE;
-#else
-#define PA_SAMPLE_TYPE paInt16
-typedef short SAMPLE;
-#endif
-
-typedef struct
-{
- long frameIndex; /* Index into sample array. */
- long maxFrameIndex;
- long samplesPerFrame;
- long numSamples;
- SAMPLE *recordedSamples;
-}
-paTestData;
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 recordCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE *rptr = (SAMPLE*)inputBuffer;
- SAMPLE *wptr = &data->recordedSamples[data->frameIndex * data->samplesPerFrame];
- long framesToCalc;
- unsigned long i;
- int finished;
- unsigned long framesLeft = data->maxFrameIndex - data->frameIndex;
-
- (void) outputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( framesLeft < framesPerBuffer )
- {
- framesToCalc = framesLeft;
- finished = 1;
- }
- else
- {
- framesToCalc = framesPerBuffer;
- finished = 0;
- }
- if( inputBuffer == NULL )
- {
- for( i=0; i<framesToCalc; i++ )
- {
- *wptr++ = 0; /* left */
- *wptr++ = 0; /* right */
- }
- }
- else
- {
- for( i=0; i<framesToCalc; i++ )
- {
- *wptr++ = *rptr++; /* left */
- *wptr++ = *rptr++; /* right */
- }
- }
- data->frameIndex += framesToCalc;
- return finished;
-}
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 playCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE *rptr = &data->recordedSamples[data->frameIndex * data->samplesPerFrame];
- SAMPLE *wptr = (SAMPLE*)outputBuffer;
- unsigned long i;
- int finished;
- unsigned int framesLeft = data->maxFrameIndex - data->frameIndex;
- if( outputBuffer == NULL ) return 0;
- (void) inputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( framesLeft < framesPerBuffer )
- {
- /* final buffer... */
- for( i=0; i<framesLeft; i++ )
- {
- *wptr++ = *rptr++; /* left */
- *wptr++ = *rptr++; /* right */
- }
- for( ; i<framesPerBuffer; i++ )
- {
- *wptr++ = 0; /* left */
- *wptr++ = 0; /* right */
- }
- data->frameIndex += framesLeft;
- finished = 1;
- }
- else
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- *wptr++ = *rptr++; /* left */
- *wptr++ = *rptr++; /* right */
- }
- data->frameIndex += framesPerBuffer;
- finished = 0;
- }
- return finished;
-}
-
-/****************************************************************/
-PaError TestRecording( paTestData *dataPtr )
-{
- PortAudioStream *stream;
- PaError err;
- int i;
-
- /* Record some audio. */
- err = Pa_OpenStream(
- &stream,
- Pa_GetDefaultInputDeviceID(),
- dataPtr->samplesPerFrame, /* stereo input */
- PA_SAMPLE_TYPE,
- NULL,
- paNoDevice,
- 0,
- PA_SAMPLE_TYPE,
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- NUM_REC_BUFS, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- recordCallback,
- dataPtr );
- if( err != paNoError ) goto error;
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
-
- printf("Now recording!\n"); fflush(stdout);
- for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
- {
- if( Pa_StreamActive( stream ) <= 0)
- {
- printf("Stream inactive!\n");
- break;
- }
- if( dataPtr->maxFrameIndex <= dataPtr->frameIndex )
- {
- printf("Buffer recording complete.\n");
- break;
- }
- Pa_Sleep(100);
- printf("index = %d\n", dataPtr->frameIndex ); fflush(stdout);
- }
-
- printf("Finished loop. Close stream.\n"); fflush(stdout);
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
-
- printf("Done.\n"); fflush(stdout);
- {
- SAMPLE max = 0;
- SAMPLE posVal;
- int i;
- for( i=0; i<dataPtr->numSamples; i++ )
- {
- posVal = dataPtr->recordedSamples[i];
- if( posVal < 0 ) posVal = -posVal;
- if( posVal > max ) max = posVal;
- }
- printf("Largest recorded sample = %d\n", max );
- }
- /* Write recorded data to a file. */
-#if 0
- {
- FILE *fid;
- fid = fopen("recorded.raw", "wb");
- if( fid == NULL )
- {
- printf("Could not open file.");
- }
- else
- {
- fwrite( dataPtr->recordedSamples, dataPtr->samplesPerFrame * sizeof(SAMPLE), totalFrames, fid );
- fclose( fid );
- printf("Wrote data to 'recorded.raw'\n");
- }
- }
-#endif
-
-error:
- return err;
-}
-
-/****************************************************************/
-PaError TestPlayback( paTestData *dataPtr )
-{
- PortAudioStream *stream;
- PaError err;
- int i;
-
- /* Playback recorded data. */
- dataPtr->frameIndex = 0;
- printf("Begin playback.\n"); fflush(stdout);
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* NO input */
- PA_SAMPLE_TYPE,
- NULL,
- Pa_GetDefaultOutputDeviceID(),
- dataPtr->samplesPerFrame, /* stereo output */
- PA_SAMPLE_TYPE,
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- playCallback,
- dataPtr );
- if( err != paNoError ) goto error;
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- printf("Waiting for playback to finish.\n"); fflush(stdout);
- for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
- {
- Pa_Sleep(100);
- printf("index = %d\n", dataPtr->frameIndex );
- }
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
-
-error:
- return err;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError err;
- paTestData data;
- long totalFrames;
- long numBytes;
- long i;
- printf("patest_record.c\n"); fflush(stdout);
-
- data.frameIndex = 0;
- data.samplesPerFrame = 2;
- data.maxFrameIndex = totalFrames = NUM_SECONDS*SAMPLE_RATE;
-
- printf("totalFrames = %d\n", totalFrames ); fflush(stdout);
- data.numSamples = totalFrames * data.samplesPerFrame;
-
- numBytes = data.numSamples * sizeof(SAMPLE);
- data.recordedSamples = (SAMPLE *) malloc( numBytes );
- if( data.recordedSamples == NULL )
- {
- printf("Could not allocate record array.\n");
- exit(1);
- }
- for( i=0; i<data.numSamples; i++ ) data.recordedSamples[i] = 0;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- for( i=0; i<2; i++ )
- {
- err = TestRecording( &data );
- if( err != paNoError ) goto error;
-
- err = TestPlayback( &data );
- if( err != paNoError ) goto error;
- }
-
- free( data.recordedSamples );
- Pa_Terminate();
- return 0;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- if( err == paHostError )
- {
- fprintf( stderr, "Host Error number: %d\n", Pa_GetHostError() );
- }
- return -1;
-}
diff --git a/pd/portaudio/pa_tests/debug_record_reuse.c b/pd/portaudio/pa_tests/debug_record_reuse.c
deleted file mode 100644
index 4f4fb53d..00000000
--- a/pd/portaudio/pa_tests/debug_record_reuse.c
+++ /dev/null
@@ -1,351 +0,0 @@
-/*
- * $Id: debug_record_reuse.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * debug_record_reuse.c
- * Record input into an array.
- * Save array to a file.
- * Based on patest_record.c but with various ugly debug hacks thrown in.
- * Loop twice and reuse same streams.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include "portaudio.h"
-#define SAMPLE_RATE (22050)
-#define NUM_SECONDS (4)
-#define SLEEP_DUR_MSEC (200)
-#define FRAMES_PER_BUFFER (256)
-#define NUM_REC_BUFS (0)
-
-#if 1
-#define PA_SAMPLE_TYPE paFloat32
-typedef float SAMPLE;
-#else
-#define PA_SAMPLE_TYPE paInt16
-typedef short SAMPLE;
-#endif
-
-typedef struct
-{
- long frameIndex; /* Index into sample array. */
- long maxFrameIndex;
- long samplesPerFrame;
- long numSamples;
- PortAudioStream *outputStream;
- PortAudioStream *inputStream;
- SAMPLE *recordedSamples;
-}
-paTestData;
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 recordCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE *rptr = (SAMPLE*)inputBuffer;
- SAMPLE *wptr = &data->recordedSamples[data->frameIndex * data->samplesPerFrame];
- long framesToCalc;
- unsigned long i;
- int finished;
- unsigned long framesLeft = data->maxFrameIndex - data->frameIndex;
-
- (void) outputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( framesLeft < framesPerBuffer )
- {
- framesToCalc = framesLeft;
- finished = 1;
- }
- else
- {
- framesToCalc = framesPerBuffer;
- finished = 0;
- }
- if( inputBuffer == NULL )
- {
- for( i=0; i<framesToCalc; i++ )
- {
- *wptr++ = 0; /* left */
- *wptr++ = 0; /* right */
- }
- }
- else
- {
- for( i=0; i<framesToCalc; i++ )
- {
- *wptr++ = *rptr++; /* left */
- *wptr++ = *rptr++; /* right */
- }
- }
- data->frameIndex += framesToCalc;
- return finished;
-}
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 playCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE *rptr = &data->recordedSamples[data->frameIndex * data->samplesPerFrame];
- SAMPLE *wptr = (SAMPLE*)outputBuffer;
- unsigned long i;
- int finished;
- unsigned int framesLeft = data->maxFrameIndex - data->frameIndex;
- if( outputBuffer == NULL ) return 0;
- (void) inputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( framesLeft < framesPerBuffer )
- {
- /* final buffer... */
- for( i=0; i<framesLeft; i++ )
- {
- *wptr++ = *rptr++; /* left */
- *wptr++ = *rptr++; /* right */
- }
- for( ; i<framesPerBuffer; i++ )
- {
- *wptr++ = 0; /* left */
- *wptr++ = 0; /* right */
- }
- data->frameIndex += framesLeft;
- finished = 1;
- }
- else
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- *wptr++ = *rptr++; /* left */
- *wptr++ = *rptr++; /* right */
- }
- data->frameIndex += framesPerBuffer;
- finished = 0;
- }
- return finished;
-}
-
-/****************************************************************/
-PaError TestRecording( paTestData *dataPtr )
-{
- PaError err;
- int i;
- int lastIndex = 0;
-
-/* Open input stream if not already open. */
- if( dataPtr->inputStream == NULL )
- {
- /* Record some audio. */
- err = Pa_OpenStream(
- &dataPtr->inputStream,
- Pa_GetDefaultInputDeviceID(),
- dataPtr->samplesPerFrame, /* stereo input */
- PA_SAMPLE_TYPE,
- NULL,
- paNoDevice,
- 0,
- PA_SAMPLE_TYPE,
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- NUM_REC_BUFS, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- recordCallback,
- dataPtr );
- if( err != paNoError ) goto error;
- }
-
- dataPtr->frameIndex = 0;
-
- err = Pa_StartStream( dataPtr->inputStream );
- if( err != paNoError ) goto error;
-
- printf("Now recording!\n"); fflush(stdout);
- for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
- {
- int frameIndex, delta;
- Pa_Sleep(SLEEP_DUR_MSEC);
-
- frameIndex = dataPtr->frameIndex;
- if( Pa_StreamActive( dataPtr->inputStream ) <= 0)
- {
- printf("Stream inactive!\n");
- break;
- }
- if( dataPtr->maxFrameIndex <= frameIndex )
- {
- printf("Buffer recording complete.\n");
- break;
- }
-
- delta = frameIndex - lastIndex;
- lastIndex = frameIndex;
- printf("index = %d, delta = %d\n", frameIndex, delta ); fflush(stdout);
- }
-
- err = Pa_StopStream( dataPtr->inputStream );
- if( err != paNoError ) goto error;
-
- printf("Done.\n"); fflush(stdout);
-
-error:
- return err;
-}
-
-/****************************************************************/
-PaError TestPlayback( paTestData *dataPtr )
-{
- PaError err;
- int i;
- int lastIndex = 0;
-
- /* Playback recorded data. */
- dataPtr->frameIndex = 0;
- printf("Begin playback.\n"); fflush(stdout);
-
-/* Open output stream if not already open. */
- if( dataPtr->outputStream == NULL )
- {
- err = Pa_OpenStream(
- &dataPtr->outputStream,
- paNoDevice,
- 0, /* NO input */
- PA_SAMPLE_TYPE,
- NULL,
- Pa_GetDefaultOutputDeviceID(),
- dataPtr->samplesPerFrame, /* stereo output */
- PA_SAMPLE_TYPE,
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- playCallback,
- dataPtr );
- if( err != paNoError ) goto error;
- }
-
- err = Pa_StartStream( dataPtr->outputStream );
- if( err != paNoError ) goto error;
-
- printf("Waiting for playback to finish.\n"); fflush(stdout);
- for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
- {
- int frameIndex, delta;
- Pa_Sleep(SLEEP_DUR_MSEC);
- frameIndex = dataPtr->frameIndex;
- delta = frameIndex - lastIndex;
- lastIndex = frameIndex;
- printf("index = %d, delta = %d\n", frameIndex, delta ); fflush(stdout);
- }
-
- err = Pa_StopStream( dataPtr->outputStream );
- if( err != paNoError ) goto error;
-
-error:
- return err;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError err;
- paTestData data = { 0 };
- long totalFrames;
- long numBytes;
- long i;
- printf("patest_record.c\n"); fflush(stdout);
-
-/* Set up test data structure and sample array. */
- data.frameIndex = 0;
- data.samplesPerFrame = 2;
- data.maxFrameIndex = totalFrames = NUM_SECONDS*SAMPLE_RATE;
-
- printf("totalFrames = %d\n", totalFrames ); fflush(stdout);
- data.numSamples = totalFrames * data.samplesPerFrame;
-
- numBytes = data.numSamples * sizeof(SAMPLE);
- data.recordedSamples = (SAMPLE *) malloc( numBytes );
- if( data.recordedSamples == NULL )
- {
- printf("Could not allocate record array.\n");
- exit(1);
- }
- for( i=0; i<data.numSamples; i++ ) data.recordedSamples[i] = 0;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
-/* Record and playback multiple times. */
- for( i=0; i<2; i++ )
- {
- err = TestRecording( &data );
- if( err != paNoError ) goto error;
-
- err = TestPlayback( &data );
- if( err != paNoError ) goto error;
- }
-
-/* Clean up. */
- err = Pa_CloseStream( data.inputStream );
- if( err != paNoError ) goto error;
-
- err = Pa_CloseStream( data.outputStream );
- if( err != paNoError ) goto error;
-
- if( err != paNoError ) goto error;
-
- free( data.recordedSamples );
- Pa_Terminate();
-
- printf("Test complete.\n"); fflush(stdout);
- return 0;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- if( err == paHostError )
- {
- fprintf( stderr, "Host Error number: %d\n", Pa_GetHostError() );
- }
- return -1;
-}
diff --git a/pd/portaudio/pa_tests/debug_sine.c b/pd/portaudio/pa_tests/debug_sine.c
deleted file mode 100644
index 93d74160..00000000
--- a/pd/portaudio/pa_tests/debug_sine.c
+++ /dev/null
@@ -1,192 +0,0 @@
-/*
- * $Id: debug_sine.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * debug_sine.c
- * Play a sine sweep using the Portable Audio api for several seconds.
- * Hacked test for debugging PA.
- *
- * Author: Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDeviceID())
-//#define OUTPUT_DEVICE (11)
-#define NUM_SECONDS (8)
-#define SLEEP_DUR (800)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (256)
-#if 0
-#define MIN_LATENCY_MSEC (200)
-#define NUM_BUFFERS ((MIN_LATENCY_MSEC * SAMPLE_RATE) / (FRAMES_PER_BUFFER * 1000))
-#else
-#define NUM_BUFFERS (0)
-#endif
-#define MIN_FREQ (100.0f)
-#define MAX_FREQ (4000.0f)
-#define FREQ_SCALAR (1.00002f)
-#define CalcPhaseIncrement(freq) (freq/SAMPLE_RATE)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (400)
-typedef struct
-{
- float sine[TABLE_SIZE + 1]; // add one for guard point for interpolation
- float phase_increment;
- float left_phase;
- float right_phase;
- unsigned int framesToGo;
-}
-paTestData;
-/* Convert phase between and 1.0 to sine value
- * using linear interpolation.
- */
-float LookupSine( paTestData *data, float phase );
-float LookupSine( paTestData *data, float phase )
-{
- float fIndex = phase*TABLE_SIZE;
- int index = (int) fIndex;
- float fract = fIndex - index;
- float lo = data->sine[index];
- float hi = data->sine[index+1];
- float val = lo + fract*(hi-lo);
- return val;
-}
-/* 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- int framesToCalc;
- int i;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- if( data->framesToGo < framesPerBuffer )
- {
- framesToCalc = data->framesToGo;
- data->framesToGo = 0;
- finished = 1;
- }
- else
- {
- framesToCalc = framesPerBuffer;
- data->framesToGo -= framesPerBuffer;
- }
-
- for( i=0; i<framesToCalc; i++ )
- {
- *out++ = LookupSine(data, data->left_phase); /* left */
- *out++ = LookupSine(data, data->right_phase); /* right */
- data->left_phase += data->phase_increment;
- if( data->left_phase >= 1.0f ) data->left_phase -= 1.0f;
- data->right_phase += (data->phase_increment * 1.5f); /* fifth above */
- if( data->right_phase >= 1.0f ) data->right_phase -= 1.0f;
- /* sweep frequency then start over. */
- data->phase_increment *= FREQ_SCALAR;
- if( data->phase_increment > CalcPhaseIncrement(MAX_FREQ) ) data->phase_increment = CalcPhaseIncrement(MIN_FREQ);
- }
- /* zero remainder of final buffer */
- for( ; i<(int)framesPerBuffer; i++ )
- {
- *out++ = 0; /* left */
- *out++ = 0; /* right */
- }
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- int totalSamps;
- printf("PortAudio Test: output sine sweep. ask for %d buffers\n", NUM_BUFFERS );
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
- }
- data.sine[TABLE_SIZE] = data.sine[0]; // set guard point
- data.left_phase = data.right_phase = 0.0;
- data.phase_increment = CalcPhaseIncrement(MIN_FREQ);
- data.framesToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- printf("totalSamps = %d\n", totalSamps );
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- printf("PortAudio Test: output device = %d\n", OUTPUT_DEVICE );
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- OUTPUT_DEVICE,
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER,
- NUM_BUFFERS, /* number of buffers, if zero then use default minimum */
- paClipOff|paDitherOff, /* 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("Is callback being called?\n");
- for( i=0; i<((NUM_SECONDS+1)*1000); i+=SLEEP_DUR )
- {
- printf("data.framesToGo = %d\n", data.framesToGo ); fflush(stdout);
- Pa_Sleep( SLEEP_DUR );
- }
- /* Stop sound until ENTER hit. */
- printf("Call Pa_StopStream()\n");
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/debug_sine_amp.c b/pd/portaudio/pa_tests/debug_sine_amp.c
deleted file mode 100644
index b6b21865..00000000
--- a/pd/portaudio/pa_tests/debug_sine_amp.c
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * $Id: debug_sine_amp.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * Play a different sine wave on each channels,
- * using the Portable Audio api.
- * Allos amplitude to be set interactively.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDeviceID())
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (256)
-#define FREQ_INCR (300.0 / SAMPLE_RATE)
-#define MAX_CHANNELS (64)
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-typedef struct
-{
- int numChannels;
- double phases[MAX_CHANNELS];
- float amplitude;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- int frameIndex, channelIndex;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( frameIndex=0; frameIndex<(int)framesPerBuffer; frameIndex++ )
- {
- for( channelIndex=0; channelIndex<data->numChannels; channelIndex++ )
- {
- /* Output sine wave on every channel. */
- *out++ = (float) ( data->amplitude * sin(data->phases[channelIndex]) );
-
- /* Play each channel at a higher frequency. */
- data->phases[channelIndex] += FREQ_INCR * (4 + channelIndex);
- if( data->phases[channelIndex] >= (2.0 * M_PI) ) data->phases[channelIndex] -= (2.0 * M_PI);
- }
- }
-
- return 0;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- char pad[256];
- PortAudioStream *stream;
- PaError err;
- const PaDeviceInfo *pdi;
- paTestData data = {0};
- printf("PortAudio Test: output sine wave on each channel.\n" );
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- pdi = Pa_GetDeviceInfo( OUTPUT_DEVICE );
- data.numChannels = pdi->maxOutputChannels;
- if( data.numChannels > MAX_CHANNELS ) data.numChannels = MAX_CHANNELS;
- printf("Number of Channels = %d\n", data.numChannels );
- data.amplitude = 1.0;
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice, /* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- OUTPUT_DEVICE,
- data.numChannels,
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- 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;
-
- do
- {
- printf("Current amplitude = %f\n", data.amplitude );
- printf("Enter new amplitude or 'q' to quit.\n");
- fflush(stdout);
- gets( pad );
- if( pad[0] != 'q' )
- {
- // I tried to use atof but it seems to be broken on Mac OS X 10.1
- float amp;
- sscanf( pad, "%f", &amp );
- data.amplitude = amp;
- }
- } while( pad[0] != 'q' );
-
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
-
- Pa_CloseStream( stream );
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/debug_sine_formats.c b/pd/portaudio/pa_tests/debug_sine_formats.c
deleted file mode 100644
index 3f75fa2e..00000000
--- a/pd/portaudio/pa_tests/debug_sine_formats.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/*
- * $Id: debug_sine_formats.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_sine_formats.c
- * Play a sine wave using the Portable Audio api for several seconds.
- * Test various data formats.
- *
- * Author: Phil Burk
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define NUM_SECONDS (10)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (256)
-
-#define LEFT_FREQ (SAMPLE_RATE/512.0) /* So we hit 1.0 */
-#define RIGHT_FREQ (500.0)
-
-#define AMPLITUDE (1.0)
-
-/* Select ONE format for testing. */
-#define TEST_UINT8 (1)
-#define TEST_INT8 (0)
-#define TEST_INT16 (0)
-#define TEST_FLOAT32 (0)
-
-#if TEST_UINT8
-#define TEST_FORMAT paUInt8
-typedef unsigned char SAMPLE_t;
-#define SAMPLE_ZERO (0x80)
-#define DOUBLE_TO_SAMPLE(x) (SAMPLE_ZERO + (SAMPLE_t)(127.0 * (x)))
-#define FORMAT_NAME "Unsigned 8 Bit"
-
-#elif TEST_INT8
-#define TEST_FORMAT paInt8
-typedef char SAMPLE_t;
-#define SAMPLE_ZERO (0)
-#define DOUBLE_TO_SAMPLE(x) (SAMPLE_ZERO + (SAMPLE_t)(127.0 * (x)))
-#define FORMAT_NAME "Signed 8 Bit"
-
-#elif TEST_INT16
-#define TEST_FORMAT paInt16
-typedef short SAMPLE_t;
-#define SAMPLE_ZERO (0)
-#define DOUBLE_TO_SAMPLE(x) (SAMPLE_ZERO + (SAMPLE_t)(32767 * (x)))
-#define FORMAT_NAME "Signed 16 Bit"
-
-#elif TEST_FLOAT32
-#define TEST_FORMAT paFloat32
-typedef float SAMPLE_t;
-#define SAMPLE_ZERO (0.0)
-#define DOUBLE_TO_SAMPLE(x) ((SAMPLE_t)(x))
-#define FORMAT_NAME "Float 32 Bit"
-#endif
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-
-typedef struct
-{
- double left_phase;
- double right_phase;
- unsigned int framesToGo;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE_t *out = (SAMPLE_t *)outputBuffer;
- SAMPLE_t sample;
- int i;
- int framesToCalc;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- if( data->framesToGo < framesPerBuffer )
- {
- framesToCalc = data->framesToGo;
- data->framesToGo = 0;
- finished = 1;
- }
- else
- {
- framesToCalc = framesPerBuffer;
- data->framesToGo -= framesPerBuffer;
- }
-
- for( i=0; i<framesToCalc; i++ )
- {
- data->left_phase += (LEFT_FREQ / SAMPLE_RATE);
- if( data->left_phase > 1.0) data->left_phase -= 1.0;
- sample = DOUBLE_TO_SAMPLE( AMPLITUDE * sin( (data->left_phase * M_PI * 2. ))); /**/
- *out++ = sample;
-/* *out++ = sample; /**/
-/* *out++ = 0; /**/
-
- data->right_phase += (RIGHT_FREQ / SAMPLE_RATE);
- if( data->right_phase > 1.0) data->right_phase -= 1.0;
- *out++ = DOUBLE_TO_SAMPLE( AMPLITUDE * sin( (data->right_phase * M_PI * 2. ))); /**/
-/* *out++ = 0; /* */
- }
- /* zero remainder of final buffer */
- for( ; i<(int)framesPerBuffer; i++ )
- {
- *out++ = SAMPLE_ZERO; /* left */
- *out++ = SAMPLE_ZERO; /* right */
- }
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int totalSamps;
-
- printf("PortAudio Test: output " FORMAT_NAME "\n");
-
-
- data.left_phase = data.right_phase = 0.0;
- data.framesToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- TEST_FORMAT,
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- TEST_FORMAT,
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER,
- 0, /* number of buffers, if zero then use default minimum */
- 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("Waiting %d seconds for sound to finish.\n", NUM_SECONDS );
- while( Pa_StreamActive( stream ) ) Pa_Sleep(10);
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
-
- printf("PortAudio Test Finished: " FORMAT_NAME "\n");
-
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/debug_srate.c b/pd/portaudio/pa_tests/debug_srate.c
deleted file mode 100644
index b3e3b70f..00000000
--- a/pd/portaudio/pa_tests/debug_srate.c
+++ /dev/null
@@ -1,265 +0,0 @@
-/*
- * $Id: debug_srate.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * debug_record_reuse.c
- * Record input into an array.
- * Save array to a file.
- * Based on patest_record.c but with various ugly debug hacks thrown in.
- * Loop twice and reuse same streams.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <memory.h>
-#include "portaudio.h"
-
-#define EWS88MT_12_REC (1)
-#define EWS88MT_12_PLAY (10)
-#define SBLIVE_REC (2)
-#define SBLIVE_PLAY (11)
-
-#if 0
-#define INPUT_DEVICE_ID Pa_GetDefaultInputDeviceID()
-#define OUTPUT_DEVICE_ID Pa_GetDefaultOutputDeviceID()
-#else
-#define INPUT_DEVICE_ID (EWS88MT_12_REC)
-#define OUTPUT_DEVICE_ID (SBLIVE_PLAY)
-#endif
-
-#define INPUT_SAMPLE_RATE (22050.0)
-#define OUTPUT_SAMPLE_RATE (22050.0)
-#define NUM_SECONDS (4)
-#define SLEEP_DUR_MSEC (1000)
-#define FRAMES_PER_BUFFER (64)
-#define NUM_REC_BUFS (0)
-#define SAMPLES_PER_FRAME (2)
-
-#define PA_SAMPLE_TYPE paInt16
-typedef short SAMPLE;
-
-typedef struct
-{
- long frameIndex; /* Index into sample array. */
-}
-paTestData;
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 recordCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData *) userData;
- (void) outputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( inputBuffer != NULL )
- {
- data->frameIndex += framesPerBuffer;
- }
- return 0;
-}
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 playCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData *) userData;
- (void) inputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( outputBuffer != NULL )
- {
- data->frameIndex += framesPerBuffer;
- }
- return 0;
-}
-
-/****************************************************************/
-PaError MeasureStreamRate( PortAudioStream *stream, paTestData *dataPtr, double *ratePtr )
-{
- PaError err;
- int i;
- int totalFrames = 0;
- int totalMSec = 0;
-
- dataPtr->frameIndex = 0;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
-
- for( i=0; i<(NUM_SECONDS*1000/SLEEP_DUR_MSEC); i++ )
- {
- int delta, endIndex;
-
- int startIndex = dataPtr->frameIndex;
- Pa_Sleep(SLEEP_DUR_MSEC);
- endIndex = dataPtr->frameIndex;
-
- delta = endIndex - startIndex;
- totalFrames += delta;
- totalMSec += SLEEP_DUR_MSEC;
-
- printf("index = %d, delta = %d\n", endIndex, delta ); fflush(stdout);
- }
-
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
-
- *ratePtr = (totalFrames * 1000.0) / totalMSec;
-
-error:
- return err;
-}
-
-void ReportRate( double measuredRate, double expectedRate )
-{
- double error;
-
- error = (measuredRate - expectedRate) / expectedRate;
- error = (error < 0 ) ? -error : error;
-
- printf("Measured rate = %6.1f, expected rate = %6.1f\n",
- measuredRate, expectedRate );
- if( error > 0.1 )
- {
- printf("ERROR: unexpected rate! --------------------- ERROR!\n");
- }
- else
- {
- printf("SUCCESS: rate within tolerance!\n");
- }
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError err;
- paTestData data = { 0 };
- long i;
- double rate;
- const PaDeviceInfo *pdi;
-
- PortAudioStream *outputStream;
- PortAudioStream *inputStream;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
-
- pdi = Pa_GetDeviceInfo( INPUT_DEVICE_ID );
- printf("Input device = %s\n", pdi->name );
- pdi = Pa_GetDeviceInfo( OUTPUT_DEVICE_ID );
- printf("Output device = %s\n", pdi->name );
-
-/* Open input stream. */
- err = Pa_OpenStream(
- &inputStream,
- INPUT_DEVICE_ID,
- SAMPLES_PER_FRAME, /* stereo input */
- PA_SAMPLE_TYPE,
- NULL,
- paNoDevice,
- 0,
- PA_SAMPLE_TYPE,
- NULL,
- INPUT_SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- NUM_REC_BUFS, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- recordCallback,
- &data );
- if( err != paNoError ) goto error;
-
- err = Pa_OpenStream(
- &outputStream,
- paNoDevice,
- 0, /* NO input */
- PA_SAMPLE_TYPE,
- NULL,
- OUTPUT_DEVICE_ID,
- SAMPLES_PER_FRAME, /* stereo output */
- PA_SAMPLE_TYPE,
- NULL,
- OUTPUT_SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- playCallback,
- &data );
- if( err != paNoError ) goto error;
-
-/* Record and playback multiple times. */
- for( i=0; i<2; i++ )
- {
- printf("Measuring INPUT ------------------------- \n");
- err = MeasureStreamRate( inputStream, &data, &rate );
- if( err != paNoError ) goto error;
- ReportRate( rate, INPUT_SAMPLE_RATE );
-
- printf("Measuring OUTPUT ------------------------- \n");
- err = MeasureStreamRate( outputStream, &data, &rate );
- if( err != paNoError ) goto error;
- ReportRate( rate, OUTPUT_SAMPLE_RATE );
- }
-
-/* Clean up. */
- err = Pa_CloseStream( inputStream );
- if( err != paNoError ) goto error;
-
- err = Pa_CloseStream( outputStream );
- if( err != paNoError ) goto error;
-
- if( err != paNoError ) goto error;
-
- Pa_Terminate();
-
- printf("Test complete.\n"); fflush(stdout);
- return 0;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- if( err == paHostError )
- {
- fprintf( stderr, "Host Error number: %d\n", Pa_GetHostError() );
- }
- return -1;
-}
diff --git a/pd/portaudio/pa_tests/debug_test1.c b/pd/portaudio/pa_tests/debug_test1.c
deleted file mode 100644
index 05370b00..00000000
--- a/pd/portaudio/pa_tests/debug_test1.c
+++ /dev/null
@@ -1,114 +0,0 @@
-/*
- * $Id: debug_test1.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- patest1.c
- Ring modulate the audio input with a 441hz sine wave for 20 seconds
- using the Portable Audio api
- Author: Ross Bencina <rossb@audiomulch.com>
- Modifications:
- April 5th, 2001 - PLB - Check for NULL inputBuffer.
-*/
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-typedef struct
-{
- float sine[100];
- int phase;
- int sampsToGo;
-}
-patest1data;
-static int patest1Callback( void *inputBuffer, void *outputBuffer,
- unsigned long bufferFrames,
- PaTimestamp outTime, void *userData )
-{
- patest1data *data = (patest1data*)userData;
- float *in = (float*)inputBuffer;
- float *out = (float*)outputBuffer;
- int framesToCalc = bufferFrames;
- unsigned long i;
- int finished = 0;
- if(inputBuffer == NULL) return 0;
- if( data->sampsToGo < bufferFrames )
- {
- finished = 1;
- }
- for( i=0; i<bufferFrames; i++ )
- {
- *out++ = *in++;
- *out++ = *in++;
- if( data->phase >= 100 )
- data->phase = 0;
- }
- data->sampsToGo -= bufferFrames;
- /* zero remainder of final buffer if not already done */
- for( ; i<bufferFrames; i++ )
- {
- *out++ = 0; /* left */
- *out++ = 0; /* right */
- }
- return finished;
-}
-int main(int argc, char* argv[]);
-int main(int argc, char* argv[])
-{
- PaStream *stream;
- PaError err;
- patest1data data;
- int i;
- int inputDevice = Pa_GetDefaultInputDeviceID();
- int outputDevice = Pa_GetDefaultOutputDeviceID();
- /* initialise sinusoidal wavetable */
- for( i=0; i<100; i++ )
- data.sine[i] = sin( ((double)i/100.) * M_PI * 2. );
- data.phase = 0;
- data.sampsToGo = 44100 * 4; // 20 seconds
- /* initialise portaudio subsytem */
- Pa_Initialize();
- err = Pa_OpenStream(
- &stream,
- inputDevice,
- 2, /* stereo input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- outputDevice,
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- 44100.,
- // 22050, /* half second buffers */
- // 4, /* four buffers */
- 512, /* half second buffers */
- 0, /* four buffers */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patest1Callback,
- &data );
- if( err == paNoError )
- {
- err = Pa_StartStream( stream );
- // printf( "Press any key to end.\n" );
- // getc( stdin ); //wait for input before exiting
- // Pa_AbortStream( stream );
-
- printf( "Waiting for stream to complete...\n" );
-
- while( Pa_StreamActive( stream ) )
- Pa_Sleep(1000); /* sleep until playback has finished */
-
- err = Pa_CloseStream( stream );
- }
- else
- {
- fprintf( stderr, "An error occured while opening the portaudio stream\n" );
- if( err == paHostError )
- fprintf( stderr, "Host error number: %d\n", Pa_GetHostError() );
- else
- fprintf( stderr, "Error number: %d\n", err );
- }
- Pa_Terminate();
- printf( "bye\n" );
-
- return 0;
-}
diff --git a/pd/portaudio/pa_tests/pa_devs.c b/pd/portaudio/pa_tests/pa_devs.c
deleted file mode 100644
index 983699d1..00000000
--- a/pd/portaudio/pa_tests/pa_devs.c
+++ /dev/null
@@ -1,199 +0,0 @@
-/*
- * $Id: pa_devs.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * pa_devs.c
- * List available devices.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-/*******************************************************************/
-static void PrintSupportedStandardSampleRates(
- const PaStreamParameters *inputParameters,
- const PaStreamParameters *outputParameters )
-{
- static double standardSampleRates[] = {
- 8000.0, 9600.0, 11025.0, 12000.0, 16000.0, 22050.0, 24000.0, 32000.0,
- 44100.0, 48000.0, 88200.0, 96000.0, -1 /* negative terminated list */
- };
- int i, printCount;
- PaError err;
-
- printCount = 0;
- for( i=0; standardSampleRates[i] > 0; i++ )
- {
- err = Pa_IsFormatSupported( inputParameters, outputParameters, standardSampleRates[i] );
- if( err == paFormatIsSupported )
- {
- if( printCount == 0 )
- {
- printf( "\t%8.2f", standardSampleRates[i] );
- printCount = 1;
- }
- else if( printCount == 4 )
- {
- printf( ",\n\t%8.2f", standardSampleRates[i] );
- printCount = 1;
- }
- else
- {
- printf( ", %8.2f", standardSampleRates[i] );
- ++printCount;
- }
- }
- }
- if( !printCount )
- printf( "None\n" );
- else
- printf( "\n" );
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- int i, numDevices, defaultDisplayed;
- const PaDeviceInfo *deviceInfo;
- PaStreamParameters inputParameters, outputParameters;
- PaError err;
-
-
- Pa_Initialize();
-
- printf( "PortAudio version number = %d\nPortAudio version text = '%s'\n",
- Pa_GetVersion(), Pa_GetVersionText() );
-
-
- numDevices = Pa_CountDevices();
- if( numDevices < 0 )
- {
- printf( "ERROR: Pa_CountDevices returned 0x%x\n", numDevices );
- 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() )
- {
- printf( "[ Default Input" );
- defaultDisplayed = 1;
- }
- else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultInputDevice )
- {
- const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
- printf( "[ Default %s Input", hostInfo->name );
- defaultDisplayed = 1;
- }
-
- if( i == Pa_GetDefaultOutputDevice() )
- {
- printf( (defaultDisplayed ? "," : "[") );
- printf( " Default Output" );
- defaultDisplayed = 1;
- }
- else if( i == Pa_GetHostApiInfo( deviceInfo->hostApi )->defaultOutputDevice )
- {
- const PaHostApiInfo *hostInfo = Pa_GetHostApiInfo( deviceInfo->hostApi );
- printf( (defaultDisplayed ? "," : "[") );
- printf( " Default %s Output", hostInfo->name );
- defaultDisplayed = 1;
- }
-
- if( defaultDisplayed )
- printf( " ]\n" );
-
- /* print device info fields */
- printf( "Name = %s\n", deviceInfo->name );
- printf( "Host API = %s\n", Pa_GetHostApiInfo( deviceInfo->hostApi )->name );
- printf( "Max inputs = %d", deviceInfo->maxInputChannels );
- printf( ", Max outputs = %d\n", deviceInfo->maxOutputChannels );
-
- printf( "Default low input latency = %8.3f\n", deviceInfo->defaultLowInputLatency );
- printf( "Default low output latency = %8.3f\n", deviceInfo->defaultLowOutputLatency );
- printf( "Default high input latency = %8.3f\n", deviceInfo->defaultHighInputLatency );
- printf( "Default high output latency = %8.3f\n", deviceInfo->defaultHighOutputLatency );
-
- printf( "Default sample rate = %8.2f\n", deviceInfo->defaultSampleRate );
-
- /* poll for standard sample rates */
- inputParameters.device = i;
- inputParameters.channelCount = deviceInfo->maxInputChannels;
- inputParameters.sampleFormat = paInt16;
- inputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
- inputParameters.hostApiSpecificStreamInfo = NULL;
-
- outputParameters.device = i;
- outputParameters.channelCount = deviceInfo->maxOutputChannels;
- outputParameters.sampleFormat = paInt16;
- outputParameters.suggestedLatency = 0; /* ignored by Pa_IsFormatSupported() */
- outputParameters.hostApiSpecificStreamInfo = NULL;
-
- if( inputParameters.channelCount > 0 )
- {
- printf("Supported standard sample rates\n for half-duplex 16 bit %d channel input = \n",
- inputParameters.channelCount );
- PrintSupportedStandardSampleRates( &inputParameters, NULL );
- }
-
- if( outputParameters.channelCount > 0 )
- {
- printf("Supported standard sample rates\n for half-duplex 16 bit %d channel output = \n",
- outputParameters.channelCount );
- PrintSupportedStandardSampleRates( NULL, &outputParameters );
- }
-
- if( inputParameters.channelCount > 0 && outputParameters.channelCount > 0 )
- {
- printf("Supported standard sample rates\n for full-duplex 16 bit %d channel input, %d channel output = \n",
- inputParameters.channelCount, outputParameters.channelCount );
- PrintSupportedStandardSampleRates( &inputParameters, &outputParameters );
- }
- }
-
- Pa_Terminate();
-
- printf("----------------------------------------------\n");
- return 0;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/pa_fuzz.c b/pd/portaudio/pa_tests/pa_fuzz.c
deleted file mode 100644
index 1ec88785..00000000
--- a/pd/portaudio/pa_tests/pa_fuzz.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * $Id: pa_fuzz.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * pa_fuzz.c
- * Distort input like a fuzz boz.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-/*
-** Note that many of the older ISA sound cards on PCs do NOT support
-** full duplex audio (simultaneous record and playback).
-** And some only support full duplex at lower sample rates.
-*/
-#define SAMPLE_RATE (44100)
-#define PA_SAMPLE_TYPE paFloat32
-#define FRAMES_PER_BUFFER (64)
-
-typedef float SAMPLE;
-
-float CubicAmplifier( float input );
-static int fuzzCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData );
-
-/* Non-linear amplifier with soft distortion curve. */
-float CubicAmplifier( float input )
-{
- float output, temp;
- if( input < 0.0 )
- {
- temp = input + 1.0f;
- output = (temp * temp * temp) - 1.0f;
- }
- else
- {
- temp = input - 1.0f;
- output = (temp * temp * temp) + 1.0f;
- }
-
- return output;
-}
-#define FUZZ(x) CubicAmplifier(CubicAmplifier(CubicAmplifier(CubicAmplifier(x))))
-
-static int gNumNoInputs = 0;
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 fuzzCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
-{
- SAMPLE *out = (SAMPLE*)outputBuffer;
- SAMPLE *in = (SAMPLE*)inputBuffer;
- unsigned int i;
- (void) timeInfo; /* Prevent unused variable warnings. */
- (void) statusFlags;
- (void) userData;
-
- if( inputBuffer == NULL )
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = 0; /* left - silent */
- *out++ = 0; /* right - silent */
- }
- gNumNoInputs += 1;
- }
- else
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = FUZZ(*in++); /* left - distorted */
- *out++ = *in++; /* right - clean */
- }
- }
-
- return paContinue;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStreamParameters inputParameters, outputParameters;
- PaStream *stream;
- PaError err;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
-
- inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
- inputParameters.channelCount = 2; /* stereo input */
- inputParameters.sampleFormat = PA_SAMPLE_TYPE;
- inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
- inputParameters.hostApiSpecificStreamInfo = NULL;
-
- outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
- outputParameters.channelCount = 2; /* stereo output */
- outputParameters.sampleFormat = PA_SAMPLE_TYPE;
- outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
- outputParameters.hostApiSpecificStreamInfo = NULL;
-
- err = Pa_OpenStream(
- &stream,
- &inputParameters,
- &outputParameters,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER,
- 0, // paClipOff, /* we won't output out of range samples so don't bother clipping them */
- fuzzCallback,
- NULL );
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
-
- printf("Hit ENTER to stop program.\n");
- getchar();
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
-
- printf("Finished. gNumNoInputs = %d\n", gNumNoInputs );
- Pa_Terminate();
- return 0;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return -1;
-}
diff --git a/pd/portaudio/pa_tests/pa_minlat.c b/pd/portaudio/pa_tests/pa_minlat.c
deleted file mode 100644
index 736445a7..00000000
--- a/pd/portaudio/pa_tests/pa_minlat.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * $Id: pa_minlat.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * paminlat.c
- * Experiment with different numbers of buffers to determine the
- * minimum latency for a computer.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "portaudio.h"
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TWOPI (M_PI * 2.0)
-
-#define DEFAULT_BUFFER_SIZE (32)
-
-typedef struct
-{
- double left_phase;
- double right_phase;
-}
-paTestData;
-
-/* Very simple synthesis routine to generate two sine waves. */
-static int paminlatCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned int i;
- double left_phaseInc = 0.02;
- double right_phaseInc = 0.06;
-
- double left_phase = data->left_phase;
- double right_phase = data->right_phase;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- left_phase += left_phaseInc;
- if( left_phase > TWOPI ) left_phase -= TWOPI;
- *out++ = (float) sin( left_phase );
-
- right_phase += right_phaseInc;
- if( right_phase > TWOPI ) right_phase -= TWOPI;
- *out++ = (float) sin( right_phase );
- }
-
- data->left_phase = left_phase;
- data->right_phase = right_phase;
- return 0;
-}
-void main( int argc, char **argv );
-void main( int argc, char **argv )
-{
- PaStream *stream;
- PaError err;
- paTestData data;
- int go;
- int outLatency = 0;
- int minLatency = DEFAULT_BUFFER_SIZE * 2;
- int framesPerBuffer;
- double sampleRate = 44100.0;
- char str[256];
- printf("pa_minlat - Determine minimum latency for your computer.\n");
- printf(" usage: pa_minlat {userBufferSize}\n");
- printf(" for example: pa_minlat 64\n");
- printf("Adjust your stereo until you hear a smooth tone in each speaker.\n");
- printf("Then try to find the smallest number of frames that still sounds smooth.\n");
- printf("Note that the sound will stop momentarily when you change the number of buffers.\n");
-
- /* Get bufferSize from command line. */
- framesPerBuffer = ( argc > 1 ) ? atol( argv[1] ) : DEFAULT_BUFFER_SIZE;
- printf("Frames per buffer = %d\n", framesPerBuffer );
-
- data.left_phase = data.right_phase = 0.0;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- outLatency = sampleRate * 200.0 / 1000.0; // 200 msec
-
- /* Try different numBuffers in a loop. */
- go = 1;
- while( go )
- {
-
- printf("Latency = %d frames = %6.1f msec.\n", outLatency,
- (outLatency * 1000.0 / sampleRate) );
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- 0,
- NULL,
- Pa_GetDefaultOutputDevice(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- outLatency,
- NULL,
- sampleRate,
- framesPerBuffer,
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- paminlatCallback,
- &data );
- if( err != paNoError ) goto error;
- if( stream == NULL ) goto error;
-
- /* Start audio. */
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
-
- /* Ask user for a new nlatency. */
- printf("\nMove windows around to see if the sound glitches.\n");
- printf("Latency currently %d, enter new number, or 'q' to quit: ", outLatency );
- gets( str );
- 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 );
- if( err != paNoError ) goto error;
- }
- printf("A good setting for latency would be somewhat higher than\n");
- printf("the minimum latency that worked.\n");
- printf("PortAudio: Test finished.\n");
- Pa_Terminate();
- return;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
-}
diff --git a/pd/portaudio/pa_tests/paqa_devs.c b/pd/portaudio/pa_tests/paqa_devs.c
deleted file mode 100644
index 904a6082..00000000
--- a/pd/portaudio/pa_tests/paqa_devs.c
+++ /dev/null
@@ -1,317 +0,0 @@
-/*
- * $Id: paqa_devs.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * paqa_devs.c
- * Self Testing Quality Assurance app for PortAudio
- * Try to open each device and run through all the
- * possible configurations.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#include "pa_trace.h"
-/****************************************** Definitions ***********/
-#define MODE_INPUT (0)
-#define MODE_OUTPUT (1)
-typedef struct PaQaData
-{
- unsigned long framesLeft;
- int numChannels;
- int bytesPerSample;
- int mode;
- short sawPhase;
- PaSampleFormat format;
-}
-PaQaData;
-/****************************************** Prototypes ***********/
-static void TestDevices( int mode );
-static void TestFormats( int mode, PaDeviceID deviceID, double sampleRate,
- int numChannels );
-static int TestAdvance( int mode, PaDeviceID deviceID, double sampleRate,
- int numChannels, PaSampleFormat format );
-static int QaCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-/****************************************** Globals ***********/
-static int gNumPassed = 0;
-static int gNumFailed = 0;
-/****************************************** Macros ***********/
-/* Print ERROR if it fails. Tally success or failure. */
-/* Odd do-while wrapper seems to be needed for some compilers. */
-#define EXPECT(_exp) \
- do \
- { \
- if ((_exp)) {\
- /* printf("SUCCESS for %s\n", #_exp ); */ \
- gNumPassed++; \
- } \
- else { \
- printf("ERROR - 0x%x - %s for %s\n", result, \
- ((result == 0) ? "-" : Pa_GetErrorText(result)), \
- #_exp ); \
- gNumFailed++; \
- goto error; \
- } \
- } while(0)
-/*******************************************************************/
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 QaCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- unsigned long i;
- short phase;
- PaQaData *data = (PaQaData *) userData;
- (void) inputBuffer;
- (void) outTime;
-
- /* Play simle sawtooth wave. */
- if( data->mode == MODE_OUTPUT )
- {
- phase = data->sawPhase;
- switch( data->format )
- {
- case paFloat32:
- {
- float *out = (float *) outputBuffer;
- for( i=0; i<framesPerBuffer; i++ )
- {
- phase += 0x123;
- *out++ = (float) (phase * (1.0 / 32768.0));
- if( data->numChannels == 2 )
- {
- *out++ = (float) (phase * (1.0 / 32768.0));
- }
- }
- }
- break;
-
- case paInt32:
- {
- int *out = (int *) outputBuffer;
- for( i=0; i<framesPerBuffer; i++ )
- {
- phase += 0x123;
- *out++ = ((int) phase ) << 16;
- if( data->numChannels == 2 )
- {
- *out++ = ((int) phase ) << 16;
- }
- }
- }
- break;
- case paInt16:
- {
- short *out = (short *) outputBuffer;
- for( i=0; i<framesPerBuffer; i++ )
- {
- phase += 0x123;
- *out++ = phase;
- if( data->numChannels == 2 )
- {
- *out++ = phase;
- }
- }
- }
- break;
-
- default:
- {
- unsigned char *out = (unsigned char *) outputBuffer;
- unsigned long numBytes = framesPerBuffer * data->numChannels * data->bytesPerSample;
- for( i=0; i<numBytes; i++ )
- {
- *out++ = 0;
- }
- }
- break;
- }
- data->sawPhase = phase;
- }
- /* Are we through yet? */
- if( data->framesLeft > framesPerBuffer )
- {
- AddTraceMessage("QaCallback: running. framesLeft", data->framesLeft );
- data->framesLeft -= framesPerBuffer;
- return 0;
- }
- else
- {
- AddTraceMessage("QaCallback: DONE! framesLeft", data->framesLeft );
- data->framesLeft = 0;
- return 1;
- }
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError result;
- EXPECT( ((result=Pa_Initialize()) == 0) );
- printf("Test OUTPUT ---------------\n");
- TestDevices( MODE_OUTPUT );
- printf("Test INPUT ---------------\n");
- TestDevices( MODE_INPUT );
-error:
- Pa_Terminate();
- printf("QA Report: %d passed, %d failed.\n", gNumPassed, gNumFailed );
-}
-/*******************************************************************
-* Try each output device, through its full range of capabilities. */
-static void TestDevices( int mode )
-{
- int id,jc,kr;
- int maxChannels;
- const PaDeviceInfo *pdi;
- int numDevices = Pa_CountDevices();
- /* Iterate through all devices. */
- for( id=0; id<numDevices; id++ )
- {
- pdi = Pa_GetDeviceInfo( id );
- /* Try 1 to maxChannels on each device. */
- maxChannels = ( mode == MODE_INPUT ) ? pdi->maxInputChannels : pdi->maxOutputChannels;
- for( jc=1; jc<=maxChannels; jc++ )
- {
- printf("Name = %s\n", pdi->name );
- /* Try each legal sample rate. */
- if( pdi->numSampleRates == -1 )
- {
- double low, high;
- low = pdi->sampleRates[0];
- high = pdi->sampleRates[1];
- if( low < 8000.0 ) low = 8000.0;
- TestFormats( mode, id, low, jc );
-#define TESTSR(sr) {if(((sr)>=low) && ((sr)<=high)) TestFormats( mode, id, (sr), jc ); }
-
- TESTSR(11025.0);
- TESTSR(22050.0);
- TESTSR(44100.0);
- TestFormats( mode, id, high, jc );
- }
- else
- {
- for( kr=0; kr<pdi->numSampleRates; kr++ )
- {
- TestFormats( mode, id, pdi->sampleRates[kr], jc );
- }
- }
- }
- }
-}
-/*******************************************************************/
-static void TestFormats( int mode, PaDeviceID deviceID, double sampleRate,
- int numChannels )
-{
- TestAdvance( mode, deviceID, sampleRate, numChannels, paFloat32 ); /* */
- TestAdvance( mode, deviceID, sampleRate, numChannels, paInt16 ); /* */
- TestAdvance( mode, deviceID, sampleRate, numChannels, paInt32 ); /* */
- /* TestAdvance( mode, deviceID, sampleRate, numChannels, paInt24 ); */
-}
-/*******************************************************************/
-static int TestAdvance( int mode, PaDeviceID deviceID, double sampleRate,
- int numChannels, PaSampleFormat format )
-{
- PortAudioStream *stream = NULL;
- PaError result;
- PaQaData myData;
-#define FRAMES_PER_BUFFER (64)
- printf("------ TestAdvance: %s, device = %d, rate = %g, numChannels = %d, format = %d -------\n",
- ( mode == MODE_INPUT ) ? "INPUT" : "OUTPUT",
- deviceID, sampleRate, numChannels, format);
- /* Setup data for synthesis thread. */
- myData.framesLeft = (unsigned long) (sampleRate * 100); /* 100 seconds */
- myData.numChannels = numChannels;
- myData.mode = mode;
- myData.format = format;
- switch( format )
- {
- case paFloat32:
- case paInt32:
- case paInt24:
- myData.bytesPerSample = 4;
- break;
- case paPackedInt24:
- myData.bytesPerSample = 3;
- break;
- default:
- myData.bytesPerSample = 2;
- break;
- }
- EXPECT( ((result = Pa_OpenStream(
- &stream,
- ( mode == MODE_INPUT ) ? deviceID : paNoDevice,
- ( mode == MODE_INPUT ) ? numChannels : 0,
- format,
- NULL,
- ( mode == MODE_OUTPUT ) ? deviceID : paNoDevice,
- ( mode == MODE_OUTPUT ) ? numChannels : 0,
- format,
- NULL,
- sampleRate,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- QaCallback,
- &myData )
- ) == 0) );
- if( stream )
- {
- PaTimestamp oldStamp, newStamp;
- unsigned long oldFrames;
- int minDelay = ( mode == MODE_INPUT ) ? 1000 : 400;
- int minNumBuffers = Pa_GetMinNumBuffers( FRAMES_PER_BUFFER, sampleRate );
- int msec = (int) ((minNumBuffers * 3 * 1000.0 * FRAMES_PER_BUFFER) / sampleRate);
- if( msec < minDelay ) msec = minDelay;
- printf("msec = %d\n", msec); /**/
- EXPECT( ((result=Pa_StartStream( stream )) == 0) );
- /* Check to make sure PortAudio is advancing timeStamp. */
- result = paNoError;
- oldStamp = Pa_StreamTime(stream);
- Pa_Sleep(msec);
- newStamp = Pa_StreamTime(stream);
- printf("oldStamp = %g,newStamp = %g\n", oldStamp, newStamp ); /**/
- EXPECT( (oldStamp < newStamp) );
- /* Check to make sure callback is decrementing framesLeft. */
- oldFrames = myData.framesLeft;
- Pa_Sleep(msec);
- printf("oldFrames = %d, myData.framesLeft = %d\n", oldFrames, myData.framesLeft ); /**/
- EXPECT( (oldFrames > myData.framesLeft) );
- EXPECT( ((result=Pa_CloseStream( stream )) == 0) );
- stream = NULL;
- }
-error:
- if( stream != NULL ) Pa_CloseStream( stream );
- return result;
-}
diff --git a/pd/portaudio/pa_tests/paqa_errs.c b/pd/portaudio/pa_tests/paqa_errs.c
deleted file mode 100644
index d0738602..00000000
--- a/pd/portaudio/pa_tests/paqa_errs.c
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- * $Id: paqa_errs.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * paqa_devs.c
- * Self Testing Quality Assurance app for PortAudio
- * Do lots of bad things to test error reporting.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-/****************************************** Definitions ***********/
-#define MODE_INPUT (0)
-#define MODE_OUTPUT (1)
-#define FRAMES_PER_BUFFER (64)
-#define SAMPLE_RATE (44100.0)
-#define NUM_BUFFERS (0)
-typedef struct PaQaData
-{
- unsigned long framesLeft;
- int numChannels;
- int bytesPerSample;
- int mode;
-}
-PaQaData;
-/****************************************** Prototypes ***********/
-static void TestDevices( int mode );
-static void TestFormats( int mode, PaDeviceID deviceID, double sampleRate,
- int numChannels );
-static int TestBadOpens( void );
-static int TestBadActions( void );
-static int QaCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-/****************************************** Globals ***********/
-static int gNumPassed = 0;
-static int gNumFailed = 0;
-/****************************************** Macros ***********/
-/* Print ERROR if it fails. Tally success or failure. */
-/* Odd do-while wrapper seems to be needed for some compilers. */
-#define EXPECT(_exp) \
- do \
- { \
- if ((_exp)) {\
- gNumPassed++; \
- } \
- else { \
- printf("\nERROR - 0x%x - %s for %s\n", result, Pa_GetErrorText(result), #_exp ); \
- gNumFailed++; \
- goto error; \
- } \
- } while(0)
-#define HOPEFOR(_exp) \
- do \
- { \
- if ((_exp)) {\
- gNumPassed++; \
- } \
- else { \
- printf("\nERROR - 0x%x - %s for %s\n", result, Pa_GetErrorText(result), #_exp ); \
- gNumFailed++; \
- } \
- } while(0)
-/*******************************************************************/
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 QaCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- unsigned long i;
- unsigned char *out = (unsigned char *) outputBuffer;
- PaQaData *data = (PaQaData *) userData;
- (void) inputBuffer; /* Prevent "unused variable" warnings. */
- (void) outTime;
-
- /* Zero out buffer so we don't hear terrible noise. */
- if( data->mode == MODE_OUTPUT )
- {
- unsigned long numBytes = framesPerBuffer * data->numChannels * data->bytesPerSample;
- for( i=0; i<numBytes; i++ )
- {
- *out++ = 0;
- }
- }
- /* Are we through yet? */
- if( data->framesLeft > framesPerBuffer )
- {
- data->framesLeft -= framesPerBuffer;
- return 0;
- }
- else
- {
- data->framesLeft = 0;
- return 1;
- }
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError result;
- EXPECT( ((result=Pa_Initialize()) == 0) );
- TestBadOpens();
- TestBadActions();
-error:
- Pa_Terminate();
- printf("QA Report: %d passed, %d failed.\n", gNumPassed, gNumFailed );
- return 0;
-}
-/*******************************************************************/
-static int TestBadOpens( void )
-{
- PortAudioStream *stream = NULL;
- PaError result;
- PaQaData myData;
- /* Setup data for synthesis thread. */
- myData.framesLeft = (unsigned long) (SAMPLE_RATE * 100); /* 100 seconds */
- myData.numChannels = 1;
- myData.mode = MODE_OUTPUT;
- HOPEFOR( (/* No devices specified. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- paNoDevice, 0, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidDeviceId) );
- HOPEFOR( ( /* Out of range input device specified. */
- (result = Pa_OpenStream(
- &stream,
- Pa_CountDevices(), 0, paFloat32, NULL,
- paNoDevice, 0, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidDeviceId) );
-
- HOPEFOR( ( /* Out of range output device specified. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_CountDevices(), 0, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidDeviceId) );
- HOPEFOR( ( /* Zero input channels. */
- (result = Pa_OpenStream(
- &stream,
- Pa_GetDefaultInputDeviceID(), 0, paFloat32, NULL,
- paNoDevice, 0, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidChannelCount) );
- HOPEFOR( ( /* Zero output channels. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 0, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidChannelCount) );
- HOPEFOR( ( /* Nonzero input channels but no device. */
- (result = Pa_OpenStream(
- &stream,
- Pa_GetDefaultInputDeviceID(), 2, paFloat32, NULL,
- paNoDevice, 2, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidChannelCount) );
-
- HOPEFOR( ( /* Nonzero output channels but no device. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 2, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidChannelCount) );
- HOPEFOR( ( /* NULL stream pointer. */
- (result = Pa_OpenStream(
- NULL,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paBadStreamPtr) );
- HOPEFOR( ( /* Low sample rate. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- 1.0, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidSampleRate) );
- HOPEFOR( ( /* High sample rate. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- 10000000.0, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidSampleRate) );
- HOPEFOR( ( /* NULL callback. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- NULL,
- &myData )
- ) == paNullCallback) );
- HOPEFOR( ( /* Bad flag. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- (1<<3),
- QaCallback,
- &myData )
- ) == paInvalidFlag) );
-
-#if 0 /* FIXME - this is legal for some implementations. */
- HOPEFOR( ( /* Use input device as output device. */
- (result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultInputDeviceID(), 2, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidDeviceId) );
-
- HOPEFOR( ( /* Use output device as input device. */
- (result = Pa_OpenStream(
- &stream,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- paNoDevice, 0, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == paInvalidDeviceId) );
-#endif
-
- if( stream != NULL ) Pa_CloseStream( stream );
- return result;
-}
-/*******************************************************************/
-static int TestBadActions( void )
-{
- PortAudioStream *stream = NULL;
- PaError result;
- PaQaData myData;
- /* Setup data for synthesis thread. */
- myData.framesLeft = (unsigned long) (SAMPLE_RATE * 100); /* 100 seconds */
- myData.numChannels = 1;
- myData.mode = MODE_OUTPUT;
- /* Default output. */
- EXPECT( ((result = Pa_OpenStream(
- &stream,
- paNoDevice, 0, paFloat32, NULL,
- Pa_GetDefaultOutputDeviceID(), 2, paFloat32, NULL,
- SAMPLE_RATE, FRAMES_PER_BUFFER, NUM_BUFFERS,
- paClipOff,
- QaCallback,
- &myData )
- ) == 0) );
- HOPEFOR( ((result = Pa_StartStream( NULL )) == paBadStreamPtr) );
- HOPEFOR( ((result = Pa_StopStream( NULL )) == paBadStreamPtr) );
- HOPEFOR( ((result = Pa_StreamActive( NULL )) == paBadStreamPtr) );
- HOPEFOR( ((result = Pa_CloseStream( NULL )) == paBadStreamPtr) );
- HOPEFOR( ((result = (PaError)Pa_StreamTime( NULL )) != 0) );
- HOPEFOR( ((result = (PaError)Pa_GetCPULoad( NULL )) != 0) );
-error:
- if( stream != NULL ) Pa_CloseStream( stream );
- return result;
-}
diff --git a/pd/portaudio/pa_tests/patest1.c b/pd/portaudio/pa_tests/patest1.c
deleted file mode 100644
index 1f969436..00000000
--- a/pd/portaudio/pa_tests/patest1.c
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- $Id: patest1.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- patest1.c
- Ring modulate the audio input with a sine wave for 20 seconds
- using the Portable Audio api
- Author: Ross Bencina <rossb@audiomulch.com>
- Modifications:
- April 5th, 2001 - PLB - Check for NULL inputBuffer.
-*/
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-typedef struct
-{
- float sine[100];
- int phase;
- int sampsToGo;
-}
-patest1data;
-static int patest1Callback( void *inputBuffer, void *outputBuffer,
- unsigned long bufferFrames,
- PaTime outTime, void *userData )
-{
- patest1data *data = (patest1data*)userData;
- float *in = (float*)inputBuffer;
- float *out = (float*)outputBuffer;
- int framesToCalc = bufferFrames;
- unsigned long i;
- int finished = 0;
- /* Check to see if any input data is available. */
- if(inputBuffer == NULL) return 0;
- if( data->sampsToGo < bufferFrames )
- {
- framesToCalc = data->sampsToGo;
- finished = 1;
- }
- for( i=0; i<framesToCalc; i++ )
- {
- *out++ = *in++ * data->sine[data->phase]; /* left */
- *out++ = *in++ * data->sine[data->phase++]; /* right */
- if( data->phase >= 100 )
- data->phase = 0;
- }
- data->sampsToGo -= framesToCalc;
- /* zero remainder of final buffer if not already done */
- for( ; i<bufferFrames; i++ )
- {
- *out++ = 0; /* left */
- *out++ = 0; /* right */
- }
- return finished;
-}
-int main(int argc, char* argv[]);
-int main(int argc, char* argv[])
-{
- PaStream *stream;
- PaError err;
- patest1data data;
- int i;
- int inputDevice = Pa_GetDefaultInputDevice();
- int outputDevice = Pa_GetDefaultOutputDevice();
- /* initialise sinusoidal wavetable */
- for( i=0; i<100; i++ )
- data.sine[i] = sin( ((double)i/100.) * M_PI * 2. );
- data.phase = 0;
- data.sampsToGo = 44100 * 20; // 20 seconds
- /* initialise portaudio subsytem */
- Pa_Initialize();
- err = Pa_OpenStream(
- &stream,
- inputDevice,
- 2, /* stereo input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- outputDevice,
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- 44100.,
- 512, /* small buffers */
- 0, /* let PA determine number of buffers */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patest1Callback,
- &data );
- if( err == paNoError )
- {
- err = Pa_StartStream( stream );
- printf( "Press any key to end.\n" );
- getc( stdin ); //wait for input before exiting
- Pa_AbortStream( stream );
-
- printf( "Waiting for stream to complete...\n" );
-
- while( Pa_IsStreamActive( stream ) )
- Pa_Sleep(1000); /* sleep until playback has finished */
-
- err = Pa_CloseStream( stream );
- }
- else
- {
- fprintf( stderr, "An error occured while opening the portaudio stream\n" );
- if( err == paHostError )
- {
- fprintf( stderr, "Host error number: %d\n", Pa_GetHostError() );
- }
- else
- {
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error text: %s\n", Pa_GetErrorText( err ) );
- }
- }
- Pa_Terminate();
- printf( "bye\n" );
-
- return 0;
-}
diff --git a/pd/portaudio/pa_tests/patest_buffer.c b/pd/portaudio/pa_tests/patest_buffer.c
deleted file mode 100644
index dbc55913..00000000
--- a/pd/portaudio/pa_tests/patest_buffer.c
+++ /dev/null
@@ -1,181 +0,0 @@
-/*
- * $Id: patest_buffer.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_buffer.c
- * Test opening streams with different buffer sizes.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "portaudio.h"
-#define NUM_SECONDS (1)
-#define SAMPLE_RATE (44100)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (200)
-
-#define BUFFER_TABLE 9
-long buffer_table[] = {200,256,500,512,600, 723, 1000, 1024, 2345};
-
-typedef struct
-{
- short sine[TABLE_SIZE];
- int left_phase;
- int right_phase;
- unsigned int sampsToGo;
-}
-paTestData;
-PaError TestOnce( int buffersize );
-
-static int patest1Callback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-/* 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 patest1Callback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- short *out = (short*)outputBuffer;
- unsigned int i;
- int finished = 0;
- (void) inputBuffer; /* Prevent "unused variable" warnings. */
- (void) outTime;
-
- if( data->sampsToGo < framesPerBuffer )
- {
- /* final buffer... */
-
- for( i=0; i<data->sampsToGo; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- /* zero remainder of final buffer */
- for( ; i<framesPerBuffer; i++ )
- {
- *out++ = 0; /* left */
- *out++ = 0; /* right */
- }
-
- finished = 1;
- }
- else
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- data->sampsToGo -= framesPerBuffer;
- }
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- int i;
- PaError err;
- printf("Test opening streams with different buffer sizes\n\n");
-
- for (i = 0 ; i < BUFFER_TABLE; i++)
- {
- printf("Buffer size %d\n", buffer_table[i]);
- err = TestOnce(buffer_table[i]);
- if( err < 0 ) return 0;
-
- }
-}
-
-
-PaError TestOnce( int buffersize )
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- int totalSamps;
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- data.sine[i] = (short) (32767.0 * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ));
- }
- data.left_phase = data.right_phase = 0;
- data.sampsToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paInt16, /* sample format */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paInt16, /* sample format */
- NULL,
- SAMPLE_RATE,
- buffersize, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patest1Callback,
- &data );
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- printf("Waiting for sound to finish.\n");
- Pa_Sleep(1000);
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- return paNoError;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_clip.c b/pd/portaudio/pa_tests/patest_clip.c
deleted file mode 100644
index c19bf3fe..00000000
--- a/pd/portaudio/pa_tests/patest_clip.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * $Id: patest_clip.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_clip.c
- * Play a sine wave using the Portable Audio api for several seconds
- * at an amplitude that would require clipping.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define NUM_SECONDS (4)
-#define SAMPLE_RATE (44100)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (200)
-typedef struct paTestData
-{
- float sine[TABLE_SIZE];
- float amplitude;
- int left_phase;
- int right_phase;
-}
-paTestData;
-PaError PlaySine( paTestData *data, unsigned long flags, float amplitude );
-/* 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( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- float amplitude = data->amplitude;
- unsigned int i;
- (void) inputBuffer; /* Prevent "unused variable" warnings. */
- (void) outTime;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = amplitude * data->sine[data->left_phase]; /* left */
- *out++ = amplitude * data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- return 0;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError err;
- paTestData DATA;
- int i;
- printf("PortAudio Test: output sine wave with and without clipping.\n");
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- DATA.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
- }
- printf("\nHalf amplitude. Should sound like sine wave.\n"); fflush(stdout);
- err = PlaySine( &DATA, paClipOff | paDitherOff, 0.5f );
- if( err < 0 ) goto error;
- printf("\nFull amplitude. Should sound like sine wave.\n"); fflush(stdout);
- err = PlaySine( &DATA, paClipOff | paDitherOff, 0.999f );
- if( err < 0 ) goto error;
- printf("\nOver range with clipping and dithering turned OFF. Should sound very nasty.\n");
- fflush(stdout);
- err = PlaySine( &DATA, paClipOff | paDitherOff, 1.1f );
- if( err < 0 ) goto error;
- printf("\nOver range with clipping and dithering turned ON. Should sound smoother than previous.\n");
- fflush(stdout);
- err = PlaySine( &DATA, paNoFlag, 1.1f );
- if( err < 0 ) goto error;
- printf("\nOver range with paClipOff but dithering ON.\n"
- "That forces clipping ON so it should sound the same as previous.\n");
- fflush(stdout);
- err = PlaySine( &DATA, paClipOff, 1.1f );
- if( err < 0 ) goto error;
- return 0;
-error:
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return 1;
-}
-/*****************************************************************************/
-PaError PlaySine( paTestData *data, unsigned long flags, float amplitude )
-{
- PortAudioStream *stream;
- PaError err;
- data->left_phase = data->right_phase = 0;
- data->amplitude = amplitude;
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- 1024,
- 0, /* number of buffers, if zero then use default minimum */
- flags, /* we won't output out of range samples so don't bother clipping them */
- sineCallback,
- data );
- if( err != paNoError ) goto error;
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- Pa_Sleep( NUM_SECONDS * 1000 );
- printf("CPULoad = %8.6f\n", Pa_GetCPULoad( stream ) );
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- return paNoError;
-error:
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_dither.c b/pd/portaudio/pa_tests/patest_dither.c
deleted file mode 100644
index 2ab11e7b..00000000
--- a/pd/portaudio/pa_tests/patest_dither.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * $Id: patest_dither.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_dither.c
- * Attempt to hear difference between dithered and non-dithered signal.
- * This only has an effect if the native format is 16 bit.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define NUM_SECONDS (4)
-#define SAMPLE_RATE (44100)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (200)
-typedef struct paTestData
-{
- float sine[TABLE_SIZE];
- float amplitude;
- int left_phase;
- int right_phase;
-}
-paTestData;
-PaError PlaySine( paTestData *data, PaStreamFlags flags, float amplitude );
-static int sineCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-/* 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( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- float amplitude = data->amplitude;
- unsigned int i;
- (void) outTime;
- (void) inputBuffer;
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = amplitude * data->sine[data->left_phase]; /* left */
- *out++ = amplitude * data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- return 0;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError err;
- paTestData DATA;
- int i;
- float amplitude = 32.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++ )
- {
- DATA.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
- }
- printf("\nNo treatment..\n"); fflush(stdout);
- err = PlaySine( &DATA, paClipOff | paDitherOff, amplitude );
- if( err < 0 ) goto error;
- printf("\nClip.\n");
- fflush(stdout);
- err = PlaySine( &DATA, paDitherOff, amplitude );
- if( err < 0 ) goto error;
- printf("\nClip and Dither.\n");
- fflush(stdout);
- err = PlaySine( &DATA, paNoFlag, amplitude );
- if( err < 0 ) goto error;
- return 0;
-error:
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return -1;
-}
-/*****************************************************************************/
-PaError PlaySine( paTestData *data, PaStreamFlags flags, float amplitude )
-{
- PortAudioStream *stream;
- PaError err;
- data->left_phase = data->right_phase = 0;
- data->amplitude = amplitude;
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- 1024,
- 0, /* number of buffers, if zero then use default minimum */
- flags, /* we won't output out of range samples so don't bother clipping them */
- sineCallback,
- (void *)data );
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- Pa_Sleep( NUM_SECONDS * 1000 );
- printf("CPULoad = %8.6f\n", Pa_GetCPULoad( stream ) );
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- return paNoError;
-error:
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_hang.c b/pd/portaudio/pa_tests/patest_hang.c
deleted file mode 100644
index b97727ba..00000000
--- a/pd/portaudio/pa_tests/patest_hang.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * $Id: patest_hang.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * Play a sine then hang audio callback to test watchdog.
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (1024)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TWOPI (M_PI * 2.0)
-
-typedef struct paTestData
-{
- int sleepFor;
- double 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned long i;
- int finished = 0;
- double phaseInc = 0.02;
- double phase = data->phase;
-
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- phase += phaseInc;
- if( phase > TWOPI ) phase -= TWOPI;
- /* 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;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- int i;
- paTestData data = {0};
-
- printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n",
- SAMPLE_RATE, FRAMES_PER_BUFFER );
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 1, /* mono output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- 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;
-
-/* Gradually increase sleep time. */
- for( i=0; i<10000; i+= 1000 )
- {
- printf("Sleep for %d milliseconds in audio callback.\n", i );
- 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 );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_latency.c b/pd/portaudio/pa_tests/patest_latency.c
deleted file mode 100644
index 261a005c..00000000
--- a/pd/portaudio/pa_tests/patest_latency.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- * $Id: patest_latency.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * 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
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDeviceID())
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (64)
-
-#if 0
-#define MIN_LATENCY_MSEC (2000)
-#define NUM_BUFFERS ((MIN_LATENCY_MSEC * SAMPLE_RATE) / (FRAMES_PER_BUFFER * 1000))
-#else
-#define NUM_BUFFERS (0)
-#endif
-
-#define MIN_FREQ (100.0f)
-#define CalcPhaseIncrement(freq) ((freq)/SAMPLE_RATE)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (400)
-typedef struct
-{
- float sine[TABLE_SIZE + 1]; // add one for guard point for interpolation
- float phase_increment;
- float left_phase;
- float right_phase;
-}
-paTestData;
-float LookupSine( paTestData *data, float phase );
-/* Convert phase between and 1.0 to sine value
- * using linear interpolation.
- */
-float LookupSine( paTestData *data, float phase )
-{
- float fIndex = phase*TABLE_SIZE;
- int index = (int) fIndex;
- float fract = fIndex - index;
- float lo = data->sine[index];
- float hi = data->sine[index+1];
- float val = lo + fract*(hi-lo);
- return val;
-}
-/* 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- int i;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = LookupSine(data, data->left_phase); /* left */
- *out++ = LookupSine(data, data->right_phase); /* right */
- data->left_phase += data->phase_increment;
- if( data->left_phase >= 1.0f ) data->left_phase -= 1.0f;
- data->right_phase += (data->phase_increment * 1.5f); /* fifth above */
- if( data->right_phase >= 1.0f ) data->right_phase -= 1.0f;
- }
- return 0;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- int done = 0;
- printf("PortAudio Test: enter letter then hit ENTER. numBuffers = %d\n", NUM_BUFFERS );
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- data.sine[i] = 0.90f * (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
- }
- data.sine[TABLE_SIZE] = data.sine[0]; // set guard point
- data.left_phase = data.right_phase = 0.0;
- data.phase_increment = CalcPhaseIncrement(MIN_FREQ);
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- printf("PortAudio Test: output device = %d\n", OUTPUT_DEVICE );
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- OUTPUT_DEVICE,
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER,
- NUM_BUFFERS, /* number of buffers, if zero then use default minimum */
- paClipOff|paDitherOff, /* 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 ASCII keyboard. Hit 'q' to stop. (Use RETURN key on Mac)\n");
- fflush(stdout);
- while ( !done )
- {
- float freq;
- int index;
- char c;
- do
- {
- c = getchar();
- }
- while( c < ' '); /* Strip white space and control chars. */
-
- if( c == 'q' ) done = 1;
- index = c % 26;
- freq = MIN_FREQ + (index * 40.0);
- data.phase_increment = CalcPhaseIncrement(freq);
- }
- printf("Call Pa_StopStream()\n");
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_leftright.c b/pd/portaudio/pa_tests/patest_leftright.c
deleted file mode 100644
index d23c8b2c..00000000
--- a/pd/portaudio/pa_tests/patest_leftright.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * $Id: patest_leftright.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_leftright.c
- * Play different tone sine waves that alternate between left and right channel.
- * The low tone should be on the left channel.
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define NUM_SECONDS (8)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (512)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (200)
-typedef struct
-{
- float sine[TABLE_SIZE];
- int left_phase;
- int right_phase;
- int toggle;
- int countDown;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned long i;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- if( data->toggle )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = 0; /* right */
- }
- else
- {
- *out++ = 0; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
-
- if( data->countDown < 0 )
- {
- data->countDown = SAMPLE_RATE;
- data->toggle = !data->toggle;
- }
- data->countDown -= framesPerBuffer;
-
- return finished;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- int timeout;
-
- 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++ )
- {
- data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
- }
- data.left_phase = data.right_phase = data.toggle = 0;
- data.countDown = SAMPLE_RATE;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- 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 several seconds.\n");
- timeout = NUM_SECONDS * 4;
- while( timeout > 0 )
- {
- Pa_Sleep( 300 );
- timeout -= 1;
- }
-
- 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 occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_longsine.c b/pd/portaudio/pa_tests/patest_longsine.c
deleted file mode 100644
index cc48c44a..00000000
--- a/pd/portaudio/pa_tests/patest_longsine.c
+++ /dev/null
@@ -1,137 +0,0 @@
-/*
- * $Id: patest_longsine.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_longsine.c
- * Play a sine wave using the Portable Audio api until ENTER hit.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define SAMPLE_RATE (44100)
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-#define TABLE_SIZE (200)
-typedef struct
-{
- float sine[TABLE_SIZE];
- int left_phase;
- 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned int i;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- return 0;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- printf("PortAudio Test: output sine wave.\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;
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- 256, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- 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("Hit ENTER to stop program.\n");
- getchar();
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
-
- printf("Test finished.\n");
- return err;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_many.c b/pd/portaudio/pa_tests/patest_many.c
deleted file mode 100644
index f42efb52..00000000
--- a/pd/portaudio/pa_tests/patest_many.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * $Id: patest_many.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_many.c
- * Start and stop the PortAudio Driver multiple times.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <math.h>
-#include "portaudio.h"
-#define NUM_SECONDS (1)
-#define SAMPLE_RATE (44100)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (200)
-typedef struct
-{
- short sine[TABLE_SIZE];
- int left_phase;
- int right_phase;
- unsigned int sampsToGo;
-}
-paTestData;
-PaError TestOnce( void );
-static int patest1Callback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-/* 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 patest1Callback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- short *out = (short*)outputBuffer;
- unsigned int i;
- int finished = 0;
- (void) inputBuffer; /* Prevent "unused variable" warnings. */
- (void) outTime;
-
- if( data->sampsToGo < framesPerBuffer )
- {
- /* final buffer... */
-
- for( i=0; i<data->sampsToGo; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- /* zero remainder of final buffer */
- for( ; i<framesPerBuffer; i++ )
- {
- *out++ = 0; /* left */
- *out++ = 0; /* right */
- }
-
- finished = 1;
- }
- else
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- data->sampsToGo -= framesPerBuffer;
- }
- return finished;
-}
-/*******************************************************************/
-#ifdef MACINTOSH
-int main(void);
-int main(void)
-{
- int i;
- PaError err;
- int numLoops = 10;
- printf("Loop %d times.\n", numLoops );
- for( i=0; i<numLoops; i++ )
- {
- printf("Loop %d out of %d.\n", i+1, numLoops );
- err = TestOnce();
- if( err < 0 ) return 0;
- }
-}
-#else
-int main(int argc, char **argv);
-int main(int argc, char **argv)
-{
- PaError err;
- int i, numLoops = 10;
- if( argc > 1 )
- {
- numLoops = atoi(argv[1]);
- }
- for( i=0; i<numLoops; i++ )
- {
- printf("Loop %d out of %d.\n", i+1, numLoops );
- err = TestOnce();
- if( err < 0 ) return 1;
- }
- printf("Test complete.\n");
- return 0;
-}
-#endif
-PaError TestOnce( void )
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- int totalSamps;
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- data.sine[i] = (short) (32767.0 * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ));
- }
- data.left_phase = data.right_phase = 0;
- data.sampsToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paInt16, /* sample format */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paInt16, /* sample format */
- NULL,
- SAMPLE_RATE,
- 1024, /* frames per buffer */
- 8, /* number of buffers, if zero then use default minimum */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- patest1Callback,
- &data );
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- printf("Waiting for sound to finish.\n");
- Pa_Sleep(1000);
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- return paNoError;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_maxsines.c b/pd/portaudio/pa_tests/patest_maxsines.c
deleted file mode 100644
index 9fcd7ba8..00000000
--- a/pd/portaudio/pa_tests/patest_maxsines.c
+++ /dev/null
@@ -1,197 +0,0 @@
-/*
- * $Id: patest_maxsines.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_maxsines.c
- * How many sine waves can we calculate and play in less than 80% CPU Load.
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define MAX_SINES (500)
-#define MAX_USAGE (0.8)
-#define SAMPLE_RATE (44100)
-#define FREQ_TO_PHASE_INC(freq) (freq/(float)SAMPLE_RATE)
-
-#define MIN_PHASE_INC FREQ_TO_PHASE_INC(200.0f)
-#define MAX_PHASE_INC (MIN_PHASE_INC * (1 << 5))
-
-#define FRAMES_PER_BUFFER (512)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TWOPI (M_PI * 2.0)
-
-#define TABLE_SIZE (512)
-
-typedef struct paTestData
-{
- int numSines;
- float sine[TABLE_SIZE + 1]; /* add one for guard point for interpolation */
- float phases[MAX_SINES];
-}
-paTestData;
-
-/* Convert phase between and 1.0 to sine value
- * using linear interpolation.
- */
-float LookupSine( paTestData *data, float phase );
-float LookupSine( paTestData *data, float phase )
-{
- float fIndex = phase*TABLE_SIZE;
- int index = (int) fIndex;
- float fract = fIndex - index;
- float lo = data->sine[index];
- float hi = data->sine[index+1];
- float val = lo + fract*(hi-lo);
- return val;
-}
-
-/* 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- float outSample;
- float scaler;
- int numForScale;
- unsigned long i;
- int j;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
-/* Detemine amplitude scaling factor */
- 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;
- float phaseInc = MIN_PHASE_INC;
- float phase;
- for( j=0; j<data->numSines; j++ )
- {
- /* Advance phase of next oscillator. */
- phase = data->phases[j];
- phase += phaseInc;
- if( phase >= 1.0 ) phase -= 1.0;
-
- output += LookupSine(data, phase);
- data->phases[j] = phase;
-
- phaseInc *= 1.02f;
- if( phaseInc > MAX_PHASE_INC ) phaseInc = MIN_PHASE_INC;
- }
-
- outSample = (float) (output * scaler);
- *out++ = outSample; /* Left */
- *out++ = outSample; /* Right */
- }
- return finished;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- int i;
- PaStream *stream;
- PaError err;
- paTestData data = {0};
- double load;
- 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.sine[TABLE_SIZE] = data.sine[0]; /* set guard point */
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* no input */
- paFloat32,
- 0, /* default latency */
- NULL,
- Pa_GetDefaultOutputDevice(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- 0, /* default latency */
- NULL,
- SAMPLE_RATE,
- 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;
-
-/* Play an increasing number of sine waves until we hit MAX_USAGE */
- do
- {
- data.numSines++;
- Pa_Sleep( 200 );
-
- load = Pa_GetStreamCpuLoad( stream );
- printf("numSines = %d, CPU load = %f\n", data.numSines, load );
- fflush( stdout );
- }
- while( (load < MAX_USAGE) && (data.numSines < MAX_SINES) );
-
- 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 occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_multi_sine.c b/pd/portaudio/pa_tests/patest_multi_sine.c
deleted file mode 100644
index 2b78e932..00000000
--- a/pd/portaudio/pa_tests/patest_multi_sine.c
+++ /dev/null
@@ -1,175 +0,0 @@
-/*
- * $Id: patest_multi_sine.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_multi_out.c
- * Play a different sine wave on each channels,
- * using the Portable Audio api.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDevice())
-//#define NON_INTERLEAVED
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (0) // take what we get(256)
-#define FREQ_INCR (300.0 / SAMPLE_RATE)
-#define MAX_CHANNELS (64)
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-typedef struct
-{
- int numChannels;
- double phases[MAX_CHANNELS];
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- float **outputs = (float**)outputBuffer;
-
-#ifdef NON_INTERLEAVED
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- int frameIndex, channelIndex;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( frameIndex=0; frameIndex<(int)framesPerBuffer; frameIndex++ )
- {
- for( channelIndex=0; channelIndex<data->numChannels; channelIndex++ )
- {
- /* Output sine wave on every channel. */
- outputs[channelIndex][frameIndex] = (float) sin(data->phases[channelIndex]);
-
- /* Play each channel at a higher frequency. */
- data->phases[channelIndex] += FREQ_INCR * (4 + channelIndex);
- if( data->phases[channelIndex] >= (2.0 * M_PI) ) data->phases[channelIndex] -= (2.0 * M_PI);
- }
- }
-
-#else /* interleaved version */
-
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- int frameIndex, channelIndex;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( frameIndex=0; frameIndex<(int)framesPerBuffer; frameIndex++ )
- {
- for( channelIndex=0; channelIndex<data->numChannels; channelIndex++ )
- {
- /* Output sine wave on every channel. */
- *out++ = (float) sin(data->phases[channelIndex]);
-
- /* Play each channel at a higher frequency. */
- data->phases[channelIndex] += FREQ_INCR * (4 + channelIndex);
- if( data->phases[channelIndex] >= (2.0 * M_PI) ) data->phases[channelIndex] -= (2.0 * M_PI);
- }
- }
-#endif /* NON_INTERLEAVED */
- return 0;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStream *stream;
- PaError err;
- const PaDeviceInfo *pdi;
- paTestData data = {0};
- printf("PortAudio Test: output sine wave on each channel.\n" );
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- pdi = Pa_GetDeviceInfo( OUTPUT_DEVICE );
- data.numChannels = pdi->maxOutputChannels;
- if( data.numChannels > MAX_CHANNELS ) data.numChannels = MAX_CHANNELS;
- printf("Number of Channels = %d\n", data.numChannels );
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice, /* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- 0, /* default input latency */
- NULL,
- OUTPUT_DEVICE,
- data.numChannels,
-#ifdef NON_INTERLEAVED
- paFloat32 | paNonInterleaved, /* 32 bit floating point output */
-#else
- paFloat32,
-#endif
- 0, /* default output latency */
- NULL,
- 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;
-
- printf("Hit ENTER to stop sound.\n");
- getchar();
-
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
-
- Pa_CloseStream( stream );
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_pink.c b/pd/portaudio/pa_tests/patest_pink.c
deleted file mode 100644
index 7a3e29cd..00000000
--- a/pd/portaudio/pa_tests/patest_pink.c
+++ /dev/null
@@ -1,245 +0,0 @@
-/*
- * $Id: patest_pink.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- patest_pink.c
- Generate Pink Noise using Gardner method.
- 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
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define PINK_MAX_RANDOM_ROWS (30)
-#define PINK_RANDOM_BITS (24)
-#define PINK_RANDOM_SHIFT ((sizeof(long)*8)-PINK_RANDOM_BITS)
-typedef struct
-{
- long pink_Rows[PINK_MAX_RANDOM_ROWS];
- long pink_RunningSum; /* Used to optimize summing of generators. */
- int pink_Index; /* Incremented each sample. */
- int pink_IndexMask; /* Index wrapped by ANDing with this mask. */
- float pink_Scalar; /* Used to scale within range of -1.0 to +1.0 */
-}
-PinkNoise;
-/* Prototypes */
-static unsigned long GenerateRandomNumber( void );
-void InitializePinkNoise( PinkNoise *pink, int numRows );
-float GeneratePinkNoise( PinkNoise *pink );
-/************************************************************/
-/* Calculate pseudo-random 32 bit number based on linear congruential method. */
-static unsigned long GenerateRandomNumber( void )
-{
- /* Change this seed for different random sequences. */
- static unsigned long randSeed = 22222;
- randSeed = (randSeed * 196314165) + 907633515;
- return randSeed;
-}
-/************************************************************/
-/* Setup PinkNoise structure for N rows of generators. */
-void InitializePinkNoise( PinkNoise *pink, int numRows )
-{
- int i;
- long pmax;
- pink->pink_Index = 0;
- pink->pink_IndexMask = (1<<numRows) - 1;
- /* Calculate maximum possible signed random value. Extra 1 for white noise always added. */
- pmax = (numRows + 1) * (1<<(PINK_RANDOM_BITS-1));
- pink->pink_Scalar = 1.0f / pmax;
- /* Initialize rows. */
- for( i=0; i<numRows; i++ ) pink->pink_Rows[i] = 0;
- pink->pink_RunningSum = 0;
-}
-#define PINK_MEASURE
-#ifdef PINK_MEASURE
-float pinkMax = -999.0;
-float pinkMin = 999.0;
-#endif
-/* Generate Pink noise values between -1.0 and +1.0 */
-float GeneratePinkNoise( PinkNoise *pink )
-{
- long newRandom;
- long sum;
- float output;
- /* Increment and mask index. */
- pink->pink_Index = (pink->pink_Index + 1) & pink->pink_IndexMask;
- /* If index is zero, don't update any random values. */
- if( pink->pink_Index != 0 )
- {
- /* Determine how many trailing zeros in PinkIndex. */
- /* This algorithm will hang if n==0 so test first. */
- int numZeros = 0;
- int n = pink->pink_Index;
- while( (n & 1) == 0 )
- {
- n = n >> 1;
- numZeros++;
- }
- /* Replace the indexed ROWS random value.
- * Subtract and add back to RunningSum instead of adding all the random
- * values together. Only one changes each time.
- */
- pink->pink_RunningSum -= pink->pink_Rows[numZeros];
- newRandom = ((long)GenerateRandomNumber()) >> PINK_RANDOM_SHIFT;
- pink->pink_RunningSum += newRandom;
- pink->pink_Rows[numZeros] = newRandom;
- }
-
- /* Add extra white noise value. */
- newRandom = ((long)GenerateRandomNumber()) >> PINK_RANDOM_SHIFT;
- sum = pink->pink_RunningSum + newRandom;
- /* Scale to range of -1.0 to 0.9999. */
- output = pink->pink_Scalar * sum;
-#ifdef PINK_MEASURE
- /* Check Min/Max */
- if( output > pinkMax ) pinkMax = output;
- else if( output < pinkMin ) pinkMin = output;
-#endif
- return output;
-}
-/*******************************************************************/
-#define PINK_TEST
-#ifdef PINK_TEST
-/* Context for callback routine. */
-typedef struct
-{
- PinkNoise leftPink;
- PinkNoise rightPink;
- unsigned int sampsToGo;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- int finished;
- int i;
- int numFrames;
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- (void) inputBuffer; /* Prevent "unused variable" warnings. */
- (void) outTime;
-
- /* Are we almost at end. */
- if( data->sampsToGo < framesPerBuffer )
- {
- numFrames = data->sampsToGo;
- finished = 1;
- }
- else
- {
- numFrames = framesPerBuffer;
- finished = 0;
- }
- for( i=0; i<numFrames; i++ )
- {
- *out++ = GeneratePinkNoise( &data->leftPink );
- *out++ = GeneratePinkNoise( &data->rightPink );
- }
- data->sampsToGo -= numFrames;
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int totalSamps;
- /* Initialize two pink noise signals with different numbers of rows. */
- InitializePinkNoise( &data.leftPink, 12 );
- InitializePinkNoise( &data.rightPink, 16 );
- /* Look at a few values. */
- {
- int i;
- float pink;
- for( i=0; i<20; i++ )
- {
- pink = GeneratePinkNoise( &data.leftPink );
- printf("Pink = %f\n", pink );
- }
- }
- data.sampsToGo = totalSamps = 8*44100; /* Play for a few seconds. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- /* Open a stereo PortAudio stream so we can hear the result. */
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- 44100.,
- 2048, /* 46 msec buffers */
- 0, /* number of buffers, if zero then use default minimum */
- 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("Waiting for sound to finish.\n");
- while( Pa_StreamActive( stream ) )
- {
- Pa_Sleep(100); /* SPIN! */
- }
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
-#ifdef PINK_MEASURE
- printf("Pink min = %f, max = %f\n", pinkMin, pinkMax );
-#endif
- Pa_Terminate();
- return 0;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return 0;
-}
-#endif /* PINK_TEST */
diff --git a/pd/portaudio/pa_tests/patest_record.c b/pd/portaudio/pa_tests/patest_record.c
deleted file mode 100644
index 59471aaf..00000000
--- a/pd/portaudio/pa_tests/patest_record.c
+++ /dev/null
@@ -1,327 +0,0 @@
-/*
- * $Id: patest_record.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_record.c
- * Record input into an array.
- * Save array to a file.
- * Playback recorded data.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include "portaudio.h"
-
-/* #define SAMPLE_RATE (17932) /* Test failure to open with this value. */
-#define SAMPLE_RATE (44100)
-#define NUM_SECONDS (5)
-#define NUM_CHANNELS (2)
-/* #define DITHER_FLAG (paDitherOff) /**/
-#define DITHER_FLAG (0) /**/
-
-/* Select sample format. */
-#if 1
-#define PA_SAMPLE_TYPE paFloat32
-typedef float SAMPLE;
-#define SAMPLE_SILENCE (0.0f)
-#elif 1
-#define PA_SAMPLE_TYPE paInt16
-typedef short SAMPLE;
-#define SAMPLE_SILENCE (0)
-#elif 0
-#define PA_SAMPLE_TYPE paInt8
-typedef char SAMPLE;
-#define SAMPLE_SILENCE (0)
-#else
-#define PA_SAMPLE_TYPE paUInt8
-typedef unsigned char SAMPLE;
-#define SAMPLE_SILENCE (128)
-
-#endif
-
-typedef struct
-{
- int frameIndex; /* Index into sample array. */
- int maxFrameIndex;
- SAMPLE *recordedSamples;
-}
-paTestData;
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 recordCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE *rptr = (SAMPLE*)inputBuffer;
- SAMPLE *wptr = &data->recordedSamples[data->frameIndex * NUM_CHANNELS];
- long framesToCalc;
- long i;
- int finished;
- unsigned long framesLeft = data->maxFrameIndex - data->frameIndex;
-
- (void) outputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( framesLeft < framesPerBuffer )
- {
- framesToCalc = framesLeft;
- finished = paComplete;
- }
- else
- {
- framesToCalc = framesPerBuffer;
- finished = paContinue;
- }
-
- if( inputBuffer == NULL )
- {
- for( i=0; i<framesToCalc; i++ )
- {
- *wptr++ = SAMPLE_SILENCE; /* left */
- if( NUM_CHANNELS == 2 ) *wptr++ = SAMPLE_SILENCE; /* right */
- }
- }
- else
- {
- for( i=0; i<framesToCalc; i++ )
- {
- *wptr++ = *rptr++; /* left */
- if( NUM_CHANNELS == 2 ) *wptr++ = *rptr++; /* right */
- }
- }
- data->frameIndex += framesToCalc;
- return finished;
-}
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 playCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE *rptr = &data->recordedSamples[data->frameIndex * NUM_CHANNELS];
- SAMPLE *wptr = (SAMPLE*)outputBuffer;
- unsigned int i;
- int finished;
- unsigned int framesLeft = data->maxFrameIndex - data->frameIndex;
- (void) inputBuffer; /* Prevent unused variable warnings. */
- (void) outTime;
-
- if( framesLeft < framesPerBuffer )
- {
- /* final buffer... */
- for( i=0; i<framesLeft; i++ )
- {
- *wptr++ = *rptr++; /* left */
- if( NUM_CHANNELS == 2 ) *wptr++ = *rptr++; /* right */
- }
- for( ; i<framesPerBuffer; i++ )
- {
- *wptr++ = 0; /* left */
- if( NUM_CHANNELS == 2 ) *wptr++ = 0; /* right */
- }
- data->frameIndex += framesLeft;
- finished = paComplete;
- }
- else
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- *wptr++ = *rptr++; /* left */
- if( NUM_CHANNELS == 2 ) *wptr++ = *rptr++; /* right */
- }
- data->frameIndex += framesPerBuffer;
- finished = paContinue;
- }
- return finished;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStream *stream;
- PaError err;
- paTestData data;
- int i;
- int totalFrames;
- int numSamples;
- int numBytes;
- SAMPLE max, average, val;
- printf("patest_record.c\n"); fflush(stdout);
-
- data.maxFrameIndex = totalFrames = NUM_SECONDS * SAMPLE_RATE; /* Record for a few seconds. */
- data.frameIndex = 0;
- numSamples = totalFrames * NUM_CHANNELS;
-
- numBytes = numSamples * sizeof(SAMPLE);
- data.recordedSamples = (SAMPLE *) malloc( numBytes );
- if( data.recordedSamples == NULL )
- {
- printf("Could not allocate record array.\n");
- exit(1);
- }
- for( i=0; i<numSamples; i++ ) data.recordedSamples[i] = 0;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- /* Record some audio. -------------------------------------------- */
- err = Pa_OpenStream(
- &stream,
- Pa_GetDefaultInputDevice(),
- NUM_CHANNELS, /* stereo input */
- PA_SAMPLE_TYPE,
- 0, /* default latency */
- NULL,
- paNoDevice,
- 0,
- PA_SAMPLE_TYPE,
- 0, /* default latency */
- NULL,
- SAMPLE_RATE,
- 1024, /* frames per buffer */
- 0, //paDitherOff, /* flags */
- recordCallback,
- &data );
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- printf("Now recording!!\n"); fflush(stdout);
-
- while( Pa_IsStreamActive( stream ) )
- {
- Pa_Sleep(1000);
- printf("index = %d\n", data.frameIndex ); fflush(stdout);
- }
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
-
- /* Measure maximum peak amplitude. */
- max = 0;
- average = 0;
- for( i=0; i<numSamples; i++ )
- {
- val = data.recordedSamples[i];
- if( val < 0 ) val = -val; /* ABS */
- if( val > max )
- {
- max = val;
- }
- average += val;
- }
-
- average = average / numSamples;
-
- if( PA_SAMPLE_TYPE == paFloat32 )
- {
- printf("sample max amplitude = %f\n", max );
- printf("sample average = %f\n", average );
- }
- else
- {
- printf("sample max amplitude = %d\n", max );
- printf("sample average = %d\n", average );
- }
-
- /* Write recorded data to a file. */
-#if 0
- {
- FILE *fid;
- fid = fopen("recorded.raw", "wb");
- if( fid == NULL )
- {
- printf("Could not open file.");
- }
- else
- {
- fwrite( data.recordedSamples, NUM_CHANNELS * sizeof(SAMPLE), totalFrames, fid );
- fclose( fid );
- printf("Wrote data to 'recorded.raw'\n");
- }
- }
-#endif
-
- /* Playback recorded data. -------------------------------------------- */
- data.frameIndex = 0;
- printf("Begin playback.\n"); fflush(stdout);
- err = Pa_OpenStream(
- &stream,
- paNoDevice,
- 0, /* NO input */
- PA_SAMPLE_TYPE,
- 0, /* default latency */
- NULL,
- Pa_GetDefaultOutputDevice(),
- NUM_CHANNELS, /* stereo output */
- PA_SAMPLE_TYPE,
- 0, /* default latency */
- NULL,
- SAMPLE_RATE,
- 1024, /* frames per buffer */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- playCallback,
- &data );
- if( err != paNoError ) goto error;
-
- if( stream )
- {
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- printf("Waiting for playback to finish.\n"); fflush(stdout);
-
- while( Pa_IsStreamActive( stream ) ) Pa_Sleep(100);
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- printf("Done.\n"); fflush(stdout);
- }
- free( data.recordedSamples );
-
- Pa_Terminate();
- return 0;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return -1;
-}
diff --git a/pd/portaudio/pa_tests/patest_ringmix.c b/pd/portaudio/pa_tests/patest_ringmix.c
deleted file mode 100644
index 34c66381..00000000
--- a/pd/portaudio/pa_tests/patest_ringmix.c
+++ /dev/null
@@ -1,41 +0,0 @@
-/* $Id: patest_ringmix.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $ */
-
-#include "stdio.h"
-#include "portaudio.h"
-/* This will be called asynchronously by the PortAudio engine. */
-static int myCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer, PaTimestamp outTime, void *userData )
-{
- float *out = (float *) outputBuffer;
- float *in = (float *) inputBuffer;
- float leftInput, rightInput;
- unsigned int i;
- if( inputBuffer == NULL ) return 0;
- /* Read input buffer, process data, and fill output buffer. */
- for( i=0; i<framesPerBuffer; i++ )
- {
- leftInput = *in++; /* Get interleaved samples from input buffer. */
- rightInput = *in++;
- *out++ = leftInput * rightInput; /* ring modulation */
- *out++ = 0.5f * (leftInput + rightInput); /* mix */
- }
- return 0;
-}
-/* Open a PortAudioStream to input and output audio data. */
-int main(void)
-{
- PortAudioStream *stream;
- Pa_Initialize();
- Pa_OpenDefaultStream(
- &stream,
- 2, 2, /* stereo input and output */
- paFloat32, 44100.0,
- 64, 0, /* 64 frames per buffer, let PA determine numBuffers */
- myCallback, NULL );
- Pa_StartStream( stream );
- Pa_Sleep( 10000 ); /* Sleep for 10 seconds while processing. */
- Pa_StopStream( stream );
- Pa_CloseStream( stream );
- Pa_Terminate();
- return 0;
-}
diff --git a/pd/portaudio/pa_tests/patest_saw.c b/pd/portaudio/pa_tests/patest_saw.c
deleted file mode 100644
index da1851ed..00000000
--- a/pd/portaudio/pa_tests/patest_saw.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * $Id: patest_saw.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_saw.c
- * Play a simple sawtooth wave.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define NUM_SECONDS (4)
-#define SAMPLE_RATE (44100)
-typedef struct
-{
- float left_phase;
- float 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- /* Cast data passed through stream to our structure. */
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned int i;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = data->left_phase; /* left */
- *out++ = data->right_phase; /* right */
- /* Generate simple sawtooth phaser that ranges between -1.0 and 1.0. */
- data->left_phase += 0.01f;
- /* When signal reaches top, drop back down. */
- if( data->left_phase >= 1.0f ) data->left_phase -= 2.0f;
- /* higher pitch so we can distinguish left and right. */
- data->right_phase += 0.03f;
- if( data->right_phase >= 1.0f ) data->right_phase -= 2.0f;
- }
- return 0;
-}
-/*******************************************************************/
-static paTestData data;
-int main(void);
-int main(void)
-{
- PortAudioStream *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 */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- SAMPLE_RATE,
- 256, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- patestCallback,
- &data );
- if( err != paNoError ) goto error;
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- /* Sleep for several 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();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_sine.c b/pd/portaudio/pa_tests/patest_sine.c
deleted file mode 100644
index 1bebb90e..00000000
--- a/pd/portaudio/pa_tests/patest_sine.c
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * $Id: patest_sine.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_sine.c
- * Play a sine wave using the Portable Audio api for several seconds.
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define NUM_SECONDS (5)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (64)
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-#define TABLE_SIZE (200)
-typedef struct
-{
- float sine[TABLE_SIZE];
- int left_phase;
- 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned long i;
-
- (void) timeInfo; /* Prevent unused variable warnings. */
- (void) statusFlags;
- (void) inputBuffer;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
-
- return paContinue;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStreamParameters outputParameters;
- PaStream *stream;
- PaError err;
- 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;
-
- outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
- 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 */
- &outputParameters,
- SAMPLE_RATE,
- 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();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_sine8.c b/pd/portaudio/pa_tests/patest_sine8.c
deleted file mode 100644
index f3ef9ebb..00000000
--- a/pd/portaudio/pa_tests/patest_sine8.c
+++ /dev/null
@@ -1,184 +0,0 @@
-/*
- * $Id: patest_sine8.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_sine8.c
- * Play a sine wave using the Portable Audio api for several seconds.
- * Test 8 bit data.
- *
- * Author: Ross Bencina <rossb@audiomulch.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define NUM_SECONDS (8)
-#define SAMPLE_RATE (44100)
-#define TEST_UNSIGNED (1)
-#if TEST_UNSIGNED
-#define TEST_FORMAT paUInt8
-#else
-#define TEST_FORMAT paInt8
-#endif
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (200)
-typedef struct
-{
-#if TEST_UNSIGNED
- unsigned char sine[TABLE_SIZE];
-#else
- char sine[TABLE_SIZE];
-#endif
- int left_phase;
- int right_phase;
- unsigned int framesToGo;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- char *out = (char*)outputBuffer;
- int i;
- int framesToCalc;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- if( data->framesToGo < framesPerBuffer )
- {
- framesToCalc = data->framesToGo;
- data->framesToGo = 0;
- finished = 1;
- }
- else
- {
- framesToCalc = framesPerBuffer;
- data->framesToGo -= framesPerBuffer;
- }
-
- for( i=0; i<framesToCalc; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
- /* zero remainder of final buffer */
- for( ; i<(int)framesPerBuffer; i++ )
- {
-#if TEST_UNSIGNED
- *out++ = (unsigned char) 0x80; /* left */
- *out++ = (unsigned char) 0x80; /* right */
-#else
- *out++ = 0; /* left */
- *out++ = 0; /* right */
-#endif
-
- }
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- paTestData data;
- int i;
- int totalSamps;
-#if TEST_UNSIGNED
- printf("PortAudio Test: output UNsigned 8 bit sine wave.\n");
-#else
- printf("PortAudio Test: output signed 8 bit sine wave.\n");
-#endif
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- data.sine[i] = (char) (127.0 * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. ));
-#if TEST_UNSIGNED
- data.sine[i] += (unsigned char) 0x80;
-#endif
-
- }
- data.left_phase = data.right_phase = 0;
- data.framesToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- TEST_FORMAT,
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- TEST_FORMAT,
- NULL,
- SAMPLE_RATE,
- 256, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- 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;
- /* Watch until sound is halfway finished. */
- while( Pa_StreamTime( stream ) < (totalSamps/2) ) Pa_Sleep(10);
- /* Stop sound until ENTER hit. */
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
- printf("Pause for 2 seconds.\n");
- Pa_Sleep( 2000 );
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- printf("Waiting for sound to finish.\n");
- while( Pa_StreamActive( stream ) ) Pa_Sleep(10);
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_sine_formats.c b/pd/portaudio/pa_tests/patest_sine_formats.c
deleted file mode 100644
index 74e12022..00000000
--- a/pd/portaudio/pa_tests/patest_sine_formats.c
+++ /dev/null
@@ -1,196 +0,0 @@
-/*
- * $Id: patest_sine_formats.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_sine_formats.c
- * Play a sine wave using the Portable Audio api for several seconds.
- * Test various data formats.
- *
- * Author: Phil Burk
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define NUM_SECONDS (10)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (512)
-#define LEFT_FREQ (SAMPLE_RATE/256.0) /* So we hit 1.0 */
-#define RIGHT_FREQ (500.0)
-#define AMPLITUDE (1.0)
-
-/* Select ONE format for testing. */
-#define TEST_UINT8 (0)
-#define TEST_INT8 (0)
-#define TEST_INT16 (1)
-#define TEST_FLOAT32 (0)
-
-#if TEST_UINT8
-#define TEST_FORMAT paUInt8
-typedef unsigned char SAMPLE_t;
-#define SAMPLE_ZERO (0x80)
-#define DOUBLE_TO_SAMPLE(x) (SAMPLE_ZERO + (SAMPLE_t)(127.0 * (x)))
-#define FORMAT_NAME "Unsigned 8 Bit"
-
-#elif TEST_INT8
-#define TEST_FORMAT paInt8
-typedef char SAMPLE_t;
-#define SAMPLE_ZERO (0)
-#define DOUBLE_TO_SAMPLE(x) (SAMPLE_ZERO + (SAMPLE_t)(127.0 * (x)))
-#define FORMAT_NAME "Signed 8 Bit"
-
-#elif TEST_INT16
-#define TEST_FORMAT paInt16
-typedef short SAMPLE_t;
-#define SAMPLE_ZERO (0)
-#define DOUBLE_TO_SAMPLE(x) (SAMPLE_ZERO + (SAMPLE_t)(32767 * (x)))
-#define FORMAT_NAME "Signed 16 Bit"
-
-#elif TEST_FLOAT32
-#define TEST_FORMAT paFloat32
-typedef float SAMPLE_t;
-#define SAMPLE_ZERO (0.0)
-#define DOUBLE_TO_SAMPLE(x) ((SAMPLE_t)(x))
-#define FORMAT_NAME "Float 32 Bit"
-#endif
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-
-typedef struct
-{
- double left_phase;
- double right_phase;
- unsigned int framesToGo;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- SAMPLE_t *out = (SAMPLE_t *)outputBuffer;
- int i;
- int framesToCalc;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- if( data->framesToGo < framesPerBuffer )
- {
- framesToCalc = data->framesToGo;
- data->framesToGo = 0;
- finished = 1;
- }
- else
- {
- framesToCalc = framesPerBuffer;
- data->framesToGo -= framesPerBuffer;
- }
-
- for( i=0; i<framesToCalc; i++ )
- {
- data->left_phase += (LEFT_FREQ / SAMPLE_RATE);
- if( data->left_phase > 1.0) data->left_phase -= 1.0;
- *out++ = DOUBLE_TO_SAMPLE( AMPLITUDE * sin( (data->left_phase * M_PI * 2. )));
-
- data->right_phase += (RIGHT_FREQ / SAMPLE_RATE);
- if( data->right_phase > 1.0) data->right_phase -= 1.0;
- *out++ = DOUBLE_TO_SAMPLE( AMPLITUDE * sin( (data->right_phase * M_PI * 2. )));
- }
- /* zero remainder of final buffer */
- for( ; i<(int)framesPerBuffer; i++ )
- {
- *out++ = SAMPLE_ZERO; /* left */
- *out++ = SAMPLE_ZERO; /* right */
- }
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStream *stream;
- PaError err;
- paTestData data;
- int totalSamps;
-
- printf("PortAudio Test: output " FORMAT_NAME "\n");
-
-
- data.left_phase = data.right_phase = 0.0;
- data.framesToGo = totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- TEST_FORMAT,
- 0, /* default latency */
- NULL,
- Pa_GetDefaultOutputDevice(), /* default output device */
- 2, /* stereo output */
- TEST_FORMAT,
- 0, /* default latency */
- NULL,
- SAMPLE_RATE,
- 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("Waiting %d seconds for sound to finish.\n", NUM_SECONDS );
- while( Pa_IsStreamActive( stream ) ) Pa_Sleep(10);
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
-
- printf("PortAudio Test Finished: " FORMAT_NAME "\n");
-
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_sine_time.c b/pd/portaudio/pa_tests/patest_sine_time.c
deleted file mode 100644
index c849af0a..00000000
--- a/pd/portaudio/pa_tests/patest_sine_time.c
+++ /dev/null
@@ -1,194 +0,0 @@
-/*
- * $Id: patest_sine_time.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_sine_time.c
- * Play a sine wave using the Portable Audio api for several seconds.
- * Pausing in the middle.
- * use the Pa_GetStreamTime() and Pa_IsStreamActive() calls.
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#include "pa_util.h"
-#define NUM_SECONDS (8)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (64)
-#define NUM_BUFFERS (0)
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TWOPI (M_PI * 2.0)
-
-#define TABLE_SIZE (200)
-typedef struct
-{
- double left_phase;
- double right_phase;
- volatile PaTimestamp outTime;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned int i;
-
- double left_phaseInc = 0.02;
- double right_phaseInc = 0.06;
-
- double left_phase = data->left_phase;
- double right_phase = data->right_phase;
-
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
- data->outTime = outTime;\
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- left_phase += left_phaseInc;
- if( left_phase > TWOPI ) left_phase -= TWOPI;
- *out++ = (float) sin( left_phase );
-
- right_phase += right_phaseInc;
- if( right_phase > TWOPI ) right_phase -= TWOPI;
- *out++ = (float) sin( right_phase );
- }
-
- data->left_phase = left_phase;
- data->right_phase = right_phase;
-
- return paContinue;
-}
-/*******************************************************************/
-static void ReportStreamTime( PaStream *stream, paTestData *data );
-static void ReportStreamTime( PaStream *stream, paTestData *data )
-{
- PaTimestamp streamTime, latency, outTime;
-
- streamTime = Pa_GetStreamTime( stream );
- outTime = data->outTime;
- if( outTime < 0.0 )
- {
- printf("Stream time = %8.1f\n", streamTime );
- }
- else
- {
- latency = outTime - streamTime;
- printf("Stream time = %8.1f, outTime = %8.1f, latency = %8.1f\n",
- streamTime, outTime, latency );
- }
- fflush(stdout);
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStream *stream;
- PaError err;
- paTestData DATA;
- int totalSamps;
- printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
- DATA.left_phase = DATA.right_phase = 0;
- totalSamps = NUM_SECONDS * SAMPLE_RATE; /* Play for a few seconds. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- 0, /* default latency */
- NULL,
- Pa_GetDefaultOutputDevice(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- 0, /* default latency */
- NULL,
- 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;
-
- /* Watch until sound is halfway finished. */
- printf("Play for %d seconds.\n", NUM_SECONDS/2 ); fflush(stdout);
-
- DATA.outTime = -1.0; // mark time for callback as undefined
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
- do
- {
- ReportStreamTime( stream, &DATA );
- Pa_Sleep(100);
- } while( Pa_GetStreamTime( stream ) < (totalSamps/2) );
-
- /* Stop sound until ENTER hit. */
- err = Pa_StopStream( stream );
- if( err != paNoError ) goto error;
- printf("Pause for 2 seconds.\n"); fflush(stdout);
- Pa_Sleep( 2000 );
-
- DATA.outTime = -1.0; // mark time for callback as undefined
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
-
- printf("Play until sound is finished.\n"); fflush(stdout);
- do
- {
- ReportStreamTime( stream, &DATA );
- Pa_Sleep(100);
- } while( Pa_GetStreamTime( stream ) < (totalSamps/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 occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_start_stop.c b/pd/portaudio/pa_tests/patest_start_stop.c
deleted file mode 100644
index 0e183708..00000000
--- a/pd/portaudio/pa_tests/patest_start_stop.c
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- * $Id: patest_start_stop.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_start_stop.c
- * Play a sine wave using the Portable Audio api for several seconds.
- * Start and stop the stream multiple times.
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define NUM_SECONDS (3)
-#define NUM_LOOPS (4)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (400)
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-#define TABLE_SIZE (200)
-typedef struct
-{
- float sine[TABLE_SIZE];
- int left_phase;
- 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo* timeInfo,
- PaStreamCallbackFlags statusFlags,
- void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned long i;
-
- (void) timeInfo; /* Prevent unused variable warnings. */
- (void) statusFlags;
- (void) inputBuffer;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
-
- return paContinue;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStreamParameters outputParameters;
- PaStream *stream;
- PaError err;
- 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;
-
- outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
- 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 */
- &outputParameters,
- SAMPLE_RATE,
- 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;
-
- for( i=0; i<NUM_LOOPS; i++ )
- {
- 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;
-
- printf("Stopped.\n" );
- Pa_Sleep( 1000 );
- }
-
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
-
- Pa_Terminate();
- printf("Test finished.\n");
-
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_stop.c b/pd/portaudio/pa_tests/patest_stop.c
deleted file mode 100644
index 54e72ff7..00000000
--- a/pd/portaudio/pa_tests/patest_stop.c
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * $Id: patest_stop.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_stop.c
- *
- * 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.
- *
- * Author: Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDevice())
-#define SLEEP_DUR (200)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (256)
-#define LATENCY_MSEC (3000)
-#define FRAMES_PER_NOTE (SAMPLE_RATE/2)
-#define MAX_REPEATS (2)
-#define FUNDAMENTAL (400.0f / SAMPLE_RATE)
-#define NOTE_0 (FUNDAMENTAL * 1.0f / 1.0f)
-#define NOTE_1 (FUNDAMENTAL * 5.0f / 4.0f)
-#define NOTE_2 (FUNDAMENTAL * 4.0f / 3.0f)
-#define NOTE_3 (FUNDAMENTAL * 3.0f / 2.0f)
-#define NOTE_4 (FUNDAMENTAL * 2.0f / 1.0f)
-#define MODE_FINISH (0)
-#define MODE_STOP (1)
-#define MODE_ABORT (2)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TABLE_SIZE (400)
-typedef struct
-{
- float waveform[TABLE_SIZE + 1]; // add one for guard point for interpolation
- float phase_increment;
- float phase;
- float *tune;
- int notesPerTune;
- int frameCounter;
- int noteCounter;
- int repeatCounter;
- PaTimestamp outTime;
- int stopMode;
- int done;
-}
-paTestData;
-/************* Prototypes *****************************/
-int TestStopMode( paTestData *data );
-float LookupWaveform( paTestData *data, float phase );
-/******************************************************
- * Convert phase between 0.0 and 1.0 to waveform value
- * using linear interpolation.
- */
-float LookupWaveform( paTestData *data, float phase )
-{
- float fIndex = phase*TABLE_SIZE;
- int index = (int) fIndex;
- float fract = fIndex - index;
- float lo = data->waveform[index];
- float hi = data->waveform[index+1];
- float val = lo + fract*(hi-lo);
- return val;
-}
-/* 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- float value;
- unsigned int i = 0;
- int finished = paContinue;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- data->outTime = outTime;
- if( !data->done )
- {
- for( i=0; i<framesPerBuffer; i++ )
- {
- /* Are we done with this note? */
- if( data->frameCounter >= FRAMES_PER_NOTE )
- {
- data->noteCounter += 1;
- data->frameCounter = 0;
- /* Are we done with this tune? */
- if( data->noteCounter >= data->notesPerTune )
- {
- data->noteCounter = 0;
- data->repeatCounter += 1;
- /* Are we totally done? */
- if( data->repeatCounter >= MAX_REPEATS )
- {
- data->done = 1;
- if( data->stopMode == MODE_FINISH )
- {
- finished = paComplete;
- break;
- }
- }
- }
- data->phase_increment = data->tune[data->noteCounter];
- }
- value = LookupWaveform(data, data->phase);
- *out++ = value; /* left */
- *out++ = value; /* right */
- data->phase += data->phase_increment;
- if( data->phase >= 1.0f ) data->phase -= 1.0f;
-
- data->frameCounter += 1;
- }
- }
- /* zero remainder of final buffer */
- for( ; i<framesPerBuffer; i++ )
- {
- *out++ = 0; /* left */
- *out++ = 0; /* right */
- }
- return finished;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- 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 %d latency\n", LATENCY_MSEC );
- /* initialise sinusoidal wavetable */
- for( i=0; i<TABLE_SIZE; i++ )
- {
- DATA.waveform[i] = (float) (
- (0.2 * sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. )) +
- (0.2 * sin( ((double)(3*i)/(double)TABLE_SIZE) * M_PI * 2. )) +
- (0.1 * sin( ((double)(5*i)/(double)TABLE_SIZE) * M_PI * 2. ))
- );
- }
- DATA.waveform[TABLE_SIZE] = DATA.waveform[0]; // set guard point
- DATA.tune = &simpleTune[0];
- DATA.notesPerTune = sizeof(simpleTune) / sizeof(float);
- printf("Test MODE_FINISH - callback returns 1.\n");
- printf("Should hear entire %d note tune repeated twice.\n", DATA.notesPerTune);
- DATA.stopMode = MODE_FINISH;
- if( TestStopMode( &DATA ) != paNoError )
- {
- printf("Test of MODE_FINISH failed!\n");
- goto error;
- }
- printf("Test MODE_STOP - stop when song is done.\n");
- printf("Should hear entire %d note tune repeated twice.\n", DATA.notesPerTune);
- DATA.stopMode = MODE_STOP;
- if( TestStopMode( &DATA ) != paNoError )
- {
- printf("Test of MODE_STOP failed!\n");
- goto error;
- }
-
- printf("Test MODE_ABORT - abort immediately.\n");
- printf("Should hear last repetition cut short by %d msec.\n", LATENCY_MSEC);
- DATA.stopMode = MODE_ABORT;
- if( TestStopMode( &DATA ) != paNoError )
- {
- printf("Test of MODE_ABORT failed!\n");
- goto error;
- }
- return 0;
-error:
- return 1;
-}
-
-int TestStopMode( paTestData *data )
-{
- 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;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- 0,
- NULL,
- OUTPUT_DEVICE,
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- LATENCY_MSEC,
- NULL,
- 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;
-
- if( data->stopMode == MODE_FINISH )
- {
- while( Pa_IsStreamActive( stream ) )
- {
- /*printf("outTime = %g, note# = %d, repeat# = %d\n", data->outTime,
- data->noteCounter, data->repeatCounter );
- fflush(stdout); /**/
- Pa_Sleep( SLEEP_DUR );
- }
- }
- else
- {
- while( data->repeatCounter < MAX_REPEATS )
- {
- /*printf("outTime = %g, note# = %d, repeat# = %d\n", data->outTime,
- data->noteCounter, data->repeatCounter );
- fflush(stdout); /**/
- Pa_Sleep( SLEEP_DUR );
- }
- }
-
- if( data->stopMode == MODE_ABORT )
- {
- printf("Call Pa_AbortStream()\n");
- err = Pa_AbortStream( stream );
- }
- else
- {
- printf("Call Pa_StopStream()\n");
- err = Pa_StopStream( stream );
- }
- if( err != paNoError ) goto error;
-
- printf("Call Pa_CloseStream()\n"); fflush(stdout);
- err = Pa_CloseStream( stream );
- if( err != paNoError ) goto error;
- Pa_Terminate();
- printf("Test finished.\n");
- return err;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_sync.c b/pd/portaudio/pa_tests/patest_sync.c
deleted file mode 100644
index 46854eb6..00000000
--- a/pd/portaudio/pa_tests/patest_sync.c
+++ /dev/null
@@ -1,257 +0,0 @@
-/*
- * $Id: patest_sync.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * patest_sync.c
- * 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.
- *
- * 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
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-#include "pa_util.h"
-#define NUM_BEEPS (6)
-#define SAMPLE_RATE (44100)
-#define SAMPLE_PERIOD (1.0/44100.0)
-#define FRAMES_PER_BUFFER (256)
-#define BEEP_DURATION (400)
-#define LATENCY_MSEC (2000)
-#define SLEEP_MSEC (10)
-#define TIMEOUT_MSEC (15000)
-
-#define STATE_BKG_IDLE (0)
-#define STATE_BKG_PENDING (1)
-#define STATE_BKG_BEEPING (2)
-typedef struct
-{
- float left_phase;
- float right_phase;
- int state;
- int requestBeep; /* Set by foreground, cleared by background. */
- PaTime beepTime;
- int beepCount;
- double latency; /* For debugging. */
-}
-paTestData;
-
-static unsigned long GenerateRandomNumber( void );
-/************************************************************/
-/* Calculate pseudo-random 32 bit number based on linear congruential method. */
-static unsigned long GenerateRandomNumber( void )
-{
- static unsigned long randSeed = 99887766; /* Change this for different random sequences. */
- randSeed = (randSeed * 196314165) + 907633515;
- return randSeed;
-}
-
-/* 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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- const PaStreamCallbackTimeInfo *timeInfo,
- PaStreamCallbackFlags statusFlags, void *userData )
-{
- /* Cast data passed through stream to our structure. */
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned int i;
- (void) inputBuffer;
-
- data->latency = timeInfo->outputBufferDacTime - timeInfo->currentTime;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- switch( data->state )
- {
- case STATE_BKG_IDLE:
- /* Schedule beep at some random time in the future. */
- if( data->requestBeep )
- {
- int random = GenerateRandomNumber() >> 14;
- data->beepTime = timeInfo->outputBufferDacTime + (( (double)(random + SAMPLE_RATE)) * SAMPLE_PERIOD );
- data->state = STATE_BKG_PENDING;
- }
- *out++ = 0.0; /* left */
- *out++ = 0.0; /* right */
- break;
-
- case STATE_BKG_PENDING:
- if( (timeInfo->outputBufferDacTime + (i*SAMPLE_PERIOD)) >= data->beepTime )
- {
- data->state = STATE_BKG_BEEPING;
- data->beepCount = BEEP_DURATION;
- data->left_phase = data->right_phase = 0.0;
- }
- *out++ = 0.0; /* left */
- *out++ = 0.0; /* right */
- break;
-
- case STATE_BKG_BEEPING:
- if( data->beepCount <= 0 )
- {
- data->state = STATE_BKG_IDLE;
- data->requestBeep = 0;
- *out++ = 0.0; /* left */
- *out++ = 0.0; /* right */
- }
- else
- {
- /* Play sawtooth wave. */
- *out++ = data->left_phase; /* left */
- *out++ = data->right_phase; /* right */
- /* Generate simple sawtooth phaser that ranges between -1.0 and 1.0. */
- data->left_phase += 0.01f;
- /* When signal reaches top, drop back down. */
- if( data->left_phase >= 1.0f ) data->left_phase -= 2.0f;
- /* higher pitch so we can distinguish left and right. */
- data->right_phase += 0.03f;
- if( data->right_phase >= 1.0f ) data->right_phase -= 2.0f;
- }
- data->beepCount -= 1;
- break;
-
- default:
- data->state = STATE_BKG_IDLE;
- break;
- }
- }
- return 0;
-}
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaStream *stream;
- PaError err;
- paTestData DATA;
- int i, timeout;
- PaTime previousTime;
- PaStreamParameters outputParameters;
- printf("PortAudio Test: you should see BEEP at the same time you hear it.\n");
- printf("Wait for a few seconds random delay between BEEPs.\n");
- printf("BEEP %d times.\n", NUM_BEEPS );
- /* Initialize our DATA for use by callback. */
- DATA.left_phase = DATA.right_phase = 0.0;
- DATA.state = STATE_BKG_IDLE;
- DATA.requestBeep = 0;
- /* Initialize library before making any other calls. */
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- outputParameters.device = Pa_GetDefaultOutputDevice();
- outputParameters.channelCount = 2;
- outputParameters.hostApiSpecificStreamInfo = NULL;
- outputParameters.sampleFormat = paFloat32;
- 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_StartStream( stream );
- if( err != paNoError ) goto error;
-
- printf("started\n");
- fflush(stdout);
-
- previousTime = Pa_GetStreamTime( stream );
- for( i=0; i<NUM_BEEPS; i++ )
- {
- /* Request a beep from background. */
- DATA.requestBeep = 1;
-
- /* Wait for background to acknowledge request. */
- timeout = TIMEOUT_MSEC;
- while( (DATA.requestBeep == 1) && (timeout-- > 0 ) ) Pa_Sleep(SLEEP_MSEC);
- if( timeout <= 0 )
- {
- fprintf( stderr, "Timed out waiting for background to acknowledge request.\n" );
- goto error;
- }
- printf("calc beep for %9.3f, latency = %6.3f\n", DATA.beepTime, DATA.latency );
- fflush(stdout);
-
- /* Wait for scheduled beep time. */
- timeout = TIMEOUT_MSEC + (10000/SLEEP_MSEC);
- while( (Pa_GetStreamTime( stream ) < DATA.beepTime) && (timeout-- > 0 ) )
- {
- Pa_Sleep(SLEEP_MSEC);
- }
- if( timeout <= 0 )
- {
- fprintf( stderr, "Timed out waiting for time. Now = %9.3f, Beep for %9.3f.\n",
- PaUtil_GetTime(), DATA.beepTime );
- goto error;
- }
-
- /* Beep should be sounding now so print synchronized BEEP. */
- printf("hear \"BEEP\" at %9.3f, delta = %9.3f\n",
- Pa_GetStreamTime( stream ), (DATA.beepTime - previousTime) );
- fflush(stdout);
-
- previousTime = DATA.beepTime;
- }
-
- 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 occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_toomanysines.c b/pd/portaudio/pa_tests/patest_toomanysines.c
deleted file mode 100644
index 2fbb8433..00000000
--- a/pd/portaudio/pa_tests/patest_toomanysines.c
+++ /dev/null
@@ -1,172 +0,0 @@
-/*
- * $Id: patest_toomanysines.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $
- * Play more sine waves than we can handle in real time as a stress test,
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define MAX_SINES (500)
-#define MAX_LOAD (1.2)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (512)
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-#define TWOPI (M_PI * 2.0)
-
-typedef struct paTestData
-{
- int numSines;
- double phases[MAX_SINES];
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned long i;
- int j;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- float output = 0.0;
- double phaseInc = 0.02;
- double phase;
- for( j=0; j<data->numSines; j++ )
- {
- /* Advance phase of next oscillator. */
- phase = data->phases[j];
- phase += phaseInc;
- if( phase > TWOPI ) phase -= TWOPI;
-
- phaseInc *= 1.02;
- if( phaseInc > 0.5 ) phaseInc *= 0.5;
-
- /* This is not a very efficient way to calc sines. */
- output += (float) sin( phase );
- data->phases[j] = phase;
- }
-
-
- *out++ = (float) (output / data->numSines);
- }
- return finished;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- int numStress;
- paTestData data = {0};
- double load;
- printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d. MAX_LOAD = %f\n",
- SAMPLE_RATE, FRAMES_PER_BUFFER, MAX_LOAD );
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 1, /* mono output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER, /* frames per buffer */
- 0, /* number of buffers, if zero then use default minimum */
- 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;
-
- /* Determine number of sines required to get to 50% */
- do
- {
- data.numSines++;
- Pa_Sleep( 100 );
-
- load = Pa_GetCPULoad( stream );
- printf("numSines = %d, CPU load = %f\n", data.numSines, load );
- }
- while( load < 0.5 );
-
- /* Calculate target stress value then ramp up to that level*/
- numStress = (int) (2.0 * data.numSines * MAX_LOAD );
- for( ; data.numSines < numStress; data.numSines++ )
- {
- Pa_Sleep( 200 );
- load = Pa_GetCPULoad( 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;
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_underflow.c b/pd/portaudio/pa_tests/patest_underflow.c
deleted file mode 100644
index 3f02c5a4..00000000
--- a/pd/portaudio/pa_tests/patest_underflow.c
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * $Id: patest_underflow.c,v 1.1.1.1 2003-05-09 16:03:57 ggeiger Exp $
- * patest_underflow.c
- * Simulate an output buffer underflow condition.
- * Tests whether the stream can be stopped when underflowing buffers.
- *
- * Authors:
- * Ross Bencina <rossb@audiomulch.com>
- * Phil Burk <philburk@softsynth.com>
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.audiomulch.com/portaudio/
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define NUM_SECONDS (20)
-#define SAMPLE_RATE (44100)
-#define FRAMES_PER_BUFFER (2048)
-#define MSEC_PER_BUFFER ( (FRAMES_PER_BUFFER * 1000) / SAMPLE_RATE )
-
-#ifndef M_PI
-#define M_PI (3.14159265)
-#endif
-
-#define TABLE_SIZE (200)
-typedef struct
-{
- float sine[TABLE_SIZE];
- int left_phase;
- int right_phase;
- int sleepTime;
-}
-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 patestCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- paTestData *data = (paTestData*)userData;
- float *out = (float*)outputBuffer;
- unsigned long i;
- int finished = 0;
- (void) outTime; /* Prevent unused variable warnings. */
- (void) inputBuffer;
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out++ = data->sine[data->left_phase]; /* left */
- *out++ = data->sine[data->right_phase]; /* 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. */
- if( data->right_phase >= TABLE_SIZE ) data->right_phase -= TABLE_SIZE;
- }
-
- /* Cause underflow to occur. */
- if( data->sleepTime > 0 ) Pa_Sleep( data->sleepTime );
- data->sleepTime += 1;
-
- return finished;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PortAudioStream *stream;
- PaError err;
- 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 = data.sleepTime = 0;
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
- err = Pa_OpenStream(
- &stream,
- paNoDevice,/* default input device */
- 0, /* no input */
- paFloat32, /* 32 bit floating point input */
- NULL,
- Pa_GetDefaultOutputDeviceID(), /* default output device */
- 2, /* stereo output */
- paFloat32, /* 32 bit floating point output */
- NULL,
- SAMPLE_RATE,
- FRAMES_PER_BUFFER,
- 0, /* number of buffers, if zero then use default minimum */
- 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;
-
- while( data.sleepTime < (2 * MSEC_PER_BUFFER) )
- {
- printf("SleepTime = %d\n", data.sleepTime );
- Pa_Sleep( data.sleepTime );
- }
-
- printf("Try to stop stream.\n");
- err = Pa_StopStream( stream ); /* */
- err = Pa_AbortStream( 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 occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- return err;
-}
diff --git a/pd/portaudio/pa_tests/patest_wire.c b/pd/portaudio/pa_tests/patest_wire.c
deleted file mode 100644
index 51531395..00000000
--- a/pd/portaudio/pa_tests/patest_wire.c
+++ /dev/null
@@ -1,277 +0,0 @@
-/*
- * $Id: patest_wire.c,v 1.1.1.1 2003-05-09 16:03:57 ggeiger Exp $
- * patest_wire.c
- *
- * 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.
- *
- * Author: Phil Burk http://www.softsynth.com
- *
- * This program uses the PortAudio Portable Audio Library.
- * For more information see: http://www.portaudio.com
- * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
- *
- * Permission is hereby granted, free of charge, to any person obtaining
- * a copy of this software and associated documentation files
- * (the "Software"), to deal in the Software without restriction,
- * including without limitation the rights to use, copy, modify, merge,
- * publish, distribute, sublicense, and/or sell copies of the Software,
- * and to permit persons to whom the Software is furnished to do so,
- * subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be
- * included in all copies or substantial portions of the Software.
- *
- * 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.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
- * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
- * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
- * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
- *
- */
-#include <stdio.h>
-#include <math.h>
-#include "portaudio.h"
-
-#define SAMPLE_RATE (44100)
-
-typedef struct WireConfig_s
-{
- int isInputInterleaved;
- int isOutputInterleaved;
- int numInputChannels;
- int numOutputChannels;
- int framesPerCallback;
-} WireConfig_t;
-
-#define USE_FLOAT_INPUT (1)
-#define USE_FLOAT_OUTPUT (1)
-
-#define INPUT_LATENCY_MSEC (0)
-#define INPUT_LATENCY_FRAMES ((INPUT_LATENCY_MSEC * SAMPLE_RATE) / 1000)
-#define OUTPUT_LATENCY_MSEC (0)
-#define OUTPUT_LATENCY_FRAMES ((OUTPUT_LATENCY_MSEC * SAMPLE_RATE) / 1000)
-
-
-#if USE_FLOAT_INPUT
- #define INPUT_FORMAT paFloat32
- typedef float INPUT_SAMPLE;
-#else
- #define INPUT_FORMAT paInt16
- typedef short INPUT_SAMPLE;
-#endif
-
-#if USE_FLOAT_OUTPUT
- #define OUTPUT_FORMAT paFloat32
- typedef float OUTPUT_SAMPLE;
-#else
- #define OUTPUT_FORMAT paInt16
- typedef short OUTPUT_SAMPLE;
-#endif
-
-double gInOutScaler = 1.0;
-#define CONVERT_IN_TO_OUT(in) ((OUTPUT_SAMPLE) ((in) * gInOutScaler))
-
-#define INPUT_DEVICE (Pa_GetDefaultInputDevice())
-#define OUTPUT_DEVICE (Pa_GetDefaultOutputDevice())
-
-static PaError TestConfiguration( WireConfig_t *config );
-
-static int wireCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData );
-
-/* This routine will be called by the PortAudio engine when audio is needed.
-** It may be 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 wireCallback( void *inputBuffer, void *outputBuffer,
- unsigned long framesPerBuffer,
- PaTimestamp outTime, void *userData )
-{
- INPUT_SAMPLE *in;
- OUTPUT_SAMPLE *out;
- int inStride;
- int outStride;
-
- int inDone = 0;
- int outDone = 0;
- WireConfig_t *config = (WireConfig_t *) userData;
- unsigned int i;
- int inChannel, outChannel;
- (void) outTime;
-
- /* This may get called with NULL inputBuffer during initial setup. */
- if( inputBuffer == NULL) return 0;
-
- inChannel=0, outChannel=0;
- while( !(inDone && outDone) )
- {
- if( config->isInputInterleaved )
- {
- in = ((INPUT_SAMPLE*)inputBuffer) + inChannel;
- inStride = config->numInputChannels;
- }
- else
- {
- in = ((INPUT_SAMPLE**)inputBuffer)[inChannel];
- inStride = 1;
- }
-
- if( config->isOutputInterleaved )
- {
- out = ((OUTPUT_SAMPLE*)outputBuffer) + outChannel;
- outStride = config->numOutputChannels;
- }
- else
- {
- out = ((OUTPUT_SAMPLE**)outputBuffer)[outChannel];
- outStride = 1;
- }
-
- for( i=0; i<framesPerBuffer; i++ )
- {
- *out = CONVERT_IN_TO_OUT( *in );
- out += outStride;
- in += inStride;
- }
-
- if(inChannel < (config->numInputChannels - 1)) inChannel++;
- else inDone = 1;
- if(outChannel < (config->numOutputChannels - 1)) outChannel++;
- else outDone = 1;
- }
- return 0;
-}
-
-/*******************************************************************/
-int main(void);
-int main(void)
-{
- PaError err;
- WireConfig_t CONFIG;
- WireConfig_t *config = &CONFIG;
- int configIndex = 0;;
-
- err = Pa_Initialize();
- if( err != paNoError ) goto error;
-
- printf("Please connect audio signal to input and listen for it on output!\n");
- printf("input format = %d\n", INPUT_FORMAT );
- printf("output format = %d\n", OUTPUT_FORMAT );
- printf("input device ID = %d\n", INPUT_DEVICE );
- printf("output device ID = %d\n", OUTPUT_DEVICE );
-
- if( INPUT_FORMAT == OUTPUT_FORMAT )
- {
- gInOutScaler = 1.0;
- }
- else if( (INPUT_FORMAT == paInt16) && (OUTPUT_FORMAT == paFloat32) )
- {
- gInOutScaler = 1.0/32768.0;
- }
- else if( (INPUT_FORMAT == paFloat32) && (OUTPUT_FORMAT == paInt16) )
- {
- gInOutScaler = 32768.0;
- }
-
- for( config->isInputInterleaved = 0; config->isInputInterleaved < 2; config->isInputInterleaved++ )
- {
- for( config->isOutputInterleaved = 0; config->isOutputInterleaved < 2; config->isOutputInterleaved++ )
- {
- for( config->numInputChannels = 1; config->numInputChannels < 3; config->numInputChannels++ )
- {
- for( config->numOutputChannels = 1; config->numOutputChannels < 3; config->numOutputChannels++ )
- {
- for( config->framesPerCallback = 0; config->framesPerCallback < 65; config->framesPerCallback += 64 )
- {
- printf("-----------------------------------------------\n" );
- printf("Configuration #%d\n", configIndex++ );
- err = TestConfiguration( config );
- // give user a chance to bail out
- if( err == 1 )
- {
- err = paNoError;
- goto done;
- }
- else if( err != paNoError ) goto error;
- }
- }
- }
- }
- }
-
-done:
- Pa_Terminate();
-
- printf("Full duplex sound test complete.\n"); fflush(stdout);
-
- printf("Hit ENTER to quit.\n"); fflush(stdout);
- getchar();
-
- return 0;
-
-error:
- Pa_Terminate();
- fprintf( stderr, "An error occured while using the portaudio stream\n" );
- fprintf( stderr, "Error number: %d\n", err );
- fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
- printf("Hit ENTER to quit.\n"); fflush(stdout);
- getchar();
- return -1;
-}
-
-static PaError TestConfiguration( WireConfig_t *config )
-{
- int c;
- PaError err;
- PaStream *stream;
- printf("input %sinterleaved!\n", (config->isInputInterleaved ? " " : "NOT ") );
- printf("output %sinterleaved!\n", (config->isOutputInterleaved ? " " : "NOT ") );
- printf("input channels = %d\n", config->numInputChannels );
- printf("output channels = %d\n", config->numOutputChannels );
- printf("framesPerCallback = %d\n", config->framesPerCallback );
-
- err = Pa_OpenStream(
- &stream,
- INPUT_DEVICE,
- config->numInputChannels,
- INPUT_FORMAT | (config->isInputInterleaved ? 0 : paNonInterleaved),
- INPUT_LATENCY_FRAMES, /* input latency */
- NULL,
- OUTPUT_DEVICE,
- config->numOutputChannels,
- OUTPUT_FORMAT | (config->isOutputInterleaved ? 0 : paNonInterleaved),
- OUTPUT_LATENCY_FRAMES, /* output latency */
- NULL,
- SAMPLE_RATE,
- config->framesPerCallback, /* frames per buffer */
- paClipOff, /* we won't output out of range samples so don't bother clipping them */
- wireCallback,
- config ); /* user data */
- if( err != paNoError ) goto error;
-
- err = Pa_StartStream( stream );
- if( err != paNoError ) goto error;
-
- printf("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;
-
- if( c == 'q' ) return 1;
-
-error:
- return err;
-}