PortAudio: Difference between revisions

From EMC23 - Satellite Of Love
Jump to navigation Jump to search
(Created page with "PortAudio Tutorials These tutorial]s takes you through a hands-on example of using PortAudio to make sound. If you'd prefer to start with a top-down overview of the PortAudio...")
 
mNo edit summary
Line 1: Line 1:
PortAudio Tutorials
= PortAudio Tutorials =
These tutorial]s takes you through a hands-on example of using PortAudio to make sound. If you'd prefer to start with a top-down overview of the PortAudio API, check out the files.portaudio.com/api_overview.html| PortAudio API Overview ]
These tutorial]s takes you through a hands-on example of using PortAudio to make sound. If you'd prefer to start with a top-down overview of the PortAudio API, check out the [files.portaudio.com/api_overview.html| PortAudio API Overview ]
<h1><a class="anchor" id="tut_start1"></a>Downloading</h1>
= Downloading =
<p>First thing you need to do is download the PortAudio source code either <a href="http://www.portaudio.com/download.html">as a tarball from the website</a>, or <a href="http://www.portaudio.com/usingsvn.html">from the Subversion Repository</a>.</p>
* First thing you need to do is download the PortAudio source code either <a href="http://www.portaudio.com/download.html">as a tarball from the website</a>, or [http://www.portaudio.com/usingsvn.html from the Subversion Repository]
<h1><a class="anchor" id="tut_start2"></a>
= Compiling =
Compiling</h1>
* Once you've downloaded PortAudio you'll need to compile it, which of course, depends on your environment:
<p>Once you've downloaded PortAudio you'll need to compile it, which of course, depends on your environment:</p>
 
<ul>
= Windows =  
= Windows =  
* http://files.portaudio.com/docs/v19-doxydocs/compile_windows.html Building PortAudio for Windows using Microsoft Visual Studio
* http://files.portaudio.com/docs/v19-doxydocs/compile_windows.html Building PortAudio for Windows using Microsoft Visual Studio
Line 19: Line 18:


* You can also use CMake to generate project files for PortAudio on Windows, OS X or Linux or include PortAudio easily in your own CMake project. See <a class="el" href="compile_cmake.html">PortAudio on Windows, OS X or Linux via. CMake</a>.</p>
* You can also use CMake to generate project files for PortAudio on Windows, OS X or Linux or include PortAudio easily in your own CMake project. See <a class="el" href="compile_cmake.html">PortAudio on Windows, OS X or Linux via. CMake</a>.</p>
<p>Many platforms with GCC/make can use the simple ./configure &amp;&amp; make combination and simply use the resulting libraries in their code.</p>
* Many platforms with GCC/make can use the simple ./configure &amp;&amp; make combination and simply use the resulting libraries in their code.
<h1><a class="anchor" id="tut_start3"></a>
 
Programming with PortAudio</h1>
 
<p>Below are the steps to writing a PortAudio application using the callback technique:</p>
= Programming with PortAudio =
<ul>
== Below are the steps to writing a PortAudio application using the callback technique: ==
<li>Write a callback function that will be called by PortAudio when audio processing is needed.</li>
 
<li>Initialize the PA library and open a stream for audio I/O.</li>
* Write a callback function that will be called by PortAudio when audio processing is needed.
<li>Start the stream. Your callback function will be now be called repeatedly by PA in the background.</li>
* Initialize the PA library and open a stream for audio I/O.
<li>In your callback you can read audio data from the inputBuffer and/or write data to the outputBuffer.</li>
* Start the stream. Your callback function will be now be called repeatedly by PA in the background.
<li>Stop the stream by returning 1 from your callback, or by calling a stop function.</li>
* In your callback you can read audio data from the inputBuffer and/or write data to the outputBuffer.
<li>Close the stream and terminate the library.</li>
* Stop the stream by returning 1 from your callback, or by calling a stop function.
</ul>
* Close the stream and terminate the library.
 
<p>In addition to this "Callback" architecture, V19 also supports a "Blocking I/O" model which uses read and write calls which may be more familiar to non-audio programmers. Note that at this time, not all APIs support this functionality.</p>
<p>In addition to this "Callback" architecture, V19 also supports a "Blocking I/O" model which uses read and write calls which may be more familiar to non-audio programmers. Note that at this time, not all APIs support this functionality.</p>
<p>In this tutorial, we'll show how to use the callback architecture to play a sawtooth wave. Much of the tutorial is taken from the file <a class="el" href="paex__saw_8c.html" title="Play a simple (aliasing) sawtooth wave. ">paex_saw.c</a>, which is part of the PortAudio distribution. When you're done with this tutorial, you'll be armed with the basic knowledge you need to write an audio program. If you need more sample code, look in the "examples" and "test" directory of the PortAudio distribution. Another great source of info is the <a class="el" href="portaudio_8h.html" title="The portable PortAudio API. ">portaudio.h</a> Doxygen page, which documents the entire V19 API. Also see the page for <a href="https://github.com/PortAudio/portaudio/wiki/Tips">tips on programming PortAudio</a> on the PortAudio wiki.</p>
<p>In this tutorial, we'll show how to use the callback architecture to play a sawtooth wave. Much of the tutorial is taken from the file <a class="el" href="paex__saw_8c.html" title="Play a simple (aliasing) sawtooth wave. ">paex_saw.c</a>, which is part of the PortAudio distribution. When you're done with this tutorial, you'll be armed with the basic knowledge you need to write an audio program. If you need more sample code, look in the "examples" and "test" directory of the PortAudio distribution. Another great source of info is the <a class="el" href="portaudio_8h.html" title="The portable PortAudio API. ">portaudio.h</a> Doxygen page, which documents the entire V19 API. Also see the page for <a href="https://github.com/PortAudio/portaudio/wiki/Tips">tips on programming PortAudio</a> on the PortAudio wiki
<h1><a class="anchor" id="tut_start4"></a>
 
Programming Tutorial Contents</h1>
= Programming Tutorial Contents =
<ul>
 
<li><a class="el" href="writing_a_callback.html">Writing a Callback Function</a></li>
http://files.portaudio.com/docs/v19-doxydocs/writing_a_callback.html">Writing a Callback Function  
<li><a class="el" href="initializing_portaudio.html">Initializing PortAudio</a></li>
http://files.portaudio.com/docs/v19-doxydocs/initializing_portaudio.html">Initializing PortAudio  
<li><a class="el" href="open_default_stream.html">Opening a Stream Using Defaults</a></li>
http://files.portaudio.com/docs/v19-doxydocs/open_default_stream.html">Opening a Stream Using Defaults  
<li><a class="el" href="start_stop_abort.html">Starting, Stopping and Aborting a Stream</a></li>
http://files.portaudio.com/docs/v19-doxydocs/start_stop_abort.html">Starting, Stopping and Aborting a Stream  
<li><a class="el" href="terminating_portaudio.html">Closing a Stream and Terminating PortAudio</a></li>
http://files.portaudio.com/docs/v19-doxydocs/href="terminating_portaudio.html">Closing a Stream and Terminating PortAudio  
<li><a class="el" href="utility_functions.html">Utility Functions</a></li>
http://files.portaudio.com/docs/v19-doxydocs/href="utility_functions.html">Utility Functions  
<li><a class="el" href="querying_devices.html">Enumerating and Querying PortAudio Devices</a></li>
http://files.portaudio.com/docs/v19-doxydocs/href="querying_devices.html">Enumerating and Querying PortAudio Devices  
<li><a class="el" href="blocking_read_write.html">Blocking Read/Write Functions</a></li>
http://files.portaudio.com/docs/v19-doxydocs/href="blocking_read_write.html">Blocking Read/Write Functions  
</ul>
 
<p>If you are upgrading from V18, you may want to look at the <a href="http://www.portaudio.com/docs/proposals/index.html">Proposed Enhancements to PortAudio</a>, which describes the differences between V18 and V19.</p>
<p>If you are upgrading from V18, you may want to look at the <a href="http://www.portaudio.com/docs/proposals/index.html">Proposed Enhancements to PortAudio</a>, which describes the differences between V18 and V19.
<p>Once you have a basic understanding of how to use PortAudio, you might be interested in <a class="el" href="exploring.html">Exploring PortAudio</a>.</p>
 
<p>Next: <a class="el" href="writing_a_callback.html">Writing a Callback Function</a> </p>
 
</div></div><!-- contents -->
Once you have a basic understanding of how to use PortAudio, you might be interested in <a class="el" href="exploring.html">Exploring PortAudio</a>.</p>
http://files.portaudio.com/docs/v19-doxydocs/writing_a_callback.html Writing a Callback Function

Revision as of 17:41, 1 September 2021

PortAudio Tutorials[edit]

These tutorial]s takes you through a hands-on example of using PortAudio to make sound. If you'd prefer to start with a top-down overview of the PortAudio API, check out the [files.portaudio.com/api_overview.html| PortAudio API Overview ]

