summaryrefslogtreecommitdiff
path: root/doc/doxygen/recording.txt
diff options
context:
space:
mode:
authorGary Scavone <gary@music.mcgill.ca>2007-08-07 14:52:05 +0000
committerStephen Sinclair <sinclair@music.mcgill.ca>2013-10-11 01:19:40 +0200
commitb0080e69d64ce69e21c8ce1b22b1bb7f888f1e58 (patch)
treeb51ebcd31a5280b4f4e9e45484f07d9b35723743 /doc/doxygen/recording.txt
parent0fbcd74a04713a4725d2f346a493121b623d60ab (diff)
Check in of new version 4.0.0 distribution (GS).
Diffstat (limited to 'doc/doxygen/recording.txt')
-rw-r--r--doc/doxygen/recording.txt66
1 files changed, 66 insertions, 0 deletions
diff --git a/doc/doxygen/recording.txt b/doc/doxygen/recording.txt
new file mode 100644
index 0000000..6316a5c
--- /dev/null
+++ b/doc/doxygen/recording.txt
@@ -0,0 +1,66 @@
+/*! \page 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:
+
+\code
+#include "RtAudio.h"
+#include <iostream>
+
+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;
+}
+\endcode
+
+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 \e record() callback function performs no specific operations.
+
+*/