52 #define SAMPLE_RATE (44100)
53 #define PA_SAMPLE_TYPE paFloat32
54 #define FRAMES_PER_BUFFER (64)
58 float CubicAmplifier(
float input );
59 static int fuzzCallback(
const void *inputBuffer,
void *outputBuffer,
60 unsigned long framesPerBuffer,
66 float CubicAmplifier(
float input )
72 output = (temp * temp * temp) - 1.0f;
77 output = (temp * temp * temp) + 1.0f;
82 #define FUZZ(x) CubicAmplifier(CubicAmplifier(CubicAmplifier(CubicAmplifier(x))))
84 static int gNumNoInputs = 0;
89 static int fuzzCallback(
const void *inputBuffer,
void *outputBuffer,
90 unsigned long framesPerBuffer,
95 SAMPLE *out = (SAMPLE*)outputBuffer;
96 const SAMPLE *in = (
const SAMPLE*)inputBuffer;
102 if( inputBuffer == NULL )
104 for( i=0; i<framesPerBuffer; i++ )
113 for( i=0; i<framesPerBuffer; i++ )
115 *out++ = FUZZ(*in++);
132 if( err != paNoError )
goto error;
136 fprintf(stderr,
"Error: No default input device.\n");
146 fprintf(stderr,
"Error: No default output device.\n");
163 if( err != paNoError )
goto error;
166 if( err != paNoError )
goto error;
168 printf(
"Hit ENTER to stop program.\n");
171 if( err != paNoError )
goto error;
173 printf(
"Finished. gNumNoInputs = %d\n", gNumNoInputs );
179 fprintf( stderr,
"An error occured while using the portaudio stream\n" );
180 fprintf( stderr,
"Error number: %d\n", err );
PaError Pa_Initialize(void)
PaDeviceIndex Pa_GetDefaultInputDevice(void)
PaError Pa_OpenStream(PaStream **stream, const PaStreamParameters *inputParameters, const PaStreamParameters *outputParameters, double sampleRate, unsigned long framesPerBuffer, PaStreamFlags streamFlags, PaStreamCallback *streamCallback, void *userData)
PaTime defaultLowInputLatency
PaError Pa_StartStream(PaStream *stream)
void * hostApiSpecificStreamInfo
The portable PortAudio API.
PaSampleFormat sampleFormat
unsigned long PaStreamCallbackFlags
const PaDeviceInfo * Pa_GetDeviceInfo(PaDeviceIndex device)
PaDeviceIndex Pa_GetDefaultOutputDevice(void)
const char * Pa_GetErrorText(PaError errorCode)
PaError Pa_CloseStream(PaStream *stream)
PaError Pa_Terminate(void)