Downloading[edit]

Compiling[edit]

  • Once you've downloaded PortAudio you'll need to compile it, which of course, depends on your environment:

Windows[edit]

Mac OS X[edit]

POSIX[edit]

  • You can also use CMake to generate project files for PortAudio on Windows, OS X or Linux or include PortAudio easily in your own CMake project. See <a class="el" href="compile_cmake.html">PortAudio on Windows, OS X or Linux via. CMake</a>.

  • Many platforms with GCC/make can use the simple ./configure && make combination and simply use the resulting libraries in their code.


Programming with PortAudio[edit]

Below are the steps to writing a PortAudio application using the callback technique:[edit]

  • Write a callback function that will be called by PortAudio when audio processing is needed.
  • Initialize the PA library and open a stream for audio I/O.
  • Start the stream. Your callback function will be now be called repeatedly by PA in the background.
  • In your callback you can read audio data from the inputBuffer and/or write data to the outputBuffer.
  • Stop the stream by returning 1 from your callback, or by calling a stop function.
  • Close the stream and terminate the library.

In addition to this "Callback" architecture, V19 also supports a "Blocking I/O" model which uses read and write calls which may be more familiar to non-audio programmers. Note that at this time, not all APIs support this functionality.

In this tutorial, we'll show how to use the callback architecture to play a sawtooth wave. Much of the tutorial is taken from the file <a class="el" href="paex__saw_8c.html" title="Play a simple (aliasing) sawtooth wave. ">paex_saw.c</a>, which is part of the PortAudio distribution. When you're done with this tutorial, you'll be armed with the basic knowledge you need to write an audio program. If you need more sample code, look in the "examples" and "test" directory of the PortAudio distribution. Another great source of info is the <a class="el" href="portaudio_8h.html" title="The portable PortAudio API. ">portaudio.h</a> Doxygen page, which documents the entire V19 API. Also see the page for <a href="https://github.com/PortAudio/portaudio/wiki/Tips">tips on programming PortAudio</a> on the PortAudio wiki

