| 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.75 [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 | Querying for Available Devices</h2> |
|---|
| 25 | |
|---|
| 26 | <blockquote>There are often several different audio devices available in |
|---|
| 27 | a computer with different capabilities. They can differ in the sample rates |
|---|
| 28 | supported, bit widths, etc. PortAudio provides a simple way to query for |
|---|
| 29 | the available devices, and then pass the selected device to Pa_OpenStream(). |
|---|
| 30 | For an example, see the file "pa_tests/pa_devs.c". |
|---|
| 31 | <p>To determine the number of devices: |
|---|
| 32 | <blockquote> |
|---|
| 33 | <pre>numDevices = Pa_CountDevices();</pre> |
|---|
| 34 | </blockquote> |
|---|
| 35 | You can then query each device in turn by calling Pa_GetDeviceInfo() with |
|---|
| 36 | an index. |
|---|
| 37 | <blockquote> |
|---|
| 38 | <pre>for( i=0; i<numDevices; i++ ) { |
|---|
| 39 | pdi = Pa_GetDeviceInfo( i );</pre> |
|---|
| 40 | </blockquote> |
|---|
| 41 | It will return a pointer to a <tt>PaDeviceInfo</tt> structure which is |
|---|
| 42 | defined as: |
|---|
| 43 | <blockquote> |
|---|
| 44 | <pre>typedef struct{ |
|---|
| 45 | int structVersion; |
|---|
| 46 | const char *name; |
|---|
| 47 | int maxInputChannels; |
|---|
| 48 | int maxOutputChannels; |
|---|
| 49 | /* Number of discrete rates, or -1 if range supported. */ |
|---|
| 50 | int numSampleRates; |
|---|
| 51 | /* Array of supported sample rates, or {min,max} if range supported. */ |
|---|
| 52 | const double *sampleRates; |
|---|
| 53 | PaSampleFormat nativeSampleFormat; |
|---|
| 54 | }PaDeviceInfo;</pre> |
|---|
| 55 | </blockquote> |
|---|
| 56 | If the device supports a continuous range of sample rates, then numSampleRates |
|---|
| 57 | will equal -1, and the sampleRates array will have two values, the minimum |
|---|
| 58 | and maximum rate. |
|---|
| 59 | <p>The device information is allocated by Pa_Initialize() and freed by |
|---|
| 60 | Pa_Terminate() so you do not have to free() the structure returned by Pa_GetDeviceInfo().</blockquote> |
|---|
| 61 | <font size=+2><a href="http://www.portaudio.com/">home</a> | |
|---|
| 62 | <a href="pa_tutorial.html">contents</a> |
|---|
| 63 | | <a href="pa_tut_util.html">previous</a> | <a href="pa_tut_rw.html">next</a></font> |
|---|
| 64 | </body> |
|---|
| 65 | </html> |
|---|