annotate src/portaudio_20161030_catalina_patch/test/patest_ringmix.c @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents d43aab368df9
children
rev   line source
cannam@162 1 /** @file patest_ringmix.c
cannam@162 2 @ingroup test_src
cannam@162 3 @brief Ring modulate inputs to left output, mix inputs to right output.
cannam@162 4 */
cannam@162 5 /*
cannam@162 6 * $Id$
cannam@162 7 *
cannam@162 8 * This program uses the PortAudio Portable Audio Library.
cannam@162 9 * For more information see: http://www.portaudio.com
cannam@162 10 * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
cannam@162 11 *
cannam@162 12 * Permission is hereby granted, free of charge, to any person obtaining
cannam@162 13 * a copy of this software and associated documentation files
cannam@162 14 * (the "Software"), to deal in the Software without restriction,
cannam@162 15 * including without limitation the rights to use, copy, modify, merge,
cannam@162 16 * publish, distribute, sublicense, and/or sell copies of the Software,
cannam@162 17 * and to permit persons to whom the Software is furnished to do so,
cannam@162 18 * subject to the following conditions:
cannam@162 19 *
cannam@162 20 * The above copyright notice and this permission notice shall be
cannam@162 21 * included in all copies or substantial portions of the Software.
cannam@162 22 *
cannam@162 23 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
cannam@162 24 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
cannam@162 25 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
cannam@162 26 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
cannam@162 27 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
cannam@162 28 * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
cannam@162 29 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
cannam@162 30 */
cannam@162 31
cannam@162 32 /*
cannam@162 33 * The text above constitutes the entire PortAudio license; however,
cannam@162 34 * the PortAudio community also makes the following non-binding requests:
cannam@162 35 *
cannam@162 36 * Any person wishing to distribute modifications to the Software is
cannam@162 37 * requested to send the modifications to the original developer so that
cannam@162 38 * they can be incorporated into the canonical version. It is also
cannam@162 39 * requested that these non-binding requests be included along with the
cannam@162 40 * license above.
cannam@162 41 */
cannam@162 42
cannam@162 43
cannam@162 44 #include "stdio.h"
cannam@162 45 #include "portaudio.h"
cannam@162 46 /* This will be called asynchronously by the PortAudio engine. */
cannam@162 47 static int myCallback( const void *inputBuffer, void *outputBuffer,
cannam@162 48 unsigned long framesPerBuffer,
cannam@162 49 const PaStreamCallbackTimeInfo* timeInfo,
cannam@162 50 PaStreamCallbackFlags statusFlags,
cannam@162 51 void *userData )
cannam@162 52 {
cannam@162 53 const float *in = (const float *) inputBuffer;
cannam@162 54 float *out = (float *) outputBuffer;
cannam@162 55 float leftInput, rightInput;
cannam@162 56 unsigned int i;
cannam@162 57
cannam@162 58 /* Read input buffer, process data, and fill output buffer. */
cannam@162 59 for( i=0; i<framesPerBuffer; i++ )
cannam@162 60 {
cannam@162 61 leftInput = *in++; /* Get interleaved samples from input buffer. */
cannam@162 62 rightInput = *in++;
cannam@162 63 *out++ = leftInput * rightInput; /* ring modulation */
cannam@162 64 *out++ = 0.5f * (leftInput + rightInput); /* mix */
cannam@162 65 }
cannam@162 66 return 0;
cannam@162 67 }
cannam@162 68
cannam@162 69 /* Open a PortAudioStream to input and output audio data. */
cannam@162 70 int main(void)
cannam@162 71 {
cannam@162 72 PaStream *stream;
cannam@162 73 Pa_Initialize();
cannam@162 74 Pa_OpenDefaultStream(
cannam@162 75 &stream,
cannam@162 76 2, 2, /* stereo input and output */
cannam@162 77 paFloat32, 44100.0,
cannam@162 78 64, /* 64 frames per buffer */
cannam@162 79 myCallback, NULL );
cannam@162 80 Pa_StartStream( stream );
cannam@162 81 Pa_Sleep( 10000 ); /* Sleep for 10 seconds while processing. */
cannam@162 82 Pa_StopStream( stream );
cannam@162 83 Pa_CloseStream( stream );
cannam@162 84 Pa_Terminate();
cannam@162 85 return 0;
cannam@162 86 }