| 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.79 [en] (Windows NT 5.0; 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 | Overview of PortAudio</h2> |
| 25 | |
| 26 | <blockquote>PortAudio is a library that provides streaming audio input |
| 27 | and output. It is a cross-platform API (Application Programming Interface) |
| 28 | that works on Windows, Macintosh, Unix running OSS, SGI, BeOS, and perhaps |
| 29 | other platforms by the time you read this. This means that you can write |
| 30 | a simple 'C' program to process or generate an audio signal, and that program |
| 31 | can run on several different types of computer just by recompiling the |
| 32 | source code. |
| 33 | <p>Here are the steps to writing a PortAudio application: |
| 34 | <ol> |
| 35 | <li> |
| 36 | Write a callback function that will be called by PortAudio when audio processing |
| 37 | is needed.</li> |
| 38 | |
| 39 | <li> |
| 40 | Initialize the PA library and open a stream for audio I/O.</li> |
| 41 | |
| 42 | <li> |
| 43 | Start the stream. Your callback function will be now be called repeatedly |
| 44 | by PA in the background.</li> |
| 45 | |
| 46 | <li> |
| 47 | In your callback you can read audio data from the inputBuffer and/or write |
| 48 | data to the outputBuffer.</li> |
| 49 | |
| 50 | <li> |
| 51 | Stop the stream by returning 1 from your callback, or by calling a stop |
| 52 | function.</li> |
| 53 | |
| 54 | <li> |
| 55 | Close the stream and terminate the library.</li> |
| 56 | </ol> |
| 57 | </blockquote> |
| 58 | |
| 59 | <blockquote>There is also <a href="pa_tut_rw.html">another interface</a> |
| 60 | provided that allows you to generate audio in the foreground. You then |
| 61 | simply write data to the stream and the tool will not return until it is |
| 62 | ready to accept more data. This interface is simpler to use but is usually |
| 63 | not preferred for large applications because it requires that you launch |
| 64 | a thread to perform the synthesis. Launching a thread may be difficult |
| 65 | on non-multi-tasking systems such as the Macintosh prior to MacOS X. |
| 66 | <p>Let's continue by building a simple application that will play a sawtooth |
| 67 | wave. |
| 68 | <p>Please select the page for the specific implementation you would like |
| 69 | to use: |
| 70 | <ul> |
| 71 | <li> |
| 72 | <a href="pa_tut_pc.html">Windows (WMME or DirectSound)</a></li> |
| 73 | |
| 74 | <li> |
| 75 | <a href="pa_tut_mac.html">Macintosh SoundManager for OS 7,8,9</a></li> |
| 76 | |
| 77 | <li> |
| 78 | <a href="pa_tut_mac_osx.html">Macintosh CoreAudio for OS X</a></li> |
| 79 | |
| 80 | <li> |
| 81 | <a href="pa_tut_asio.html">ASIO on Windows or Macintosh</a></li> |
| 82 | |
| 83 | <li> |
| 84 | <a href="pa_tut_oss.html">Unix OSS</a></li> |
| 85 | </ul> |
| 86 | or continue with the <a href="pa_tut_callback.html">next page of the programming |
| 87 | tutorial</a>.</blockquote> |
| 88 | <font size=+2><a href="http://www.portaudio.com/">home</a> | |
| 89 | <a href="pa_tutorial.html">contents</a> |
| 90 | | <a href="pa_tutorial.html">previous</a></font> |
| 91 | </body> |
| 92 | </html> |