55 #define SAMPLE_RATE (44100)
56 #define PA_SAMPLE_TYPE paFloat32
57 #define FRAMES_PER_BUFFER (64)
61 float CubicAmplifier(
float input );
62 static int fuzzCallback(
const void *inputBuffer,
void *outputBuffer,
63 unsigned long framesPerBuffer,
69 float CubicAmplifier(
float input )
75 output = (temp * temp * temp) - 1.0f;
80 output = (temp * temp * temp) + 1.0f;
85 #define FUZZ(x) CubicAmplifier(CubicAmplifier(CubicAmplifier(CubicAmplifier(x))))
87 static int gNumNoInputs = 0;
92 static int fuzzCallback(
const void *inputBuffer,
void *outputBuffer,
93 unsigned long framesPerBuffer,
98 SAMPLE *out = (SAMPLE*)outputBuffer;
99 const SAMPLE *in = (
const SAMPLE*)inputBuffer;
105 if( inputBuffer == NULL )
107 for( i=0; i<framesPerBuffer; i++ )
116 for( i=0; i<framesPerBuffer; i++ )
118 SAMPLE sample = *in++;
119 *out++ = FUZZ(sample);
136 if( err != paNoError )
goto error;
140 fprintf(stderr,
"Error: No default input device.\n");
150 fprintf(stderr,
"Error: No default output device.\n");
167 if( err != paNoError )
goto error;
170 if( err != paNoError )
goto error;
172 printf(
"Hit ENTER to stop program.\n");
175 if( err != paNoError )
goto error;
177 printf(
"Finished. gNumNoInputs = %d\n", gNumNoInputs );
183 fprintf( stderr,
"An error occurred while using the portaudio stream\n" );
184 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)