From be2eb99b37cd017fcab00c1704f794cb1bc85ee1 Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Fri, 11 Oct 2013 01:58:40 +0200 Subject: Release 4.0.7 tarball --- doc/html/duplex.html | 46 ++++++++++++++++++++++++---------------------- 1 file changed, 24 insertions(+), 22 deletions(-) (limited to 'doc/html/duplex.html') diff --git a/doc/html/duplex.html b/doc/html/duplex.html index 7bfdb64..6e85d69 100644 --- a/doc/html/duplex.html +++ b/doc/html/duplex.html @@ -8,21 +8,23 @@
Home   Class/Enum List   File List   Compound Members  

- +
-

Duplex Mode

Finally, it is easy to use RtAudio for simultaneous audio input/output, or duplex operation. In this example, we simply pass the input data back to the output.

-

#include "RtAudio.h"
+
+
+

Duplex Mode

Finally, it is easy to use RtAudio for simultaneous audio input/output, or duplex operation. In this example, we simply pass the input data back to the output.

+
#include "RtAudio.h"
 #include <iostream>
 #include <cstdlib>
 #include <cstring>
 
 // Pass-through function.
 int inout( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
-           double streamTime, RtAudioStreamStatus status, void *data )
+           double streamTime, RtAudioStreamStatus status, void *data )
 {
   // Since the number of input and output channels is equal, we can do
   // a simple buffer copy operation here.
-  if ( status ) std::cout << "Stream over/underflow detected." << std::endl;
+  if ( status ) std::cout << "Stream over/underflow detected." << std::endl;
 
   unsigned long *bytes = (unsigned long *) data;
   memcpy( outputBuffer, inputBuffer, *bytes );
@@ -32,56 +34,56 @@
 int main()
 {
  RtAudio adac;
-  if ( adac.getDeviceCount() < 1 ) {
-    std::cout << "\nNo audio devices found!\n";
+  if ( adac.getDeviceCount() < 1 ) {
+    std::cout << "\nNo audio devices found!\n";
     exit( 0 );
   }
 
   // Set the same number of channels for both input and output.
   unsigned int bufferBytes, bufferFrames = 512;
   RtAudio::StreamParameters iParams, oParams;
-  iParams.deviceId = 0; // first available device
-  iParams.nChannels = 2;
-  oParams.deviceId = 0; // first available device
-  oParams.nChannels = 2;
+  iParams.deviceId = 0; // first available device
+  iParams.nChannels = 2;
+  oParams.deviceId = 0; // first available device
+  oParams.nChannels = 2;
 
   try {
-    adac.openStream( &oParams, &iParams, RTAUDIO_SINT32, 44100, &bufferFrames, &inout, (void *)&bufferBytes );
+    adac.openStream( &oParams, &iParams, RTAUDIO_SINT32, 44100, &bufferFrames, &inout, (void *)&bufferBytes );
   }
   catch ( RtError& e ) {
-    e.printMessage();
+    e.printMessage();
     exit( 0 );
   }
 
   bufferBytes = bufferFrames * 2 * 4;
 
   try {
-    adac.startStream();
+    adac.startStream();
 
     char input;
-    std::cout << "\nRunning ... press <enter> to quit.\n";
+    std::cout << "\nRunning ... press <enter> to quit.\n";
     std::cin.get(input);
 
     // Stop the stream.
-    adac.stopStream();
+    adac.stopStream();
   }
   catch ( RtError& e ) {
-    e.printMessage();
+    e.printMessage();
     goto cleanup;
   }
 
  cleanup:
-  if ( adac.isStreamOpen() ) adac.closeStream();
+  if ( adac.isStreamOpen() ) adac.closeStream();
 
   return 0;
 }
-

-In this example, audio recorded by the stream input will be played out during the next round of audio processing.

-Note that a duplex stream can make use of two different devices (except when using the Linux Jack and Windows ASIO APIs). However, this may cause timing problems due to possible device clock variations, unless a common external "sync" is provided.

+

In this example, audio recorded by the stream input will be played out during the next round of audio processing.

+

Note that a duplex stream can make use of two different devices (except when using the Linux Jack and Windows ASIO APIs). However, this may cause timing problems due to possible device clock variations, unless a common external "sync" is provided.

+
- +
©2001-2009 Gary P. Scavone, McGill University. All Rights Reserved.
Maintained by Gary P. Scavone.
©2001-2010 Gary P. Scavone, McGill University. All Rights Reserved.
Maintained by Gary P. Scavone.
-- cgit v1.2.3