| 1 | <!doctype html public "-//w3c//dtd html 4.0 transitional//en"> |
| 2 | <html> |
| 3 | <head> |
| 4 | <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> |
| 5 | <meta name="GENERATOR" content="Mozilla/4.73 [en]C-gatewaynet (Win98; U) [Netscape]"> |
| 6 | <meta name="Author" content="Phil Burk"> |
| 7 | <meta name="Description" content="Tutorial for PortAudio, a cross platform, open-source, audio I/O library.It provides a very simple API for recording and/or playing sound using a simple callback function."> |
| 8 | <meta name="KeyWords" content="audio, tutorial, library, portable, open-source, DirectSound,sound, music, JSyn, synthesis,"> |
| 9 | <title>PortAudio Tutorial</title> |
| 10 | </head> |
| 11 | <body> |
| 12 | |
| 13 | <center><table COLS=1 WIDTH="100%" BGCOLOR="#FADA7A" > |
| 14 | <tr> |
| 15 | <td> |
| 16 | <center> |
| 17 | <h1> |
| 18 | PortAudio Tutorial</h1></center> |
| 19 | </td> |
| 20 | </tr> |
| 21 | </table></center> |
| 22 | |
| 23 | <h2> |
| 24 | Opening a Stream using Defaults</h2> |
| 25 | |
| 26 | <blockquote>The next step is to open a stream which is similar to opening |
| 27 | a file. You can specify whether you want audio input and/or output, how |
| 28 | many channels, the data format, sample rate, etc. There are two calls for |
| 29 | opening streams, <tt>Pa_OpenStream</tt>() and <tt>Pa_OpenDefaultStream</tt>(). |
| 30 | <p><tt>Pa_OpenStream()</tt> takes extra parameters which give you |
| 31 | more control. You can normally just use <tt>Pa_OpenDefaultStream</tt>() |
| 32 | which just calls <tt>Pa_OpenStream()</tt> <tt>with</tt> some reasonable |
| 33 | default values. Let's open a stream for stereo output, using floating |
| 34 | point data, at 44100 Hz. |
| 35 | <blockquote> |
| 36 | <pre>err = Pa_OpenDefaultStream( |
| 37 | &stream, /* passes back stream pointer */ |
| 38 | 0, /* no input channels */ |
| 39 | 2, /* stereo output */ |
| 40 | paFloat32, /* 32 bit floating point output */ |
| 41 | 44100, /* sample rate */ |
| 42 | 256, /* frames per buffer */ |
| 43 | 0, /* number of buffers, if zero then use default minimum */ |
| 44 | patestCallback, /* specify our custom callback */ |
| 45 | &data ); /* pass our data through to callback */</pre> |
| 46 | </blockquote> |
| 47 | If you want to use 16 bit integer data, pass <tt>paInt16</tt> instead of |
| 48 | <tt>paFloat32</tt>.</blockquote> |
| 49 | <font size=+2><a href="http://www.portaudio.com/">home</a> | <a href="pa_tutorial.html">contents</a> |
| 50 | | <a href="pa_tut_init.html">previous</a> | <a href="pa_tut_run.html">next</a></font> |
| 51 | </body> |
| 52 | </html> |