diff options
| author | Gary Scavone <gary@music.mcgill.ca> | 2013-10-11 01:58:40 +0200 |
|---|---|---|
| committer | Stephen Sinclair <sinclair@music.mcgill.ca> | 2013-10-11 01:58:40 +0200 |
| commit | be2eb99b37cd017fcab00c1704f794cb1bc85ee1 (patch) | |
| tree | 3d44598e9ded18aee024a8c1a6cd4f2b1d4a5dce /doc/html/recording.html | |
| parent | 464790a82e90cfea0cb47a7f716117b63bb6dd5f (diff) | |
Release 4.0.7 tarball4.0.7
Diffstat (limited to 'doc/html/recording.html')
| -rw-r--r-- | doc/html/recording.html | 44 |
1 files changed, 23 insertions, 21 deletions
diff --git a/doc/html/recording.html b/doc/html/recording.html index c7772bf..3e86db4 100644 --- a/doc/html/recording.html +++ b/doc/html/recording.html @@ -8,21 +8,23 @@ <CENTER> <a class="qindex" href="index.html">Home</a> <a class="qindex" href="annotated.html">Class/Enum List</a> <a class="qindex" href="files.html">File List</a> <a class="qindex" href="functions.html">Compound Members</a> </CENTER> <HR> -<!-- Generated by Doxygen 1.5.8 --> +<!-- Generated by Doxygen 1.6.2 --> <div class="contents"> -<h1><a class="anchor" name="recording">Recording </a></h1>Using <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> for audio input is almost identical to the way it is used for playback. Here's the blocking playback example rewritten for recording:<p> -<div class="fragment"><pre class="fragment"><span class="preprocessor">#include "<a class="code" href="RtAudio_8h.html">RtAudio.h</a>"</span> + + +<h1><a class="anchor" id="recording">Recording </a></h1><p>Using <a class="el" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> for audio input is almost identical to the way it is used for playback. Here's the blocking playback example rewritten for recording:</p> +<div class="fragment"><pre class="fragment"><span class="preprocessor">#include "<a class="code" href="RtAudio_8h.html">RtAudio.h</a>"</span> <span class="preprocessor">#include <iostream></span> <span class="preprocessor">#include <cstdlib></span> <span class="preprocessor">#include <cstring></span> <span class="keywordtype">int</span> record( <span class="keywordtype">void</span> *outputBuffer, <span class="keywordtype">void</span> *inputBuffer, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> nBufferFrames, - <span class="keywordtype">double</span> streamTime, <a class="code" href="RtAudio_8h.html#80e306d363583da3b0a1b65d9b57c806" title="RtAudio stream status (over- or underflow) flags.">RtAudioStreamStatus</a> status, <span class="keywordtype">void</span> *userData ) + <span class="keywordtype">double</span> streamTime, <a class="code" href="RtAudio_8h.html#a80e306d363583da3b0a1b65d9b57c806" title="RtAudio stream status (over- or underflow) flags.">RtAudioStreamStatus</a> status, <span class="keywordtype">void</span> *userData ) { <span class="keywordflow">if</span> ( status ) - std::cout << <span class="stringliteral">"Stream overflow detected!"</span> << std::endl; + std::cout << <span class="stringliteral">"Stream overflow detected!"</span> << std::endl; - <span class="comment">// Do something with the data in the "inputBuffer" buffer.</span> + <span class="comment">// Do something with the data in the "inputBuffer" buffer.</span> <span class="keywordflow">return</span> 0; } @@ -30,50 +32,50 @@ <span class="keywordtype">int</span> main() { <a class="code" href="classRtAudio.html" title="Realtime audio i/o C++ classes.">RtAudio</a> adc; - <span class="keywordflow">if</span> ( adc.<a class="code" href="classRtAudio.html#747ce2d73803641bbb66d6e78092aa1a" title="A public function that queries for the number of audio devices available.">getDeviceCount</a>() < 1 ) { - std::cout << <span class="stringliteral">"\nNo audio devices found!\n"</span>; + <span class="keywordflow">if</span> ( adc.<a class="code" href="classRtAudio.html#a747ce2d73803641bbb66d6e78092aa1a" title="A public function that queries for the number of audio devices available.">getDeviceCount</a>() < 1 ) { + std::cout << <span class="stringliteral">"\nNo audio devices found!\n"</span>; exit( 0 ); } <a class="code" href="structRtAudio_1_1StreamParameters.html" title="The structure for specifying input or ouput stream parameters.">RtAudio::StreamParameters</a> parameters; - parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#ffd27496c70c0986522056234c64e28e">deviceId</a> = adc.<a class="code" href="classRtAudio.html#ad8b94edd3cd379ee300b125750ac6ce" title="A function that returns the index of the default input device.">getDefaultInputDevice</a>(); - parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#78798b65fada7941e1a7e47c11c9e627">nChannels</a> = 2; - parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#ddc8281f23a87455ec6dedbc766a74db">firstChannel</a> = 0; + parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#ab3c72bcf3ef12149ae9a4fb597cc5489">deviceId</a> = adc.<a class="code" href="classRtAudio.html#aad8b94edd3cd379ee300b125750ac6ce" title="A function that returns the index of the default input device.">getDefaultInputDevice</a>(); + parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#a88a10091b6e284e21235cc6f25332ebd">nChannels</a> = 2; + parameters.<a class="code" href="structRtAudio_1_1StreamParameters.html#ad4b4503782653ec93c83328c46abe50c">firstChannel</a> = 0; <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> sampleRate = 44100; <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> bufferFrames = 256; <span class="comment">// 256 sample frames</span> <span class="keywordflow">try</span> { - adc.<a class="code" href="classRtAudio.html#facc99740fa4c5606fb35467cdea6da8" title="A public function for opening a stream with the specified parameters.">openStream</a>( NULL, &parameters, RTAUDIO_SINT16, + adc.<a class="code" href="classRtAudio.html#afacc99740fa4c5606fb35467cdea6da8" title="A public function for opening a stream with the specified parameters.">openStream</a>( NULL, &parameters, RTAUDIO_SINT16, sampleRate, &bufferFrames, &record ); - adc.<a class="code" href="classRtAudio.html#ec017a89629ccef66a90b60be22a2f80" title="A function that starts a stream.">startStream</a>(); + adc.<a class="code" href="classRtAudio.html#aec017a89629ccef66a90b60be22a2f80" title="A function that starts a stream.">startStream</a>(); } <span class="keywordflow">catch</span> ( <a class="code" href="classRtError.html" title="Exception handling class for RtAudio &amp; RtMidi.">RtError</a>& e ) { - e.<a class="code" href="classRtError.html#da41f7472122f45bc5b4677f066e0943" title="Prints thrown error message to stderr.">printMessage</a>(); + e.<a class="code" href="classRtError.html#ada41f7472122f45bc5b4677f066e0943" title="Prints thrown error message to stderr.">printMessage</a>(); exit( 0 ); } <span class="keywordtype">char</span> input; - std::cout << <span class="stringliteral">"\nRecording ... press <enter> to quit.\n"</span>; + std::cout << <span class="stringliteral">"\nRecording ... press <enter> to quit.\n"</span>; std::cin.get( input ); <span class="keywordflow">try</span> { <span class="comment">// Stop the stream</span> - adc.<a class="code" href="classRtAudio.html#f4c241ff86936ecc8108f0d9dfe3efdd" title="Stop a stream, allowing any samples remaining in the output queue to be played.">stopStream</a>(); + adc.<a class="code" href="classRtAudio.html#af4c241ff86936ecc8108f0d9dfe3efdd" title="Stop a stream, allowing any samples remaining in the output queue to be played.">stopStream</a>(); } <span class="keywordflow">catch</span> (<a class="code" href="classRtError.html" title="Exception handling class for RtAudio &amp; RtMidi.">RtError</a>& e) { - e.<a class="code" href="classRtError.html#da41f7472122f45bc5b4677f066e0943" title="Prints thrown error message to stderr.">printMessage</a>(); + e.<a class="code" href="classRtError.html#ada41f7472122f45bc5b4677f066e0943" title="Prints thrown error message to stderr.">printMessage</a>(); } - <span class="keywordflow">if</span> ( adc.<a class="code" href="classRtAudio.html#3863e45ff81dbe97176de0ee7545917f" title="Returns true if a stream is open and false if not.">isStreamOpen</a>() ) adc.<a class="code" href="classRtAudio.html#90d599002ad32cf250a4cb866f2cc93a" title="A function that closes a stream and frees any associated stream memory.">closeStream</a>(); + <span class="keywordflow">if</span> ( adc.<a class="code" href="classRtAudio.html#a3863e45ff81dbe97176de0ee7545917f" title="Returns true if a stream is open and false if not.">isStreamOpen</a>() ) adc.<a class="code" href="classRtAudio.html#a90d599002ad32cf250a4cb866f2cc93a" title="A function that closes a stream and frees any associated stream memory.">closeStream</a>(); <span class="keywordflow">return</span> 0; } -</pre></div><p> -In this example, we pass the address of the stream parameter structure as the second argument of the <a class="el" href="classRtAudio.html#facc99740fa4c5606fb35467cdea6da8" title="A public function for opening a stream with the specified parameters.">RtAudio::openStream()</a> function and pass a NULL value for the output stream parameters. In this example, the <em>record()</em> callback function performs no specific operations. </div> +</pre></div><p>In this example, we pass the address of the stream parameter structure as the second argument of the <a class="el" href="classRtAudio.html#afacc99740fa4c5606fb35467cdea6da8" title="A public function for opening a stream with the specified parameters.">RtAudio::openStream()</a> function and pass a NULL value for the output stream parameters. In this example, the <em>record()</em> callback function performs no specific operations. </p> +</div> <HR> <table><tr><td><img src="../images/mcgill.gif" width=165></td> - <td>©2001-2009 Gary P. Scavone, McGill University. All Rights Reserved.<br>Maintained by <a href="http://www.music.mcgill.ca/~gary/">Gary P. Scavone</a>.</td></tr> + <td>©2001-2010 Gary P. Scavone, McGill University. All Rights Reserved.<br>Maintained by <a href="http://www.music.mcgill.ca/~gary/">Gary P. Scavone</a>.</td></tr> </table> </BODY> |
