*/\r
#include <stdio.h>\r
#include <stdlib.h>\r
+#include <string.h>\r
#include <math.h>\r
#include "portaudio.h"\r
\r
#define SAMPLE_RATE (44100)\r
-#define FRAMES_PER_BUFFER (128)\r
+#define FRAMES_PER_BUFFER 2//(128)\r
#define NUM_CHANNELS (2)\r
\r
#define SUGGESTED_LATENCY_START_SECONDS (0.0)\r
PaStreamCallbackFlags statusFlags,\r
void *userData )\r
{\r
+ return paContinue;\r
}\r
\r
/*******************************************************************/\r
int main( int argc, const char* argv[] );\r
int main( int argc, const char* argv[] )\r
{\r
- PaStreamParameters outputParameters, inputParameters;\r
+ PaStreamParameters inputParameters, outputParameters;\r
PaStream *stream;\r
PaError err;\r
PaTime suggestedLatency;\r
- PaStreamInfo *streamInfo;\r
- PaDeviceInfo *deviceInfo;\r
+ const PaStreamInfo *streamInfo;\r
+ const PaDeviceInfo *deviceInfo;\r
float sampleRate = SAMPLE_RATE;\r
int framesPerBuffer = FRAMES_PER_BUFFER;\r
err = Pa_Initialize();\r
\r
printf("# sample rate=%f, frames per buffer=%d\n", (float)sampleRate, framesPerBuffer );\r
\r
- outputParameters.device = -1;\r
- if( argc > 1 )\r
- outputParameters.device = atoi(argv[1]);\r
- if( outputParameters.device == -1 ){\r
- outputParameters.device = Pa_GetDefaultOutputDevice();\r
- if (outputParameters.device == paNoDevice) {\r
- fprintf(stderr,"Error: No default output device available.\n");\r
- goto error;\r
- }\r
- }else{\r
- deviceInfo = Pa_GetDeviceInfo(outputParameters.device);\r
- if( !deviceInfo ){\r
- fprintf(stderr,"Error: Invalid output device index.\n");\r
- usage();\r
- }\r
- if( deviceInfo->maxOutputChannels == 0 ){\r
- fprintf(stderr,"Error: Specified output device has no output channels (an input only device?).\n");\r
- usage();\r
- }\r
- }\r
- \r
- outputParameters.channelCount = NUM_CHANNELS;\r
- outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */\r
- outputParameters.hostApiSpecificStreamInfo = NULL;\r
-\r
- deviceInfo = Pa_GetDeviceInfo(outputParameters.device);\r
- printf( "# using output device id %d (%s, %s)\n", outputParameters.device, deviceInfo->name, Pa_GetHostApiInfo(deviceInfo->hostApi)->name );\r
-\r
-\r
inputParameters.device = -1;\r
- if( argc > 2 )\r
+ if( argc > 1 )\r
inputParameters.device = atoi(argv[1]);\r
if( inputParameters.device == -1 ){\r
inputParameters.device = Pa_GetDefaultInputDevice();\r
usage();\r
}\r
}\r
-\r
\r
inputParameters.channelCount = NUM_CHANNELS;\r
inputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */\r
printf( "# using input device id %d (%s, %s)\n", inputParameters.device, deviceInfo->name, Pa_GetHostApiInfo(deviceInfo->hostApi)->name );\r
\r
\r
- printf( "# suggested latency, half duplex PaStreamInfo::outputLatency, half duplex PaStreamInfo::inputLatency, half duplex PaStreamInfo::outputLatency, half duplex PaStreamInfo::inputLatency\n" );\r
+ outputParameters.device = -1;\r
+ if( argc > 2 )\r
+ outputParameters.device = atoi(argv[2]);\r
+ if( outputParameters.device == -1 ){\r
+ outputParameters.device = Pa_GetDefaultOutputDevice();\r
+ if (outputParameters.device == paNoDevice) {\r
+ fprintf(stderr,"Error: No default output device available.\n");\r
+ goto error;\r
+ }\r
+ }else{\r
+ deviceInfo = Pa_GetDeviceInfo(outputParameters.device);\r
+ if( !deviceInfo ){\r
+ fprintf(stderr,"Error: Invalid output device index.\n");\r
+ usage();\r
+ }\r
+ if( deviceInfo->maxOutputChannels == 0 ){\r
+ fprintf(stderr,"Error: Specified output device has no output channels (an input only device?).\n");\r
+ usage();\r
+ }\r
+ }\r
+\r
+ outputParameters.channelCount = NUM_CHANNELS;\r
+ outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */\r
+ outputParameters.hostApiSpecificStreamInfo = NULL;\r
+\r
+ deviceInfo = Pa_GetDeviceInfo(outputParameters.device);\r
+ printf( "# using output device id %d (%s, %s)\n", outputParameters.device, deviceInfo->name, Pa_GetHostApiInfo(deviceInfo->hostApi)->name );\r
+\r
+\r
+ printf( "# suggested latency, half duplex PaStreamInfo::outputLatency, half duplex PaStreamInfo::inputLatency, full duplex PaStreamInfo::outputLatency, full duplex PaStreamInfo::inputLatency\n" );\r
suggestedLatency = SUGGESTED_LATENCY_START_SECONDS;\r
while( suggestedLatency <= SUGGESTED_LATENCY_END_SECONDS ){\r
\r