aboutsummaryrefslogtreecommitdiff
path: root/pd/portaudio/pa_tests/patest_ringmix.c
diff options
context:
space:
mode:
authorGuenter Geiger <ggeiger@users.sourceforge.net>2003-05-09 16:04:00 +0000
committerGuenter Geiger <ggeiger@users.sourceforge.net>2003-05-09 16:04:00 +0000
commit9c0e19a3be2288db79e2502e5fa450c3e20a668d (patch)
treeca97ce615e037a533304fc4660dcf372ca3b9cd6 /pd/portaudio/pa_tests/patest_ringmix.c
parentef50dd62804d54af7da18d8bd8413c0dccd729b8 (diff)
This commit was generated by cvs2svn to compensate for changes in r610,
which included commits to RCS files with non-trunk default branches. svn path=/trunk/; revision=611
Diffstat (limited to 'pd/portaudio/pa_tests/patest_ringmix.c')
-rw-r--r--pd/portaudio/pa_tests/patest_ringmix.c41
1 files changed, 41 insertions, 0 deletions
diff --git a/pd/portaudio/pa_tests/patest_ringmix.c b/pd/portaudio/pa_tests/patest_ringmix.c
new file mode 100644
index 00000000..34c66381
--- /dev/null
+++ b/pd/portaudio/pa_tests/patest_ringmix.c
@@ -0,0 +1,41 @@
+/* $Id: patest_ringmix.c,v 1.1.1.1 2003-05-09 16:03:56 ggeiger Exp $ */
+
+#include "stdio.h"
+#include "portaudio.h"
+/* This will be called asynchronously by the PortAudio engine. */
+static int myCallback( void *inputBuffer, void *outputBuffer,
+ unsigned long framesPerBuffer, PaTimestamp outTime, void *userData )
+{
+ float *out = (float *) outputBuffer;
+ float *in = (float *) inputBuffer;
+ float leftInput, rightInput;
+ unsigned int i;
+ if( inputBuffer == NULL ) return 0;
+ /* Read input buffer, process data, and fill output buffer. */
+ for( i=0; i<framesPerBuffer; i++ )
+ {
+ leftInput = *in++; /* Get interleaved samples from input buffer. */
+ rightInput = *in++;
+ *out++ = leftInput * rightInput; /* ring modulation */
+ *out++ = 0.5f * (leftInput + rightInput); /* mix */
+ }
+ return 0;
+}
+/* Open a PortAudioStream to input and output audio data. */
+int main(void)
+{
+ PortAudioStream *stream;
+ Pa_Initialize();
+ Pa_OpenDefaultStream(
+ &stream,
+ 2, 2, /* stereo input and output */
+ paFloat32, 44100.0,
+ 64, 0, /* 64 frames per buffer, let PA determine numBuffers */
+ myCallback, NULL );
+ Pa_StartStream( stream );
+ Pa_Sleep( 10000 ); /* Sleep for 10 seconds while processing. */
+ Pa_StopStream( stream );
+ Pa_CloseStream( stream );
+ Pa_Terminate();
+ return 0;
+}