47 #define NUM_SECONDS (4)
48 #define SAMPLE_RATE (44100)
61 static int patestCallback(
const void *inputBuffer,
void *outputBuffer,
62 unsigned long framesPerBuffer,
69 float *out = (
float*)outputBuffer;
73 for( i=0; i<framesPerBuffer; i++ )
75 *out++ = data->left_phase;
76 *out++ = data->right_phase;
78 data->left_phase += 0.01f;
80 if( data->left_phase >= 1.0f ) data->left_phase -= 2.0f;
82 data->right_phase += 0.03f;
83 if( data->right_phase >= 1.0f ) data->right_phase -= 2.0f;
96 printf(
"PortAudio Test: output sawtooth wave.\n");
98 data.left_phase = data.right_phase = 0.0;
101 if( err != paNoError )
goto error;
112 if( err != paNoError )
goto error;
115 if( err != paNoError )
goto error;
121 if( err != paNoError )
goto error;
123 if( err != paNoError )
goto error;
125 printf(
"Test finished.\n");
129 fprintf( stderr,
"An error occured while using the portaudio stream\n" );
130 fprintf( stderr,
"Error number: %d\n", err );
PaError Pa_Initialize(void)
PaError Pa_StopStream(PaStream *stream)
PaError Pa_StartStream(PaStream *stream)
The portable PortAudio API.
unsigned long PaStreamCallbackFlags
PaError Pa_OpenDefaultStream(PaStream **stream, int numInputChannels, int numOutputChannels, PaSampleFormat sampleFormat, double sampleRate, unsigned long framesPerBuffer, PaStreamCallback *streamCallback, void *userData)
const char * Pa_GetErrorText(PaError errorCode)
PaError Pa_CloseStream(PaStream *stream)
PaError Pa_Terminate(void)