PortAudio: Difference between revisions
Jump to navigation
Jump to search
m (→Compiling) |
m (→POSIX) |
||
(6 intermediate revisions by the same user not shown) | |||
Line 9: | Line 9: | ||
== 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] | ||
* http://files.portaudio.com/docs/v19-doxydocs/compile_windows_mingw.html Building Portaudio for Windows with MinGW | * [http://files.portaudio.com/docs/v19-doxydocs/compile_windows_mingw.html Building Portaudio for Windows with MinGW] | ||
* http://files.portaudio.com/docs/v19-doxydocs/compile_windows_asio_msvc.html Building Portaudio for Windows with ASIO support using MSVC | * [http://files.portaudio.com/docs/v19-doxydocs/compile_windows_asio_msvc.html Building Portaudio for Windows with ASIO support using MSVC] | ||
== Mac OS X == | == Mac OS X == | ||
* http://files.portaudio.com/docs/v19-doxydocs/compile_mac_coreaudio.html Building Portaudio for Mac OS X | * [http://files.portaudio.com/docs/v19-doxydocs/compile_mac_coreaudio.html Building Portaudio for Mac OS X] | ||
== POSIX == | == POSIX == | ||
* http://files.portaudio.com/docs/v19-doxydocs/compile_linux.html Building Portaudio for Linux | * [http://files.portaudio.com/docs/v19-doxydocs/compile_linux.html Building Portaudio for Linux] | ||
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 [http://files.portaudio.com/docs/v19-doxydocs/compile_cmake.html PortAudio on Windows, OS X or Linux via. CMake]. | |||
Many platforms with GCC/make can use the simple ./configure && make combination and simply use the resulting libraries in their code. | |||
= Programming with PortAudio = | = Programming with PortAudio = | ||
Below are the steps to writing a PortAudio application using the callback technique: | |||
* Write a callback function that will be called by PortAudio when audio processing is needed. | * Write a callback function that will be called by PortAudio when audio processing is needed. | ||
Line 32: | Line 34: | ||
* Close the stream and terminate the library. | * 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 [http://paex__saw_8c.html Play a simple (aliasing) sawtooth wave], 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 [http://files.portaudio.com/docs/v19-doxydocs/portaudio_8h.html" portaudio.h] Doxygen page, which documents the entire V19 API. Also see the page for [https://github.com/PortAudio/portaudio/wiki/Tips">tips on programming PortAudio] on the PortAudio wiki | |||
= Programming Tutorial Contents = | = Programming Tutorial Contents = | ||
Line 47: | Line 54: | ||
* If you are upgrading from V18, you may want to look at the [http://www.portaudio.com/docs/proposals/index.html | Proposed Enhancements to PortAudio] , which describes the differences between V18 and V19. | * If you are upgrading from V18, you may want to look at the [http://www.portaudio.com/docs/proposals/index.html | Proposed Enhancements to PortAudio] , which describes the differences between V18 and V19. | ||
* Once you have a basic understanding of how to use PortAudio, you might be interested in [http://www.portaudio.com/docs/proposals/exploring.html Exploring PortAudio] | * Once you have a basic understanding of how to use PortAudio, you might be interested in [http://www.portaudio.com/docs/proposals/exploring.html Exploring PortAudio] | ||
http://files.portaudio.com/docs/v19-doxydocs/writing_a_callback.html Writing a Callback Function | *[http://files.portaudio.com/docs/v19-doxydocs/writing_a_callback.html Writing a Callback Function] |
Latest revision as of 19:34, 1 September 2021
PortAudio Tutorials[edit]
These tutorials 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 PortAudio API Overview
Downloading[edit]
- First thing you need to do is download the PortAudio source code either as a tarball from the website, or from the Subversion Repository
Compiling[edit]
Once you've downloaded PortAudio you'll need to compile it, which of course, depends on your environment:
Windows[edit]
- Building PortAudio for Windows using Microsoft Visual Studio
- Building Portaudio for Windows with MinGW
- Building Portaudio for Windows with ASIO support using MSVC
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 PortAudio on Windows, OS X or Linux via. CMake.
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:
- 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 Play a simple (aliasing) sawtooth wave, 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 " portaudio.h Doxygen page, which documents the entire V19 API. Also see the page for ">tips on programming PortAudio on the PortAudio wiki
Programming Tutorial Contents[edit]
- Writing a Callback Function
- Initializing PortAudio
- Opening a Stream Using Defaults
- Starting, Stopping and Aborting a Stream
- Closing a Stream and Terminating PortAudio
- Utility Functions
- Enumerating and Querying PortAudio Devices
- Blocking Read/Write Functions
- If you are upgrading from V18, you may want to look at the | Proposed Enhancements to PortAudio , which describes the differences between V18 and V19.
- Once you have a basic understanding of how to use PortAudio, you might be interested in Exploring PortAudio
- Writing a Callback Function