--- /dev/null
+//==========================================================================\r
+// Name: thread_audio.cpp\r
+//\r
+// Purpose: Implements simple wxWidgets application with GUI.\r
+// Created: May 11, 2012
+// Initial author: David Witten\r
+// License: BSD License (other licenses may apply to other\r
+// components of this project)\r
+//==========================================================================\r
+#include "thread_audio.h"\r
+\r
+// declare a new type of event, to be used by our MyThread class:\r
+wxDECLARE_EVENT(wxEVT_COMMAND_AUDIOTHREAD_COMPLETED, wxThreadEvent);\r
+wxDECLARE_EVENT(wxEVT_COMMAND_AUDIOTHREAD_UPDATE, wxThreadEvent);\r
+\r
+#include "stdio.h"\r
+#include "portaudio.h"\r
+\r
+/* This will be called asynchronously by the PortAudio engine. */\r
+static int audioCallback( void *inputBuffer, void *outputBuffer,\r
+\r
+unsigned long framesPerBuffer, PaTimestamp outTime, void *userData )\r
+{\r
+ float *out = (float *) outputBuffer;\r
+ float *in = (float *) inputBuffer;\r
+ float leftInput, rightInput;\r
+ unsigned int i;\r
+\r
+ if( inputBuffer == NULL )\r
+ {\r
+ return 0;\r
+ }\r
+ /* Read input buffer, process data, and fill output buffer. */\r
+ for(i = 0; i < framesPerBuffer; i++)\r
+ {\r
+ leftInput = *in++; /* Get interleaved samples from input buffer. */\r
+ rightInput = *in++;\r
+ *out++ = leftInput * rightInput; /* ring modulation */\r
+ *out++ = 0.5f * (leftInput + rightInput); /* mixing */\r
+ }\r
+ return 0;\r
+}\r
+/* Use a PortAudioStream to process audio data. */\r
+int main(void)\r
+{\r
+ PortAudioStream *stream;\r
+ Pa_Initialize();\r
+ //Pa_OpenDefaultStream(&stream, 2, 2, /* stereo input and output */ paFloat32, 44100.0, 64, 0, /* 64 frames per buffer, let PA determine numBuffers */audioCallback, NULL );\r
+ Pa_OpenDefaultStream(&stream, 2, 2, paFloat32, 44100.0, 64, 0, audioCallback, NULL );\r
+ Pa_StartStream( stream );\r
+ Pa_Sleep( 10000 ); /* Sleep for 10 seconds while processing. */\r
+ Pa_StopStream( stream );\r
+ Pa_CloseStream( stream );\r
+ Pa_Terminate();\r
+ return 0;\r
+}\r