From 2ea2d92e3b4e1e87ffe1df14da877334834a499f Mon Sep 17 00:00:00 2001 From: Gary Scavone Date: Fri, 11 Oct 2013 02:06:28 +0200 Subject: Release 4.0.12 tarball --- doc/html/recording.html | 133 ++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 66 deletions(-) (limited to 'doc/html/recording.html') diff --git a/doc/html/recording.html b/doc/html/recording.html index 17b1a50..2acb1e6 100644 --- a/doc/html/recording.html +++ b/doc/html/recording.html @@ -8,75 +8,76 @@
Home   Class/Enum List   File List   Compound Members  

- + + +
+
+
Recording
+
- - -

Recording

Using RtAudio for audio input is almost identical to the way it is used for playback. Here's the blocking playback example rewritten for recording:

-
#include "RtAudio.h"
-#include <iostream>
-#include <cstdlib>
-#include <cstring>
-
-int record( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
-         double streamTime, RtAudioStreamStatus status, void *userData )
-{
-  if ( status )
-    std::cout << "Stream overflow detected!" << std::endl;
-
-  // Do something with the data in the "inputBuffer" buffer.
-
-  return 0;
-}
-
-int main()
-{
-  RtAudio adc;
-  if ( adc.getDeviceCount() < 1 ) {
-    std::cout << "\nNo audio devices found!\n";
-    exit( 0 );
-  }
-
-  RtAudio::StreamParameters parameters;
-  parameters.deviceId = adc.getDefaultInputDevice();
-  parameters.nChannels = 2;
-  parameters.firstChannel = 0;
-  unsigned int sampleRate = 44100;
-  unsigned int bufferFrames = 256; // 256 sample frames
-
-  try {
-    adc.openStream( NULL, &parameters, RTAUDIO_SINT16,
-                    sampleRate, &bufferFrames, &record );
-    adc.startStream();
-  }
-  catch ( RtError& e ) {
-    e.printMessage();
-    exit( 0 );
-  }
-  
-  char input;
-  std::cout << "\nRecording ... press <enter> to quit.\n";
-  std::cin.get( input );
-
-  try {
-    // Stop the stream
-    adc.stopStream();
-  }
-  catch (RtError& e) {
-    e.printMessage();
-  }
-
-  if ( adc.isStreamOpen() ) adc.closeStream();
-
-  return 0;
-}
-

In this example, we pass the address of the stream parameter structure as the second argument of the RtAudio::openStream() function and pass a NULL value for the output stream parameters. In this example, the record() callback function performs no specific operations.

-
+

Using RtAudio for audio input is almost identical to the way it is used for playback. Here's the blocking playback example rewritten for recording:

+
#include "RtAudio.h"
+
#include <iostream>
+
#include <cstdlib>
+
#include <cstring>
+
+
int record( void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
+
double streamTime, RtAudioStreamStatus status, void *userData )
+
{
+
if ( status )
+
std::cout << "Stream overflow detected!" << std::endl;
+
+
// Do something with the data in the "inputBuffer" buffer.
+
+
return 0;
+
}
+
+
int main()
+
{
+
RtAudio adc;
+
if ( adc.getDeviceCount() < 1 ) {
+
std::cout << "\nNo audio devices found!\n";
+
exit( 0 );
+
}
+
+ +
parameters.deviceId = adc.getDefaultInputDevice();
+
parameters.nChannels = 2;
+
parameters.firstChannel = 0;
+
unsigned int sampleRate = 44100;
+
unsigned int bufferFrames = 256; // 256 sample frames
+
+
try {
+
adc.openStream( NULL, &parameters, RTAUDIO_SINT16,
+
sampleRate, &bufferFrames, &record );
+
adc.startStream();
+
}
+
catch ( RtError& e ) {
+ +
exit( 0 );
+
}
+
+
char input;
+
std::cout << "\nRecording ... press <enter> to quit.\n";
+
std::cin.get( input );
+
+
try {
+
// Stop the stream
+
adc.stopStream();
+
}
+
catch (RtError& e) {
+ +
}
+
+
if ( adc.isStreamOpen() ) adc.closeStream();
+
+
return 0;
+
}
+

In this example, we pass the address of the stream parameter structure as the second argument of the RtAudio::openStream() function and pass a NULL value for the output stream parameters. In this example, the record() callback function performs no specific operations.

+

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