/* This routine will be called by the PortAudio engine when audio is needed. ** It may be called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). */ static int fuzzCallback( const void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, const PaStreamCallbackTimeInfo* timeInfo, PaStreamCallbackFlags statusFlags, void *userData ) { SAMPLE *out = (SAMPLE*)outputBuffer; const SAMPLE *in = (const SAMPLE*)inputBuffer; unsigned int i; (void) timeInfo; /* Prevent unused variable warnings. */ (void) statusFlags; (void) userData; if( inputBuffer == NULL ) { for( i=0; i<framesPerBuffer; i++ ) { *out++ = 0; /* left - silent */ *out++ = 0; /* right - silent */ } gNumNoInputs += 1; } else { for( i=0; i<framesPerBuffer; i++ ) { *out++ = FUZZ(*in++); /* left - distorted */ *out++ = *in++; /* right - clean */ } } return paContinue; }
/* This routine will be called by the PortAudio engine when audio is needed. ** It may be called at interrupt level on some machines so don't do anything ** that could mess up the system like calling malloc() or free(). */ static int fuzzCallback( void *inputBuffer, void *outputBuffer, unsigned long framesPerBuffer, PaTimestamp outTime, void *userData ) { SAMPLE *out = (SAMPLE*)outputBuffer; SAMPLE *in = (SAMPLE*)inputBuffer; unsigned int i; (void) outTime; /* Prevent unused variable warnings. */ (void) userData; if( inputBuffer == NULL ) { for( i=0; i<framesPerBuffer; i++ ) { *out++ = 0; /* left - silent */ *out++ = 0; /* right - silent */ } gNumNoInputs += 1; } else { for( i=0; i<framesPerBuffer; i++ ) { *out++ = FUZZ(*in++); /* left - distorted */ *out++ = *in++; /* right - clean */ } } return 0; }
/* * Fuzz distortion * args: * audio_ctx - audio context * data - audio buffer to be processed * * asserts: * audio_ctx is not null * * returns: none */ static void audio_fx_fuzz (audio_context_t *audio_ctx, sample_t *data) { /*assertions*/ assert(audio_ctx != NULL); int samp=0; for(samp = 0; samp < audio_ctx->capture_buff_size; samp++) data[samp] = FUZZ(data[samp]); HPF(audio_ctx, data, 1000, 0.9); }