54 #define NUM_SECONDS (10)
55 #define SAMPLE_RATE (44100)
56 #define AMPLITUDE (0.8)
57 #define FRAMES_PER_BUFFER (64)
58 #define OUTPUT_DEVICE Pa_GetDefaultOutputDevice()
61 #define M_PI (3.14159265)
64 #define TABLE_SIZE (200)
67 float sine[TABLE_SIZE];
76 static int patestCallback(
const void *inputBuffer,
void *outputBuffer,
77 unsigned long framesPerBuffer,
83 float *out = (
float*)outputBuffer;
90 for( i=0; i<framesPerBuffer; i++ )
92 *out++ = data->sine[data->phase];
94 if( data->phase >= TABLE_SIZE ) data->phase -= TABLE_SIZE;
108 int outputChannelSelectors[1];
110 printf(
"PortAudio Test: output MONO sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
112 for( i=0; i<TABLE_SIZE; i++ )
114 data.sine[i] = (float) (AMPLITUDE * sin( ((
double)i/(
double)TABLE_SIZE) * M_PI * 2. ));
119 if( err != paNoError )
goto error;
121 outputParameters.
device = OUTPUT_DEVICE;
130 asioOutputInfo.flags = paAsioUseChannelSelectors;
131 outputChannelSelectors[0] = 1;
132 asioOutputInfo.channelSelectors = outputChannelSelectors;
144 if( err != paNoError )
goto error;
147 if( err != paNoError )
goto error;
149 printf(
"Play for %d seconds.\n", NUM_SECONDS ); fflush(stdout);
153 if( err != paNoError )
goto error;
156 if( err != paNoError )
goto error;
159 printf(
"Test finished.\n");
163 fprintf( stderr,
"An error occured while using the portaudio stream\n" );
164 fprintf( stderr,
"Error number: %d\n", err );
PaError Pa_Initialize(void)
PaError Pa_StopStream(PaStream *stream)
ASIO-specific PortAudio API extension header file.
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
PaError Pa_StartStream(PaStream *stream)
void * hostApiSpecificStreamInfo
The portable PortAudio API.
PaSampleFormat sampleFormat
unsigned long PaStreamCallbackFlags
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
PaHostApiTypeId hostApiType
const char * Pa_GetErrorText(PaError errorCode)
PaError Pa_CloseStream(PaStream *stream)
PaError Pa_Terminate(void)