| 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 | Starting and Stopping a Stream</h2> |
| 25 | |
| 26 | <blockquote>The stream will not start running until you call Pa_StartStream(). |
| 27 | Then it will start calling your callback function to perform the audio |
| 28 | processing. |
| 29 | <blockquote> |
| 30 | <pre>err = Pa_StartStream( stream ); |
| 31 | if( err != paNoError ) goto error;</pre> |
| 32 | </blockquote> |
| 33 | At this point, audio is being generated. You can communicate to your callback |
| 34 | routine through the data structure you passed in on the open call, or through |
| 35 | global variables, or using other interprocess communication techniques. |
| 36 | Please be aware that your callback function may be called at interrupt |
| 37 | time when your foreground process is least expecting it. So avoid sharing |
| 38 | complex data structures that are easily corrupted like double linked lists. |
| 39 | <p>In many of the tests we simply sleep for a few seconds so we can hear |
| 40 | the sound. This is easy to do with Pa_Sleep() which will sleep for some |
| 41 | number of milliseconds. Do not rely on this function for accurate scheduling. |
| 42 | it is mostly for writing examples. |
| 43 | <blockquote> |
| 44 | <pre>/* Sleep for several seconds. */ |
| 45 | Pa_Sleep(NUM_SECONDS*1000);</pre> |
| 46 | </blockquote> |
| 47 | When you are through, you can stop the stream from the foreground. |
| 48 | <blockquote> |
| 49 | <pre>err = Pa_StopStream( stream ); |
| 50 | if( err != paNoError ) goto error;</pre> |
| 51 | </blockquote> |
| 52 | You can also stop the stream by returning 1 from your custom callback function.</blockquote> |
| 53 | <font size=+2><a href="http://www.portaudio.com/">home</a> | <a href="pa_tutorial.html">contents</a> |
| 54 | | <a href="pa_tut_open.html">previous</a> | <a href="pa_tut_term.html">next</a></font> |
| 55 | </body> |
| 56 | </html> |