pa_tut_devs.html 2.6 KB

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