Programming Tutorial Contents[edit]

http://files.portaudio.com/docs/v19-doxydocs/writing_a_callback.html">Writing a Callback Function http://files.portaudio.com/docs/v19-doxydocs/initializing_portaudio.html">Initializing PortAudio http://files.portaudio.com/docs/v19-doxydocs/open_default_stream.html">Opening a Stream Using Defaults http://files.portaudio.com/docs/v19-doxydocs/start_stop_abort.html">Starting, Stopping and Aborting a Stream http://files.portaudio.com/docs/v19-doxydocs/href="terminating_portaudio.html">Closing a Stream and Terminating PortAudio http://files.portaudio.com/docs/v19-doxydocs/href="utility_functions.html">Utility Functions http://files.portaudio.com/docs/v19-doxydocs/href="querying_devices.html">Enumerating and Querying PortAudio Devices http://files.portaudio.com/docs/v19-doxydocs/href="blocking_read_write.html">Blocking Read/Write Functions

If you are upgrading from V18, you may want to look at the <a href="http://www.portaudio.com/docs/proposals/index.html">Proposed Enhancements to PortAudio</a>, which describes the differences between V18 and V19. Once you have a basic understanding of how to use PortAudio, you might be interested in <a class="el" href="exploring.html">Exploring PortAudio</a>.

http://files.portaudio.com/docs/v19-doxydocs/writing_a_callback.html Writing a Callback Function