1
/** @file patest_ringmix.c
3
@brief Ring modulate inputs to left output, mix inputs to right output.
6
* $Id: patest_ringmix.c,v 1.2 2006/09/23 18:42:52 llucius Exp $
8
* This program uses the PortAudio Portable Audio Library.
9
* For more information see: http://www.portaudio.com
10
* Copyright (c) 1999-2000 Ross Bencina and Phil Burk
12
* Permission is hereby granted, free of charge, to any person obtaining
13
* a copy of this software and associated documentation files
14
* (the "Software"), to deal in the Software without restriction,
15
* including without limitation the rights to use, copy, modify, merge,
16
* publish, distribute, sublicense, and/or sell copies of the Software,
17
* and to permit persons to whom the Software is furnished to do so,
18
* subject to the following conditions:
20
* The above copyright notice and this permission notice shall be
21
* included in all copies or substantial portions of the Software.
23
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
24
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
25
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
26
* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
27
* ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
28
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
29
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
33
* The text above constitutes the entire PortAudio license; however,
34
* the PortAudio community also makes the following non-binding requests:
36
* Any person wishing to distribute modifications to the Software is
37
* requested to send the modifications to the original developer so that
38
* they can be incorporated into the canonical version. It is also
39
* requested that these non-binding requests be included along with the
45
#include "portaudio.h"
46
/* This will be called asynchronously by the PortAudio engine. */
47
static int myCallback( const void *inputBuffer, void *outputBuffer,
48
unsigned long framesPerBuffer,
49
const PaStreamCallbackTimeInfo* timeInfo,
50
PaStreamCallbackFlags statusFlags,
53
const float *in = (const float *) inputBuffer;
54
float *out = (float *) outputBuffer;
55
float leftInput, rightInput;
58
/* Read input buffer, process data, and fill output buffer. */
59
for( i=0; i<framesPerBuffer; i++ )
61
leftInput = *in++; /* Get interleaved samples from input buffer. */
63
*out++ = leftInput * rightInput; /* ring modulation */
64
*out++ = 0.5f * (leftInput + rightInput); /* mix */
69
/* Open a PortAudioStream to input and output audio data. */
76
2, 2, /* stereo input and output */
78
64, /* 64 frames per buffer */
80
Pa_StartStream( stream );
81
Pa_Sleep( 10000 ); /* Sleep for 10 seconds while processing. */
82
Pa_StopStream( stream );
83
Pa_CloseStream( stream );