├── bindings └── cpp │ ├── NEWS │ ├── AUTHORS │ ├── README │ ├── build │ ├── gnu │ │ ├── OUT_OF_DATE │ │ ├── aclocal.m4 │ │ └── Makefile.in │ ├── vc7 │ │ └── OUT_OF_DATE │ ├── vc6 │ │ ├── static_library.dsw │ │ ├── devs_example.dsw │ │ └── sine_example.dsw │ └── vc7_1 │ │ ├── static_library.sln │ │ ├── devs_example.sln │ │ └── sine_example.sln │ ├── source │ └── portaudiocpp │ │ ├── MemFunCallbackStream.cxx │ │ ├── CallbackStream.cxx │ │ ├── CallbackInterface.cxx │ │ ├── CMakeLists.txt │ │ ├── CFunCallbackStream.cxx │ │ ├── InterfaceCallbackStream.cxx │ │ ├── SystemDeviceIterator.cxx │ │ ├── SystemHostApiIterator.cxx │ │ ├── AsioDeviceAdapter.cxx │ │ ├── BlockingStream.cxx │ │ └── CppFunCallbackStream.cxx │ ├── doc │ ├── Makefile.am │ └── README │ ├── Makefile.am │ ├── cmake │ ├── PortAudioCppConfig.cmake.in │ ├── portaudiocpp.pc.in │ └── modules │ │ ├── FindPortAudio.cmake │ │ └── FindASIO.cmake │ ├── bin │ └── Makefile.am │ ├── portaudiocpp.pc.in │ ├── include │ ├── Makefile.am │ └── portaudiocpp │ │ ├── SampleDataFormat.hxx │ │ ├── CallbackStream.hxx │ │ ├── AsioDeviceAdapter.hxx │ │ ├── BlockingStream.hxx │ │ ├── InterfaceCallbackStream.hxx │ │ ├── CallbackInterface.hxx │ │ ├── CFunCallbackStream.hxx │ │ ├── SystemHostApiIterator.hxx │ │ ├── AutoSystem.hxx │ │ ├── SystemDeviceIterator.hxx │ │ ├── HostApi.hxx │ │ ├── Stream.hxx │ │ ├── DirectionSpecificStreamParameters.hxx │ │ ├── StreamParameters.hxx │ │ ├── CppFunCallbackStream.hxx │ │ ├── Device.hxx │ │ └── System.hxx │ ├── lib │ └── Makefile.am │ ├── configure.ac │ └── COPYING ├── src ├── common │ ├── pa_gitrevision.h │ └── pa_cpuload.h ├── hostapi │ ├── asio │ │ ├── Pa_ASIO.pdf │ │ └── Callback_adaptation_.pdf │ ├── oss │ │ ├── low_latency_tip.txt │ │ └── recplay.c │ ├── skeleton │ │ └── README.txt │ ├── wasapi │ │ ├── mingw-include │ │ │ ├── propkey.h │ │ │ ├── PropIdl.h │ │ │ ├── functiondiscoverykeys_devpkey.h │ │ │ ├── winapifamily.h │ │ │ ├── ksguid.h │ │ │ ├── propkeydef.h │ │ │ └── AudioSessionTypes.h │ │ └── readme.txt │ └── pulseaudio │ │ ├── pa_linux_pulseaudio_block_internal.h │ │ └── pa_linux_pulseaudio_cb_internal.h └── os │ └── win │ ├── pa_x86_plain_converters.h │ ├── pa_win_util.h │ ├── pa_win_wdmks_utils.h │ └── pa_win_version.h ├── filtered1.wav ├── test ├── README.txt ├── README.md ├── test_use_cmake │ └── CMakeLists.txt ├── CMakeLists.txt ├── patest_init.c └── patest_ringmix.c ├── doc ├── src │ ├── images │ │ └── portaudio-external-architecture-diagram.png │ ├── tutorial │ │ ├── terminating_portaudio.dox │ │ ├── exploring.dox │ │ ├── initializing_portaudio.dox │ │ ├── compile_windows_mingw.dox │ │ ├── start_stop_abort.dox │ │ ├── utility_functions.dox │ │ ├── open_default_stream.dox │ │ ├── compile_windows_mingw-w64.dox │ │ ├── tutorial_start.dox │ │ └── compile_cmake.dox │ ├── srcguide.dox │ ├── license.dox │ └── mainpage.dox └── utils │ └── checkfiledocs.py ├── qa ├── CMakeLists.txt ├── loopback │ ├── CMakeLists.txt │ └── src │ │ ├── biquad_filter.h │ │ ├── test_audio_analyzer.h │ │ ├── paqa_tools.h │ │ └── qa_tools.h └── paqa_macros.h ├── .github ├── asiosdk-version.txt ├── workflows │ ├── whitelint.yml │ ├── compare_def_files.yml │ └── autotools_msys2.yml └── ISSUE_TEMPLATE │ └── bug_report.md ├── portaudio-2.0.pc.in ├── .editorconfig ├── clear_gitrevision.sh ├── cmake ├── portaudio-2.0.pc.in ├── PortAudioConfig.cmake.in ├── cmake_uninstall.cmake.in ├── modules │ ├── FindOSS.cmake │ ├── FindJACK.cmake │ ├── FindRegex.cmake │ └── FindASIO.cmake └── portaudio.def.in ├── update_gitrevision.sh ├── msvc ├── portaudio.dsw ├── portaudio.sln └── portaudio.def ├── .gitignore ├── README.configure.txt ├── .gitattributes ├── vcpkg.json ├── examples └── CMakeLists.txt ├── include ├── pa_linux_pulseaudio.h └── pa_jack.h ├── README.md └── pa_compare_def_files.py /bindings/cpp/NEWS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bindings/cpp/AUTHORS: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bindings/cpp/README: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bindings/cpp/build/gnu/OUT_OF_DATE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /bindings/cpp/build/vc7/OUT_OF_DATE: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /src/common/pa_gitrevision.h: -------------------------------------------------------------------------------- 1 | #define PA_GIT_REVISION unknown 2 | -------------------------------------------------------------------------------- /filtered1.wav: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortAudio/portaudio/HEAD/filtered1.wav -------------------------------------------------------------------------------- /test/README.txt: -------------------------------------------------------------------------------- 1 | Contents moved to https://github.com/PortAudio/portaudio/blob/master/test/README.md 2 | -------------------------------------------------------------------------------- /src/hostapi/asio/Pa_ASIO.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortAudio/portaudio/HEAD/src/hostapi/asio/Pa_ASIO.pdf -------------------------------------------------------------------------------- /src/hostapi/oss/low_latency_tip.txt: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortAudio/portaudio/HEAD/src/hostapi/oss/low_latency_tip.txt -------------------------------------------------------------------------------- /src/hostapi/asio/Callback_adaptation_.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortAudio/portaudio/HEAD/src/hostapi/asio/Callback_adaptation_.pdf -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/MemFunCallbackStream.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/MemFunCallbackStream.hxx" 2 | 3 | // (... template class ...) 4 | -------------------------------------------------------------------------------- /doc/src/images/portaudio-external-architecture-diagram.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/PortAudio/portaudio/HEAD/doc/src/images/portaudio-external-architecture-diagram.png -------------------------------------------------------------------------------- /bindings/cpp/doc/Makefile.am: -------------------------------------------------------------------------------- 1 | PACPP_ROOT = . 2 | #INCLUDES = -I$(srcdir)/$(PACPP_ROOT)/include -I$(top_srcdir)/include 3 | 4 | docs: 5 | doxygen $(srcdir)/config.doxy.linux 6 | -------------------------------------------------------------------------------- /bindings/cpp/Makefile.am: -------------------------------------------------------------------------------- 1 | SUBDIRS = lib include bin 2 | #doc 3 | 4 | EXTRA_DIST = portaudiocpp.pc 5 | 6 | pkgconfigdir = $(libdir)/pkgconfig 7 | pkgconfig_DATA = portaudiocpp.pc 8 | -------------------------------------------------------------------------------- /bindings/cpp/cmake/PortAudioCppConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/PortAudioCppTargets.cmake") 4 | 5 | check_required_components(PortAudioCpp) 6 | -------------------------------------------------------------------------------- /qa/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_test(paqa_errs) 2 | add_test(paqa_devs) 3 | if(LINK_PRIVATE_SYMBOLS) 4 | add_test(paqa_dither) 5 | endif() 6 | add_test(paqa_latency) 7 | 8 | subdirs(loopback) 9 | -------------------------------------------------------------------------------- /src/hostapi/skeleton/README.txt: -------------------------------------------------------------------------------- 1 | pa_hostapi_skeleton.c provides a starting point for implementing support for a new host API with PortAudio. The idea is that you copy it to a new directory inside /hostapi and start editing. -------------------------------------------------------------------------------- /.github/asiosdk-version.txt: -------------------------------------------------------------------------------- 1 | GitHub Actions uses the hash of this file as the cache key for the ASIO SDK. 2 | Update this file when a new version of the ASIO SDK is released to trigger 3 | a new download on GitHub Actions instead of using the old cache. 4 | 5 | asiosdk_2.3.3_2019-06-14.zip 6 | -------------------------------------------------------------------------------- /portaudio-2.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: PortAudio 7 | Description: Portable audio I/O 8 | Requires: 9 | Version: 19 10 | 11 | Libs: -L${libdir} -lportaudio @LIBS@ 12 | Cflags: -I${includedir} @THREAD_CFLAGS@ 13 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # EditorConfig info: https://editorconfig.org/ 2 | root = true 3 | 4 | [Makefile*] 5 | indent_style = tab 6 | 7 | [*.{c,cpp,h,cxx,hxx}] 8 | indent_style = space 9 | indent_size = 4 10 | charset = utf-8 11 | trim_trailing_whitespace = true 12 | insert_final_newline = true 13 | max_line_length = 120 14 | -------------------------------------------------------------------------------- /bindings/cpp/bin/Makefile.am: -------------------------------------------------------------------------------- 1 | BINDIR = $(top_srcdir)/example 2 | LIBDIR = $(top_builddir)/lib 3 | 4 | noinst_PROGRAMS = devs sine 5 | 6 | LDADD = $(LIBDIR)/libportaudiocpp.la $(top_builddir)/$(PORTAUDIO_ROOT)/lib/libportaudio.la 7 | 8 | devs_SOURCES = $(BINDIR)/devs.cxx 9 | sine_SOURCES = $(BINDIR)/sine.cxx 10 | -------------------------------------------------------------------------------- /bindings/cpp/portaudiocpp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | libdir=@libdir@ 4 | includedir=@includedir@ 5 | 6 | Name: PortAudioCpp 7 | Description: Portable audio I/O C++ bindings 8 | Version: 12 9 | Requires: portaudio-2.0 10 | 11 | Libs: -L${libdir} -lportaudiocpp 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /bindings/cpp/cmake/portaudiocpp.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@PC_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: PortAudioCpp 7 | Description: Portable audio I/O C++ bindings 8 | Version: 12 9 | Requires: portaudio-2.0 10 | 11 | Libs: -L${libdir} -lportaudiocpp 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /clear_gitrevision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Clear the Git commit SHA in the include file. 4 | # This should be run before checking in code to Git. 5 | # 6 | revision_filename=src/common/pa_gitrevision.h 7 | 8 | # Update the include file with the current GIT revision. 9 | echo "#define PA_GIT_REVISION unknown" > ${revision_filename} 10 | 11 | echo ${revision_filename} now contains 12 | cat ${revision_filename} 13 | -------------------------------------------------------------------------------- /cmake/portaudio-2.0.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 4 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 5 | 6 | Name: PortAudio 7 | Description: Portable audio I/O 8 | Version: @CMAKE_PROJECT_VERSION@ 9 | 10 | Libs: -L${libdir} -lportaudio 11 | Libs.private: @PKGCONFIG_LDFLAGS_PRIVATE@ 12 | Cflags: -I${includedir} @PKGCONFIG_CFLAGS@ 13 | Requires.private: @PKGCONFIG_REQUIRES_PRIVATE@ 14 | -------------------------------------------------------------------------------- /.github/workflows/whitelint.yml: -------------------------------------------------------------------------------- 1 | name: Check for valid whitespace usage in PortAudio source files 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | run-pa-whitelint-dot-py: 7 | 8 | runs-on: ubuntu-latest 9 | name: Ubuntu 10 | 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: actions/setup-python@v4 14 | with: 15 | python-version: '3.x' 16 | - name: Run the pa_whitelint.py script 17 | run: python ./pa_whitelint.py 18 | -------------------------------------------------------------------------------- /cmake/PortAudioConfig.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | 3 | include("${CMAKE_CURRENT_LIST_DIR}/PortAudioTargets.cmake") 4 | 5 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules") 6 | 7 | include(CMakeFindDependencyMacro) 8 | 9 | find_dependency(Threads) 10 | 11 | # PA_USE_JACK 12 | if(@PA_USE_JACK@) 13 | find_dependency(Regex) 14 | find_dependency(JACK) 15 | endif() 16 | 17 | # PA_USE_ALSA 18 | if(@PA_USE_ALSA@) 19 | find_dependency(ALSA) 20 | endif() 21 | -------------------------------------------------------------------------------- /.github/workflows/compare_def_files.yml: -------------------------------------------------------------------------------- 1 | name: Check that PortAudio .def files are in sync 2 | 3 | on: [push, pull_request] 4 | 5 | jobs: 6 | run-pa-compare-def-files-py: 7 | 8 | runs-on: ubuntu-latest 9 | name: Ubuntu 10 | 11 | steps: 12 | - uses: actions/checkout@v3 13 | - uses: actions/setup-python@v4 14 | with: 15 | python-version: '3.x' 16 | - name: Run the pa_compare_def_files.py script 17 | run: python ./pa_compare_def_files.py 18 | -------------------------------------------------------------------------------- /src/hostapi/wasapi/mingw-include/propkey.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the PortAudio library. 4 | */ 5 | #ifndef _INC_PROPKEY_PA 6 | #define _INC_PROPKEY_PA 7 | 8 | #ifndef DEFINE_API_PKEY 9 | #define DEFINE_API_PKEY(name, managed_name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) \ 10 | DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) 11 | #endif 12 | 13 | #endif /* _INC_PROPKEY_PA */ 14 | -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/CallbackStream.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/CallbackStream.hxx" 2 | 3 | namespace portaudio 4 | { 5 | CallbackStream::CallbackStream() 6 | { 7 | } 8 | 9 | CallbackStream::~CallbackStream() 10 | { 11 | } 12 | 13 | // ----------------------------------------------------------------------------------- 14 | 15 | double CallbackStream::cpuLoad() const 16 | { 17 | return Pa_GetStreamCpuLoad(stream_); 18 | } 19 | 20 | } // namespace portaudio 21 | -------------------------------------------------------------------------------- /qa/loopback/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(paloopback 2 | src/audio_analyzer.c 3 | src/audio_analyzer.h 4 | src/biquad_filter.c 5 | src/biquad_filter.h 6 | src/paqa.c 7 | src/paqa_tools.c 8 | src/paqa_tools.h 9 | src/qa_tools.h 10 | src/test_audio_analyzer.c 11 | src/test_audio_analyzer.h 12 | src/write_wav.c 13 | src/write_wav.h 14 | ) 15 | target_include_directories(paloopback PRIVATE ..) 16 | target_link_libraries(paloopback portaudio) 17 | if(UNIX) 18 | target_link_libraries(paloopback m) 19 | endif() 20 | -------------------------------------------------------------------------------- /src/hostapi/wasapi/mingw-include/PropIdl.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the PortAudio library. 4 | */ 5 | #ifndef _INC_PROPIDL_PA 6 | #define _INC_PROPIDL_PA 7 | 8 | #ifndef COM_NO_WINDOWS_H 9 | #include "windows.h" 10 | #include "ole2.h" 11 | #endif 12 | 13 | typedef const PROPVARIANT *REFPROPVARIANT; 14 | 15 | #define PropVariantInit(VAR) memset((VAR), 0, sizeof(PROPVARIANT)) 16 | WINOLEAPI PropVariantClear(PROPVARIANT *pvar); 17 | 18 | #endif /* _INC_PROPIDL_PA */ 19 | 20 | -------------------------------------------------------------------------------- /src/hostapi/wasapi/mingw-include/functiondiscoverykeys_devpkey.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the mingw-w64 runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 | */ 6 | #ifndef _INC_FUNCTIONDISCOVERYKEYS 7 | #define _INC_FUNCTIONDISCOVERYKEYS 8 | 9 | #include 10 | 11 | DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0x20, 0x67, 0xd1, 0x46, 0xa8, 0x50, 0xe0, 14); 12 | 13 | #endif /* _INC_FUNCTIONDISCOVERYKEYS */ 14 | -------------------------------------------------------------------------------- /update_gitrevision.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Write the Git commit SHA to an include file. 4 | # This should be run before compiling code on Linux or Macintosh. 5 | # 6 | revision_filename=src/common/pa_gitrevision.h 7 | 8 | # Run git first to make sure it is installed before corrupting the 9 | # include file. 10 | git rev-parse HEAD 11 | 12 | # Update the include file with the current Git revision. 13 | echo -n "#define PA_GIT_REVISION " > ${revision_filename} 14 | git rev-parse HEAD >> ${revision_filename} 15 | 16 | echo ${revision_filename} now contains 17 | cat ${revision_filename} 18 | -------------------------------------------------------------------------------- /doc/src/tutorial/terminating_portaudio.dox: -------------------------------------------------------------------------------- 1 | /** @page terminating_portaudio Closing a Stream and Terminating PortAudio 2 | @ingroup tutorial 3 | 4 | When you are done with a stream, you should close it to free up resources: 5 | 6 | @code 7 | err = Pa_CloseStream( stream ); 8 | if( err != paNoError ) goto error; 9 | @endcode 10 | 11 | We've already mentioned this in \ref initializing_portaudio, but in case you forgot, be sure to terminate PortAudio when you are done: 12 | 13 | @code 14 | err = Pa_Terminate( ); 15 | if( err != paNoError ) goto error; 16 | @endcode 17 | 18 | Previous: \ref start_stop_abort | Next: \ref utility_functions 19 | 20 | */ -------------------------------------------------------------------------------- /msvc/portaudio.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "portaudio"=".\portaudio.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /bindings/cpp/build/vc6/static_library.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "static_library"=".\static_library.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | }}} 15 | 16 | ############################################################################### 17 | 18 | Global: 19 | 20 | Package=<5> 21 | {{{ 22 | }}} 23 | 24 | Package=<3> 25 | {{{ 26 | }}} 27 | 28 | ############################################################################### 29 | 30 | -------------------------------------------------------------------------------- /test/README.md: -------------------------------------------------------------------------------- 1 | # PortAudio Tests 2 | 3 | This directory contains various programs to test PortAudio. The files 4 | named patest_* are tests. 5 | 6 | For more information on the TestPlan please visit: 7 | 8 | https://github.com/PortAudio/portaudio/wiki/TestPlan 9 | 10 | The current status is in: 11 | 12 | https://github.com/PortAudio/portaudio/wiki/TestStatus 13 | 14 | All of the tests are up to date with the V19 API. They should all compile 15 | (without any warnings on GCC 3.3). Note that this does not necessarily mean that 16 | the tests pass, just that they compile. 17 | 18 | Note that Phil Burk deleted the debug_* tests on 2/26/11. They were just hacked 19 | versions of old V18 tests. If we need to debug then we can just hack a working V19 test. 20 | -------------------------------------------------------------------------------- /doc/src/tutorial/exploring.dox: -------------------------------------------------------------------------------- 1 | /** @page exploring Exploring PortAudio 2 | @ingroup tutorial 3 | 4 | Now that you have a good idea of how PortAudio works, you can try out the example programs. You'll find them in the examples/ directory in the PortAudio distribution. 5 | 6 | For an example of playing a sine wave, see examples/paex_sine.c. 7 | 8 | For an example of recording and playing back a sound, see examples/paex_record.c. 9 | 10 | I also encourage you to examine the source for the PortAudio libraries. If you have suggestions on ways to improve them, please let us know. If you want to implement PortAudio on a new platform, please let us know as well so we can coordinate people's efforts. 11 | 12 | 13 | Previous: \ref blocking_read_write | Next: This is the end of the tutorial. 14 | 15 | */ -------------------------------------------------------------------------------- /src/hostapi/wasapi/mingw-include/winapifamily.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the mingw-w64 runtime package. 3 | * No warranty is given; refer to the file DISCLAIMER within this package. 4 | */ 5 | 6 | #ifndef _INC_WINAPIFAMILY 7 | #define _INC_WINAPIFAMILY 8 | 9 | #define WINAPI_PARTITION_DESKTOP 0x1 10 | #define WINAPI_PARTITION_APP 0x2 11 | 12 | #define WINAPI_FAMILY_APP WINAPI_PARTITION_APP 13 | #define WINAPI_FAMILY_DESKTOP_APP (WINAPI_PARTITION_DESKTOP \ 14 | | WINAPI_PARTITION_APP) 15 | 16 | /* WINAPI_FAMILY can be either desktop + App, or App. */ 17 | #ifndef WINAPI_FAMILY 18 | #define WINAPI_FAMILY WINAPI_FAMILY_DESKTOP_APP 19 | #endif 20 | 21 | #define WINAPI_FAMILY_PARTITION(v) ((WINAPI_FAMILY & v) == v) 22 | #define WINAPI_FAMILY_ONE_PARTITION(vset, v) ((WINAPI_FAMILY & vset) == v) 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /test/test_use_cmake/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # This test checks that it is possible to use the 2 | # CMake artifacts generated by the build. 3 | 4 | cmake_minimum_required(VERSION 3.1.0) 5 | project(test_use) 6 | 7 | file(GENERATE 8 | OUTPUT 9 | "${CMAKE_CURRENT_BINARY_DIR}/main.cpp" 10 | CONTENT 11 | [=[ 12 | #include 13 | int main() 14 | { 15 | Pa_Initialize(); 16 | Pa_Terminate(); 17 | } 18 | ]=] 19 | ) 20 | 21 | find_package(PortAudio REQUIRED) 22 | 23 | add_library(test_use_static STATIC "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") 24 | add_library(test_use_shared SHARED "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") 25 | add_executable(test_use_exe "${CMAKE_CURRENT_BINARY_DIR}/main.cpp") 26 | 27 | target_link_libraries(test_use_static PRIVATE portaudio) 28 | target_link_libraries(test_use_shared PRIVATE portaudio) 29 | target_link_libraries(test_use_exe PRIVATE portaudio) 30 | 31 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | *.obj 6 | 7 | # annoying files 8 | **/.DS_Store 9 | 10 | # Generated by configure and make 11 | Makefile 12 | bin-stamp 13 | bin/* 14 | config.log 15 | config.status 16 | lib-stamp 17 | lib/* 18 | libtool 19 | portaudio-2.0.pc 20 | autom4te.cache/* 21 | 22 | # Precompiled Headers 23 | *.gch 24 | *.pch 25 | 26 | # Compiled Dynamic libraries 27 | *.so 28 | *.dylib 29 | *.dll 30 | 31 | # Fortran module files 32 | *.mod 33 | 34 | # Compiled Static libraries 35 | *.lai 36 | *.la 37 | *.a 38 | *.lib 39 | 40 | # Executables 41 | *.exe 42 | *.out 43 | *.app 44 | 45 | # Visual Studio 2017/2019 state folder 46 | .vs/ 47 | 48 | # Visual Studio CMake build output folder 49 | out/ 50 | 51 | # Visual Studio CMake settings file 52 | CMakeSettings.json 53 | 54 | # VSCode 55 | .vscode* 56 | 57 | # Common build directories of users and VSCode 58 | build* 59 | -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/CallbackInterface.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/CallbackInterface.hxx" 2 | 3 | namespace portaudio 4 | { 5 | 6 | namespace impl 7 | { 8 | 9 | ////// 10 | /// Adapts any CallbackInterface object to a C-callable function (ie this function). A 11 | /// pointer to the object should be passed as ``userData'' when setting up the callback. 12 | ////// 13 | int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, 14 | const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) 15 | { 16 | CallbackInterface *cb = static_cast(userData); 17 | return cb->paCallbackFun(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags); 18 | } 19 | 20 | 21 | } // namespace impl 22 | 23 | } // namespace portaudio 24 | -------------------------------------------------------------------------------- /bindings/cpp/include/Makefile.am: -------------------------------------------------------------------------------- 1 | pkginclude_HEADERS = \ 2 | portaudiocpp/AutoSystem.hxx \ 3 | portaudiocpp/BlockingStream.hxx \ 4 | portaudiocpp/CallbackInterface.hxx \ 5 | portaudiocpp/CallbackStream.hxx \ 6 | portaudiocpp/CFunCallbackStream.hxx \ 7 | portaudiocpp/CppFunCallbackStream.hxx \ 8 | portaudiocpp/Device.hxx \ 9 | portaudiocpp/DirectionSpecificStreamParameters.hxx \ 10 | portaudiocpp/Exception.hxx \ 11 | portaudiocpp/HostApi.hxx \ 12 | portaudiocpp/InterfaceCallbackStream.hxx \ 13 | portaudiocpp/MemFunCallbackStream.hxx \ 14 | portaudiocpp/PortAudioCpp.hxx \ 15 | portaudiocpp/SampleDataFormat.hxx \ 16 | portaudiocpp/Stream.hxx \ 17 | portaudiocpp/StreamParameters.hxx \ 18 | portaudiocpp/SystemDeviceIterator.hxx \ 19 | portaudiocpp/SystemHostApiIterator.hxx \ 20 | portaudiocpp/System.hxx 21 | 22 | # portaudiocpp/AsioDeviceAdapter.hxx 23 | -------------------------------------------------------------------------------- /src/hostapi/wasapi/mingw-include/ksguid.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file has no copyright assigned and is placed in the Public Domain. 3 | * This file is part of the w64 mingw-runtime package. 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. 5 | */ 6 | #define INITGUID 7 | #include 8 | 9 | #ifndef DECLSPEC_SELECTANY 10 | #define DECLSPEC_SELECTANY __declspec(selectany) 11 | #endif 12 | 13 | #ifdef DEFINE_GUIDEX 14 | #undef DEFINE_GUIDEX 15 | #endif 16 | 17 | #ifdef __cplusplus 18 | #define DEFINE_GUIDEX(name) EXTERN_C const CDECL GUID DECLSPEC_SELECTANY name = { STATICGUIDOF(name) } 19 | #else 20 | #define DEFINE_GUIDEX(name) const CDECL GUID DECLSPEC_SELECTANY name = { STATICGUIDOF(name) } 21 | #endif 22 | #ifndef STATICGUIDOF 23 | #define STATICGUIDOF(guid) STATIC_##guid 24 | #endif 25 | 26 | #ifndef DEFINE_WAVEFORMATEX_GUID 27 | #define DEFINE_WAVEFORMATEX_GUID(x) (USHORT)(x),0x0000,0x0010,0x80,0x00,0x00,0xaa,0x00,0x38,0x9b,0x71 28 | #endif 29 | -------------------------------------------------------------------------------- /src/hostapi/wasapi/mingw-include/propkeydef.h: -------------------------------------------------------------------------------- 1 | #ifndef PID_FIRST_USABLE 2 | #define PID_FIRST_USABLE 2 3 | #endif 4 | 5 | #ifndef REFPROPERTYKEY 6 | #ifdef __cplusplus 7 | #define REFPROPERTYKEY const PROPERTYKEY & 8 | #else // !__cplusplus 9 | #define REFPROPERTYKEY const PROPERTYKEY * __MIDL_CONST 10 | #endif // __cplusplus 11 | #endif //REFPROPERTYKEY 12 | 13 | #ifdef DEFINE_PROPERTYKEY 14 | #undef DEFINE_PROPERTYKEY 15 | #endif 16 | 17 | #ifdef INITGUID 18 | #define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const PROPERTYKEY DECLSPEC_SELECTANY name = { { l, w1, w2, { b1, b2, b3, b4, b5, b6, b7, b8 } }, pid } 19 | #else 20 | #define DEFINE_PROPERTYKEY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8, pid) EXTERN_C const PROPERTYKEY name 21 | #endif // INITGUID 22 | 23 | #ifndef IsEqualPropertyKey 24 | #define IsEqualPropertyKey(a, b) (((a).pid == (b).pid) && IsEqualIID((a).fmtid, (b).fmtid) ) 25 | #endif // IsEqualPropertyKey 26 | 27 | -------------------------------------------------------------------------------- /README.configure.txt: -------------------------------------------------------------------------------- 1 | PortAudio uses "autoconf" tools to generate Makefiles for Linux and Mac platforms. 2 | The source for these are configure.in and Makefile.in 3 | If you modify either of these files then please run this command before 4 | testing and checking in your changes. I run this command on Linux. 5 | 6 | autoreconf -if 7 | 8 | If you do not have autoreconf then do: 9 | sudo apt-get install autoconf 10 | 11 | If you get error like "possibly undefined macro: AC_LIBTOOL_WIN32_DLL" 12 | then you try installing some more packages and then try again. 13 | 14 | sudo apt-get install build-essential 15 | sudo apt-get install pkg-config 16 | sudo apt-get install libtool 17 | autoreconf -if 18 | 19 | Then test a build by doing: 20 | 21 | ./configure 22 | make clean 23 | make 24 | 25 | then check in the related files that are modified. 26 | These might include files like: 27 | 28 | configure 29 | config.guess 30 | depcomp 31 | install.sh 32 | 33 | -------------------------------------------------------------------------------- /bindings/cpp/build/vc7_1/static_library.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "static_library", "static_library.vcproj", "{D18EA0C9-8C65-441D-884C-55EB43A84F2A}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | EndProjectSection 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfiguration) = preSolution 8 | Debug = Debug 9 | Release = Release 10 | EndGlobalSection 11 | GlobalSection(ProjectConfiguration) = postSolution 12 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Debug.ActiveCfg = Debug|Win32 13 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Debug.Build.0 = Debug|Win32 14 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Release.ActiveCfg = Release|Win32 15 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Release.Build.0 = Release|Win32 16 | EndGlobalSection 17 | GlobalSection(ExtensibilityGlobals) = postSolution 18 | EndGlobalSection 19 | GlobalSection(ExtensibilityAddIns) = postSolution 20 | EndGlobalSection 21 | EndGlobal 22 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior, in case people don't have core.autocrlf set. 2 | * text=auto 3 | 4 | # Explicitly declare text files you want to always be normalized and converted 5 | # to native line endings on checkout. 6 | *.c text 7 | *.h text 8 | *.cpp text 9 | *.hpp text 10 | *.fth text 11 | *.java text 12 | *.f text 13 | *.txt text 14 | *.dox text 15 | *.m text 16 | 17 | # Declare files that will always have CRLF line endings on checkout. 18 | *.sln text eol=crlf 19 | *.def text eol=crlf 20 | *.dsp text eol=crlf 21 | *.dsw text eol=crlf 22 | *.vcproj text eol=crlf 23 | *.sln text eol=crlf 24 | *.doc text eol=crlf 25 | *.bat text eol=crlf 26 | 27 | # Denote all files that are truly binary and should not be modified. 28 | *.dic binary 29 | *.odt binary 30 | *.pdf binary 31 | *.png binary 32 | *.jpg binary 33 | *.wav binary 34 | *.la binary 35 | config.guess binary 36 | config.status binary 37 | config.sub binary 38 | configure binary 39 | depcomp binary 40 | install-sh binary 41 | libtool binary 42 | missing binary 43 | 44 | -------------------------------------------------------------------------------- /bindings/cpp/lib/Makefile.am: -------------------------------------------------------------------------------- 1 | SRCDIR = $(top_srcdir)/source/portaudiocpp 2 | 3 | lib_LTLIBRARIES = libportaudiocpp.la 4 | 5 | LDADD = libportaudiocpp.la 6 | 7 | libportaudiocpp_la_LDFLAGS = -version-info $(LT_VERSION_INFO) -no-undefined 8 | 9 | libportaudiocpp_la_LIBADD = $(top_builddir)/$(PORTAUDIO_ROOT)/lib/libportaudio.la 10 | libportaudiocpp_la_SOURCES = \ 11 | $(SRCDIR)/BlockingStream.cxx \ 12 | $(SRCDIR)/CallbackInterface.cxx \ 13 | $(SRCDIR)/CallbackStream.cxx \ 14 | $(SRCDIR)/CFunCallbackStream.cxx \ 15 | $(SRCDIR)/CppFunCallbackStream.cxx \ 16 | $(SRCDIR)/Device.cxx \ 17 | $(SRCDIR)/DirectionSpecificStreamParameters.cxx \ 18 | $(SRCDIR)/Exception.cxx \ 19 | $(SRCDIR)/HostApi.cxx \ 20 | $(SRCDIR)/InterfaceCallbackStream.cxx \ 21 | $(SRCDIR)/MemFunCallbackStream.cxx \ 22 | $(SRCDIR)/Stream.cxx \ 23 | $(SRCDIR)/StreamParameters.cxx \ 24 | $(SRCDIR)/System.cxx \ 25 | $(SRCDIR)/SystemDeviceIterator.cxx \ 26 | $(SRCDIR)/SystemHostApiIterator.cxx 27 | -------------------------------------------------------------------------------- /bindings/cpp/build/vc6/devs_example.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "devs_example"=".\devs_example.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | Begin Project Dependency 15 | Project_Dep_Name static_library 16 | End Project Dependency 17 | }}} 18 | 19 | ############################################################################### 20 | 21 | Project: "static_library"=".\static_library.dsp" - Package Owner=<4> 22 | 23 | Package=<5> 24 | {{{ 25 | }}} 26 | 27 | Package=<4> 28 | {{{ 29 | }}} 30 | 31 | ############################################################################### 32 | 33 | Global: 34 | 35 | Package=<5> 36 | {{{ 37 | }}} 38 | 39 | Package=<3> 40 | {{{ 41 | }}} 42 | 43 | ############################################################################### 44 | 45 | -------------------------------------------------------------------------------- /bindings/cpp/build/vc6/sine_example.dsw: -------------------------------------------------------------------------------- 1 | Microsoft Developer Studio Workspace File, Format Version 6.00 2 | # WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! 3 | 4 | ############################################################################### 5 | 6 | Project: "sine_example"=".\sine_example.dsp" - Package Owner=<4> 7 | 8 | Package=<5> 9 | {{{ 10 | }}} 11 | 12 | Package=<4> 13 | {{{ 14 | Begin Project Dependency 15 | Project_Dep_Name static_library 16 | End Project Dependency 17 | }}} 18 | 19 | ############################################################################### 20 | 21 | Project: "static_library"=".\static_library.dsp" - Package Owner=<4> 22 | 23 | Package=<5> 24 | {{{ 25 | }}} 26 | 27 | Package=<4> 28 | {{{ 29 | }}} 30 | 31 | ############################################################################### 32 | 33 | Global: 34 | 35 | Package=<5> 36 | {{{ 37 | }}} 38 | 39 | Package=<3> 40 | {{{ 41 | }}} 42 | 43 | ############################################################################### 44 | 45 | -------------------------------------------------------------------------------- /doc/src/tutorial/initializing_portaudio.dox: -------------------------------------------------------------------------------- 1 | /** @page initializing_portaudio Initializing PortAudio 2 | @ingroup tutorial 3 | 4 | @section tut_init1 Initializing PortAudio 5 | 6 | Before making any other calls to PortAudio, you 'must' call Pa_Initialize(). This will trigger a scan of available devices which can be queried later. Like most PA functions, it will return a result of type paError. If the result is not paNoError, then an error has occurred. 7 | @code 8 | err = Pa_Initialize(); 9 | if( err != paNoError ) goto error; 10 | @endcode 11 | 12 | You can get a text message that explains the error message by passing it to Pa_GetErrorText( err ). For Example: 13 | 14 | @code 15 | printf( "PortAudio error: %s\n", Pa_GetErrorText( err ) ); 16 | @endcode 17 | 18 | It is also important, when you are done with PortAudio, to Terminate it: 19 | 20 | @code 21 | err = Pa_Terminate(); 22 | if( err != paNoError ) 23 | printf( "PortAudio error: %s\n", Pa_GetErrorText( err ) ); 24 | @endcode 25 | 26 | 27 | Previous: \ref writing_a_callback | Next: \ref open_default_stream 28 | 29 | */ -------------------------------------------------------------------------------- /qa/loopback/src/biquad_filter.h: -------------------------------------------------------------------------------- 1 | #ifndef _BIQUADFILTER_H 2 | #define _BIQUADFILTER_H 3 | 4 | 5 | /** 6 | * Unit_BiquadFilter implements a second order IIR filter. 7 | * 8 | * @author (C) 2002 Phil Burk, SoftSynth.com, All Rights Reserved 9 | */ 10 | 11 | #define BIQUAD_MIN_RATIO (0.000001) 12 | #define BIQUAD_MIN_Q (0.00001) 13 | 14 | typedef struct BiquadFilter_s 15 | { 16 | double xn1; // storage for delayed signals 17 | double xn2; 18 | double yn1; 19 | double yn2; 20 | 21 | double a0; // coefficients 22 | double a1; 23 | double a2; 24 | 25 | double b1; 26 | double b2; 27 | 28 | double cos_omega; 29 | double sin_omega; 30 | double alpha; 31 | } BiquadFilter; 32 | 33 | void BiquadFilter_SetupHighPass( BiquadFilter *filter, double ratio, double Q ); 34 | void BiquadFilter_SetupNotch( BiquadFilter *filter, double ratio, double Q ); 35 | 36 | void BiquadFilter_Filter( BiquadFilter *filter, float *inputs, float *outputs, int numSamples ); 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/SampleDataFormat.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX 2 | #define INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | // --------------------------------------------------------------------------------------- 9 | 10 | namespace portaudio 11 | { 12 | 13 | 14 | ////// 15 | /// @brief PortAudio sample data formats. 16 | /// 17 | /// Small helper enum to wrap the PortAudio defines. 18 | ////// 19 | enum SampleDataFormat 20 | { 21 | INVALID_FORMAT = 0, 22 | FLOAT32 = paFloat32, 23 | INT32 = paInt32, 24 | INT24 = paInt24, 25 | INT16 = paInt16, 26 | INT8 = paInt8, 27 | UINT8 = paUInt8 28 | }; 29 | 30 | 31 | } // namespace portaudio 32 | 33 | // --------------------------------------------------------------------------------------- 34 | 35 | #endif // INCLUDED_PORTAUDIO_SAMPLEDATAFORMAT_HXX 36 | -------------------------------------------------------------------------------- /src/hostapi/wasapi/readme.txt: -------------------------------------------------------------------------------- 1 | ************** 2 | * WASAPI API * 3 | ************** 4 | 5 | ------------------------------------------- 6 | Microsoft Visual Studio 2005 SP1 and higher 7 | ------------------------------------------- 8 | No specific action is required to compile WASAPI API under Visual Studio. 9 | You are only required to install min. Windows Vista SDK (v6.0A) prior 10 | the compilation. To compile with WASAPI specific functionality for Windows 8 11 | and higher the min. Windows 8 SDK is required. 12 | 13 | ---------------------------------------- 14 | MinGW (GCC 32/64-bit) 15 | ---------------------------------------- 16 | To compile with MinGW you are required to include 'mingw-include' directory 17 | which contains necessary files with WASAPI API. These files are modified 18 | for the compatibility with MinGW compiler. These files are taken from 19 | the Windows Vista SDK (v6.0A). MinGW compilation is tested and proved to be 20 | fully working. 21 | MinGW (32-bit) tested min. version: gcc version 4.4.0 (GCC) 22 | MinGW64 (64-bit) tested min. version: gcc version 4.4.4 20100226 (prerelease) (GCC) -------------------------------------------------------------------------------- /cmake/cmake_uninstall.cmake.in: -------------------------------------------------------------------------------- 1 | if(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 2 | message(FATAL_ERROR "Cannot find install manifest: @CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 3 | endif(NOT EXISTS "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt") 4 | 5 | file(READ "@CMAKE_CURRENT_BINARY_DIR@/install_manifest.txt" files) 6 | string(REGEX REPLACE "\n" ";" files "${files}") 7 | foreach(file ${files}) 8 | message(STATUS "Uninstalling $ENV{DESTDIR}${file}") 9 | if(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 10 | exec_program( 11 | "@CMAKE_COMMAND@" ARGS "-E remove \"$ENV{DESTDIR}${file}\"" 12 | OUTPUT_VARIABLE rm_out 13 | RETURN_VALUE rm_retval 14 | ) 15 | if(NOT "${rm_retval}" STREQUAL 0) 16 | message(FATAL_ERROR "Problem when removing $ENV{DESTDIR}${file}") 17 | endif(NOT "${rm_retval}" STREQUAL 0) 18 | else(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 19 | message(STATUS "File $ENV{DESTDIR}${file} does not exist.") 20 | endif(IS_SYMLINK "$ENV{DESTDIR}${file}" OR EXISTS "$ENV{DESTDIR}${file}") 21 | endforeach(file) 22 | -------------------------------------------------------------------------------- /doc/src/srcguide.dox: -------------------------------------------------------------------------------- 1 | /* 2 | define all of the file groups used to structure the documentation. 3 | */ 4 | 5 | /** 6 | @defgroup public_header Public API definitions for users of PortAudio 7 | */ 8 | 9 | /** 10 | @internal 11 | @defgroup common_src Source code common to all implementations 12 | */ 13 | 14 | /** 15 | @internal 16 | @defgroup win_src Source code common to all Windows implementations 17 | */ 18 | 19 | /** 20 | @internal 21 | @defgroup unix_src Source code common to all Unix implementations 22 | */ 23 | 24 | /** 25 | @internal 26 | @defgroup macosx_src Source code common to all Macintosh implementations 27 | */ 28 | 29 | /** 30 | @internal 31 | @defgroup hostapi_src Source code for specific Host APIs 32 | */ 33 | 34 | /** 35 | @internal 36 | @defgroup test_src Test programs 37 | */ 38 | 39 | /** 40 | @defgroup examples_src Example programs demonstrating PortAudio usage 41 | */ 42 | 43 | /** 44 | @internal 45 | @page srcguide A guide to the PortAudio sources 46 | 47 | - \ref public_header 48 | - \ref examples_src 49 | - \ref common_src 50 | - \ref win_src 51 | - \ref unix_src 52 | - \ref macosx_src 53 | - \ref hostapi_src 54 | - \ref test_src 55 | */ -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | find_package(ASIO) 2 | if(ASIO_FOUND) 3 | set(portaudio-cpp-sources-asio AsioDeviceAdapter.cxx PARENT_SCOPE) 4 | else() 5 | set(portaudio-cpp-sources-asio PARENT_SCOPE) 6 | endif() 7 | 8 | set(portaudio-cpp-sources 9 | ${CMAKE_CURRENT_SOURCE_DIR}/BlockingStream.cxx 10 | ${CMAKE_CURRENT_SOURCE_DIR}/CFunCallbackStream.cxx 11 | ${CMAKE_CURRENT_SOURCE_DIR}/CallbackInterface.cxx 12 | ${CMAKE_CURRENT_SOURCE_DIR}/CallbackStream.cxx 13 | ${CMAKE_CURRENT_SOURCE_DIR}/CppFunCallbackStream.cxx 14 | ${CMAKE_CURRENT_SOURCE_DIR}/Device.cxx 15 | ${CMAKE_CURRENT_SOURCE_DIR}/DirectionSpecificStreamParameters.cxx 16 | ${CMAKE_CURRENT_SOURCE_DIR}/Exception.cxx 17 | ${CMAKE_CURRENT_SOURCE_DIR}/HostApi.cxx 18 | ${CMAKE_CURRENT_SOURCE_DIR}/InterfaceCallbackStream.cxx 19 | ${CMAKE_CURRENT_SOURCE_DIR}/MemFunCallbackStream.cxx 20 | ${CMAKE_CURRENT_SOURCE_DIR}/Stream.cxx 21 | ${CMAKE_CURRENT_SOURCE_DIR}/StreamParameters.cxx 22 | ${CMAKE_CURRENT_SOURCE_DIR}/System.cxx 23 | ${CMAKE_CURRENT_SOURCE_DIR}/SystemDeviceIterator.cxx 24 | ${CMAKE_CURRENT_SOURCE_DIR}/SystemHostApiIterator.cxx 25 | PARENT_SCOPE 26 | ) 27 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/CallbackStream.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX 2 | #define INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | #include "portaudiocpp/Stream.hxx" 9 | 10 | // --------------------------------------------------------------------------------------- 11 | 12 | // Declaration(s): 13 | namespace portaudio 14 | { 15 | 16 | 17 | ////// 18 | /// @brief Base class for all Streams which use a callback-based mechanism. 19 | ////// 20 | class CallbackStream : public Stream 21 | { 22 | protected: 23 | CallbackStream(); 24 | virtual ~CallbackStream(); 25 | 26 | public: 27 | // stream info (time-varying) 28 | double cpuLoad() const; 29 | 30 | private: 31 | CallbackStream(const CallbackStream &); // non-copyable 32 | CallbackStream &operator=(const CallbackStream &); // non-copyable 33 | }; 34 | 35 | 36 | } // namespace portaudio 37 | 38 | // --------------------------------------------------------------------------------------- 39 | 40 | #endif // INCLUDED_PORTAUDIO_CALLBACKSTREAM_HXX 41 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: '' 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | (Please use the mailing list for support requests and general discussion. This is only for actual bugs.) 11 | 12 | **Describe the bug** 13 | A clear and concise description of what the bug is. 14 | 15 | **To Reproduce** 16 | Steps to reproduce the behavior. Include code if applicable. 17 | 1. 18 | 19 | **Expected behavior** 20 | A clear and concise description of what you expected to happen. 21 | 22 | **Actual behavior** 23 | What actually happened. 24 | Include a recording if helpful. 25 | Error messages or logs longer than a page should be attached as a .txt file. 26 | 27 | **Desktop (please complete the following information):** 28 | - OS: [e.g. Mac OS] 29 | - OS Version [e.g. 22] 30 | - PortAudio version: stable, nightly snapshot (which?), current (please give date and/or Git hash): 31 | - If Windows or Linux, which Host API (e.g. WASAPI): 32 | 33 | **Additional context** 34 | Add any other context about the problem here. 35 | 36 | Note: PortAudio is a community supported project. If you have a solution, please create a Pull Request for us to consider. 37 | -------------------------------------------------------------------------------- /bindings/cpp/cmake/modules/FindPortAudio.cmake: -------------------------------------------------------------------------------- 1 | 2 | macro(handle_default) 3 | 4 | endmacro() 5 | 6 | if(TARGET PortAudio::portaudio) 7 | # nothing to do 8 | return() 9 | endif() 10 | # search for portaudio as cmake module 11 | find_package(PortAudio CONFIG QUIET) 12 | if(PortAudio_FOUND) 13 | if(TARGET PortAudio::portaudio) 14 | return() 15 | elseif(TARGET portaudio) 16 | # vcpkg and old portaudio installations do not provide the same targets 17 | add_library(PortAudio::portaudio ALIAS portaudio) 18 | return() 19 | else() 20 | message(FATAL_ERROR "PortAudio_FOUND but not target PortAudio::portaudio") 21 | endif() 22 | endif() 23 | 24 | # search for portaudio via pkg-config 25 | 26 | message(STATUS "portaudio could not be found via cmake, specify PortAudio_DIR.\n Searching for it via pkg-config") 27 | find_package(PkgConfig REQUIRED) 28 | pkg_check_modules(portaudio REQUIRED QUIET IMPORTED_TARGET GLOBAL portaudio-2.0) 29 | add_library(PortAudio::portaudio ALIAS PkgConfig::portaudio) 30 | return() 31 | 32 | # include(FindPackageHandleStandardArgs) 33 | # find_package_handle_standard_args(Foo 34 | # FOUND_VAR Foo_FOUND 35 | # REQUIRED_VARS 36 | # Foo_LIBRARY 37 | # Foo_INCLUDE_DIR 38 | # VERSION_VAR Foo_VERSION 39 | # ) 40 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/AsioDeviceAdapter.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX 2 | #define INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX 3 | 4 | namespace portaudio 5 | { 6 | 7 | // Forward declaration(s): 8 | class Device; 9 | 10 | // Declaration(s): 11 | ////// 12 | /// @brief Adapts the given Device to an ASIO specific extension. 13 | /// 14 | /// Deleting the AsioDeviceAdapter does not affect the underlying 15 | /// Device. 16 | ////// 17 | class AsioDeviceAdapter 18 | { 19 | public: 20 | AsioDeviceAdapter(Device &device); 21 | 22 | Device &device(); 23 | 24 | long minBufferSize() const; 25 | long maxBufferSize() const; 26 | long preferredBufferSize() const; 27 | long granularity() const; 28 | 29 | void showControlPanel(void *systemSpecific); 30 | 31 | const char *inputChannelName(int channelIndex) const; 32 | const char *outputChannelName(int channelIndex) const; 33 | 34 | private: 35 | Device *device_; 36 | 37 | long minBufferSize_; 38 | long maxBufferSize_; 39 | long preferredBufferSize_; 40 | long granularity_; 41 | }; 42 | } 43 | 44 | #endif // INCLUDED_PORTAUDIO_ASIODEVICEADAPTER_HXX 45 | -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/CFunCallbackStream.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/CFunCallbackStream.hxx" 2 | 3 | #include "portaudiocpp/StreamParameters.hxx" 4 | #include "portaudiocpp/Exception.hxx" 5 | 6 | namespace portaudio 7 | { 8 | CFunCallbackStream::CFunCallbackStream() 9 | { 10 | } 11 | 12 | CFunCallbackStream::CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) 13 | { 14 | open(parameters, funPtr, userData); 15 | } 16 | 17 | CFunCallbackStream::~CFunCallbackStream() 18 | { 19 | try 20 | { 21 | close(); 22 | } 23 | catch (...) 24 | { 25 | // ignore all errors 26 | } 27 | } 28 | 29 | // ---------------------------------------------------------------------------------== 30 | 31 | void CFunCallbackStream::open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData) 32 | { 33 | PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), 34 | parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), funPtr, userData); 35 | 36 | if (err != paNoError) 37 | { 38 | throw PaException(err); 39 | } 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/BlockingStream.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX 2 | #define INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudiocpp/Stream.hxx" 7 | 8 | // --------------------------------------------------------------------------------------- 9 | 10 | namespace portaudio 11 | { 12 | 13 | 14 | 15 | ////// 16 | /// @brief Stream class for blocking read/write-style input and output. 17 | ////// 18 | class BlockingStream : public Stream 19 | { 20 | public: 21 | BlockingStream(); 22 | BlockingStream(const StreamParameters ¶meters); 23 | ~BlockingStream(); 24 | 25 | void open(const StreamParameters ¶meters); 26 | 27 | void read(void *buffer, unsigned long numFrames); 28 | void write(const void *buffer, unsigned long numFrames); 29 | 30 | signed long availableReadSize() const; 31 | signed long availableWriteSize() const; 32 | 33 | private: 34 | BlockingStream(const BlockingStream &); // non-copyable 35 | BlockingStream &operator=(const BlockingStream &); // non-copyable 36 | }; 37 | 38 | 39 | 40 | } // portaudio 41 | 42 | // --------------------------------------------------------------------------------------- 43 | 44 | #endif // INCLUDED_PORTAUDIO_BLOCKINGSTREAM_HXX 45 | -------------------------------------------------------------------------------- /bindings/cpp/doc/README: -------------------------------------------------------------------------------- 1 | GNU/Linux: 2 | ---------- 3 | 4 | 1) Download and install a recent version of Doxygen (preferably version 1.3.3 or 5 | later). See http://www.doxygen.org/. 6 | 2) Download and install a recent version of GraphViz. See 7 | http://www.research.att.com/sw/tools/graphviz/. 8 | 3) Run ``doxygen config.doxy.linux'' in this directory or load and generate the file 9 | config.doxy.linux from the Doxywizard application. Or alternatively ``make docs'' can 10 | be run from the build/gnu folder. 11 | 12 | The generated html documentation will be placed in /doc/api_reference/. To open 13 | the main page of the documentation, open the file /doc/api_reference/index.html in 14 | an html browser. 15 | 16 | 17 | Windows: 18 | -------- 19 | 20 | 1) Download and install a recent Doxygen (preferably version 1.3.4 or later). See 21 | http://www.doxygen.org/. 22 | 2) Download and install a recent version of GraphViz. See 23 | http://www.research.att.com/sw/tools/graphviz/. 24 | 3) If needed, edit the config.doxy file in an ascii text editor so that 25 | ``DOT_PATH'' variable points to the folder where GraphViz is installed. 26 | 4) Run ``doxygen config.doxy'' in this directory or load and generate the file 27 | config.doxy from the Doxywizard application. 28 | 29 | The generated html documentation will be placed in /doc/api_reference/. To open 30 | the main page of the documentation, open the file /doc/api_reference/index.html in 31 | an html browser. 32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /vcpkg.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "portaudio", 3 | "version": "19.8", 4 | "description": "PortAudio Portable Cross-platform Audio I/O API PortAudio is a free, cross-platform, open-source, audio I/O library. It lets you write simple audio programs in 'C' or C++ that will compile and run on many platforms including Windows, Macintosh OS X, and Unix (OSS/ALSA). It is intended to promote the exchange of audio software between developers on different platforms. Many applications use PortAudio for Audio I/O.", 5 | "homepage": "http://portaudio.com/", 6 | "license": "MIT", 7 | "supports": "!uwp", 8 | "default-features": [ "jack" ], 9 | "features": { 10 | "jack": { 11 | "description": "Build with support for the JACK Audio Connection Kit host API.", 12 | "dependencies": [ 13 | "jack2", 14 | { 15 | "name": "tre", 16 | "platform": "windows | mingw" 17 | }, 18 | { 19 | "name": "pthreads", 20 | "platform": "windows" 21 | } 22 | ] 23 | }, 24 | "asio": { 25 | "description": "Build with support for ASIO host API on Windows or MinGW. This automatically downloads the ASIO SDK from Steinberg. Review the ASIO SDK license for details https://www.steinberg.net/en/company/developers.html" 26 | } 27 | }, 28 | "dependencies": [ 29 | { 30 | "name": "vcpkg-cmake", 31 | "host": true 32 | }, 33 | { 34 | "name": "vcpkg-cmake-config", 35 | "host": true 36 | } 37 | ] 38 | } 39 | -------------------------------------------------------------------------------- /examples/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Example projects 2 | 3 | macro(add_example appl_name) 4 | add_executable(${appl_name} "${appl_name}.c") 5 | target_link_libraries(${appl_name} portaudio) 6 | if(UNIX) 7 | target_link_libraries(${appl_name} m) 8 | endif() 9 | set_target_properties(${appl_name} PROPERTIES FOLDER "Examples C") 10 | if(WIN32) 11 | set_property(TARGET ${appl_name} APPEND_STRING PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS) 12 | endif() 13 | endmacro() 14 | 15 | macro(add_example_cpp appl_name) 16 | add_executable(${appl_name} "${appl_name}.cpp") 17 | target_link_libraries(${appl_name} portaudio) 18 | set_target_properties(${appl_name} PROPERTIES FOLDER "Examples C++") 19 | if(WIN32) 20 | set_property(TARGET ${appl_name} APPEND_STRING PROPERTY COMPILE_DEFINITIONS _CRT_SECURE_NO_WARNINGS) 21 | endif() 22 | endmacro() 23 | 24 | add_example(pa_devs) 25 | add_example(pa_fuzz) 26 | if(PA_USE_ASIO AND WIN32) 27 | add_example(paex_mono_asio_channel_select) 28 | endif() 29 | if(LINK_PRIVATE_SYMBOLS) 30 | add_example(paex_ocean_shore) 31 | endif() 32 | add_example(paex_pink) 33 | add_example(paex_read_write_wire) 34 | add_example(paex_record) 35 | if(LINK_PRIVATE_SYMBOLS) 36 | add_example(paex_record_file) 37 | endif() 38 | add_example(paex_saw) 39 | add_example(paex_sine) 40 | add_example_cpp(paex_sine_c++) 41 | if(PA_USE_WMME AND WIN32) 42 | add_example(paex_wmme_ac3) 43 | add_example(paex_wmme_surround) 44 | endif() 45 | add_example(paex_write_sine) 46 | add_example(paex_write_sine_nonint) 47 | -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/InterfaceCallbackStream.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/InterfaceCallbackStream.hxx" 2 | 3 | #include "portaudiocpp/StreamParameters.hxx" 4 | #include "portaudiocpp/Exception.hxx" 5 | #include "portaudiocpp/CallbackInterface.hxx" 6 | 7 | namespace portaudio 8 | { 9 | 10 | // ---------------------------------------------------------------------------------== 11 | 12 | InterfaceCallbackStream::InterfaceCallbackStream() 13 | { 14 | } 15 | 16 | InterfaceCallbackStream::InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance) 17 | { 18 | open(parameters, instance); 19 | } 20 | 21 | InterfaceCallbackStream::~InterfaceCallbackStream() 22 | { 23 | try 24 | { 25 | close(); 26 | } 27 | catch (...) 28 | { 29 | // ignore all errors 30 | } 31 | } 32 | 33 | // ---------------------------------------------------------------------------------== 34 | 35 | void InterfaceCallbackStream::open(const StreamParameters ¶meters, CallbackInterface &instance) 36 | { 37 | PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), 38 | parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::callbackInterfaceToPaCallbackAdapter, static_cast(&instance)); 39 | 40 | if (err != paNoError) 41 | { 42 | throw PaException(err); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /bindings/cpp/configure.ac: -------------------------------------------------------------------------------- 1 | # 2 | # PortAudioCpp V19 autoconf input file 3 | # Shamelessly ripped from the PortAudio one by Dominic Mazzoni 4 | # Ludwig Schwardt 5 | # Customized for automake by Mikael Magnusson 6 | # 7 | 8 | # Require autoconf >= 2.69 9 | AC_PREREQ([2.69]) 10 | 11 | m4_define([lt_current], [0]) 12 | m4_define([lt_revision], [12]) 13 | m4_define([lt_age], [0]) 14 | 15 | AC_INIT([PortAudioCpp], [12]) 16 | AC_CONFIG_SRCDIR([include/portaudiocpp/PortAudioCpp.hxx]) 17 | AM_INIT_AUTOMAKE(subdir-objects) 18 | AM_MAINTAINER_MODE 19 | 20 | ###### Top-level directory of pacpp 21 | ###### This makes it easy to shuffle the build directories 22 | ###### Also edit AC_CONFIG_SRCDIR above (wouldn't accept this variable)! 23 | PACPP_ROOT="\$(top_srcdir)" 24 | PORTAUDIO_ROOT="../.." 25 | 26 | # Various other variables and flags 27 | DEFAULT_INCLUDES="-I$PACPP_ROOT/include -I$PACPP_ROOT/$PORTAUDIO_ROOT/include" 28 | CFLAGS=${CFLAGS-"-g -O2 -Wall -ansi -pedantic"} 29 | CXXFLAGS=${CXXFLAGS-"${CFLAGS}"} 30 | 31 | LT_VERSION_INFO="lt_current:lt_revision:lt_age" 32 | 33 | # Checks for programs 34 | 35 | AC_PROG_CC 36 | AC_PROG_CXX 37 | 38 | LT_INIT(win32-dll) 39 | 40 | # Transfer these variables to the Makefile 41 | AC_SUBST(DEFAULT_INCLUDES) 42 | AC_SUBST(PORTAUDIO_ROOT) 43 | AC_SUBST(CXXFLAGS) 44 | AC_SUBST(LT_VERSION_INFO) 45 | 46 | AC_CONFIG_FILES([ 47 | Makefile 48 | lib/Makefile 49 | include/Makefile 50 | bin/Makefile 51 | doc/Makefile 52 | portaudiocpp.pc 53 | ]) 54 | AC_OUTPUT 55 | -------------------------------------------------------------------------------- /bindings/cpp/build/vc7_1/devs_example.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "devs_example", "devs_example.vcproj", "{1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A} = {D18EA0C9-8C65-441D-884C-55EB43A84F2A} 5 | EndProjectSection 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "static_library", "static_library.vcproj", "{D18EA0C9-8C65-441D-884C-55EB43A84F2A}" 8 | ProjectSection(ProjectDependencies) = postProject 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfiguration) = preSolution 13 | Debug = Debug 14 | Release = Release 15 | EndGlobalSection 16 | GlobalSection(ProjectConfiguration) = postSolution 17 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Debug.ActiveCfg = Debug|Win32 18 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Debug.Build.0 = Debug|Win32 19 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Release.ActiveCfg = Release|Win32 20 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Release.Build.0 = Release|Win32 21 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Debug.ActiveCfg = Debug|Win32 22 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Debug.Build.0 = Debug|Win32 23 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Release.ActiveCfg = Release|Win32 24 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Release.Build.0 = Release|Win32 25 | EndGlobalSection 26 | GlobalSection(ExtensibilityGlobals) = postSolution 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityAddIns) = postSolution 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /bindings/cpp/build/vc7_1/sine_example.sln: -------------------------------------------------------------------------------- 1 | Microsoft Visual Studio Solution File, Format Version 8.00 2 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "sine_example", "sine_example.vcproj", "{1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}" 3 | ProjectSection(ProjectDependencies) = postProject 4 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A} = {D18EA0C9-8C65-441D-884C-55EB43A84F2A} 5 | EndProjectSection 6 | EndProject 7 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "static_library", "static_library.vcproj", "{D18EA0C9-8C65-441D-884C-55EB43A84F2A}" 8 | ProjectSection(ProjectDependencies) = postProject 9 | EndProjectSection 10 | EndProject 11 | Global 12 | GlobalSection(SolutionConfiguration) = preSolution 13 | Debug = Debug 14 | Release = Release 15 | EndGlobalSection 16 | GlobalSection(ProjectConfiguration) = postSolution 17 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Debug.ActiveCfg = Debug|Win32 18 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Debug.Build.0 = Debug|Win32 19 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Release.ActiveCfg = Release|Win32 20 | {1B9A038D-80A3-4DBD-9F0D-AF10B49B863A}.Release.Build.0 = Release|Win32 21 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Debug.ActiveCfg = Debug|Win32 22 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Debug.Build.0 = Debug|Win32 23 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Release.ActiveCfg = Release|Win32 24 | {D18EA0C9-8C65-441D-884C-55EB43A84F2A}.Release.Build.0 = Release|Win32 25 | EndGlobalSection 26 | GlobalSection(ExtensibilityGlobals) = postSolution 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityAddIns) = postSolution 29 | EndGlobalSection 30 | EndGlobal 31 | -------------------------------------------------------------------------------- /bindings/cpp/COPYING: -------------------------------------------------------------------------------- 1 | PortAudio Portable Real-Time Audio Library 2 | Copyright (c) 1999-2006 Ross Bencina and Phil Burk 3 | 4 | Permission is hereby granted, free of charge, to any person obtaining 5 | a copy of this software and associated documentation files 6 | (the "Software"), to deal in the Software without restriction, 7 | including without limitation the rights to use, copy, modify, merge, 8 | publish, distribute, sublicense, and/or sell copies of the Software, 9 | and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be 13 | included in all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 16 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 17 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 18 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 19 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 20 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 21 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 22 | 23 | 24 | The text above constitutes the entire PortAudio license; however, 25 | the PortAudio community also makes the following non-binding requests: 26 | 27 | Any person wishing to distribute modifications to the Software is 28 | requested to send the modifications to the original developer so that 29 | they can be incorporated into the canonical version. It is also 30 | requested that these non-binding requests be included along with the 31 | license above. 32 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/InterfaceCallbackStream.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX 2 | #define INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | #include "portaudiocpp/CallbackStream.hxx" 9 | 10 | // --------------------------------------------------------------------------------------- 11 | 12 | // Forward declaration(s) 13 | namespace portaudio 14 | { 15 | class StreamParameters; 16 | class CallbackInterface; 17 | } 18 | 19 | // --------------------------------------------------------------------------------------- 20 | 21 | // Declaration(s): 22 | namespace portaudio 23 | { 24 | 25 | 26 | ////// 27 | /// @brief Callback stream using an instance of an object that's derived from the CallbackInterface 28 | /// interface. 29 | ////// 30 | class InterfaceCallbackStream : public CallbackStream 31 | { 32 | public: 33 | InterfaceCallbackStream(); 34 | InterfaceCallbackStream(const StreamParameters ¶meters, CallbackInterface &instance); 35 | ~InterfaceCallbackStream(); 36 | 37 | void open(const StreamParameters ¶meters, CallbackInterface &instance); 38 | 39 | private: 40 | InterfaceCallbackStream(const InterfaceCallbackStream &); // non-copyable 41 | InterfaceCallbackStream &operator=(const InterfaceCallbackStream &); // non-copyable 42 | }; 43 | 44 | 45 | } // portaudio 46 | 47 | // --------------------------------------------------------------------------------------- 48 | 49 | #endif // INCLUDED_PORTAUDIO_INTERFACECALLBACKSTREAM_HXX 50 | -------------------------------------------------------------------------------- /doc/src/license.dox: -------------------------------------------------------------------------------- 1 | /** @page License PortAudio License 2 | 3 | PortAudio Portable Real-Time Audio Library
4 | Copyright (c) 1999-2011 Ross Bencina, Phil Burk 5 | 6 | 7 | 8 | Permission is hereby granted, free of charge, to any person obtaining 9 | a copy of this software and associated documentation files 10 | (the "Software"), to deal in the Software without restriction, 11 | including without limitation the rights to use, copy, modify, merge, 12 | publish, distribute, sublicense, and/or sell copies of the Software, 13 | and to permit persons to whom the Software is furnished to do so, 14 | subject to the following conditions: 15 | 16 | The above copyright notice and this permission notice shall be 17 | included in all copies or substantial portions of the Software. 18 | 19 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 23 | ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 | CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | 27 |
28 | 29 | The text above constitutes the entire PortAudio license; however, 30 | the PortAudio community also makes the following non-binding requests: 31 | 32 | Any person wishing to distribute modifications to the Software is 33 | requested to send the modifications to the original developer so that 34 | they can be incorporated into the canonical version. It is also 35 | requested that these non-binding requests be included along with the 36 | license above. 37 | 38 | */ -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/SystemDeviceIterator.hxx" 2 | 3 | namespace portaudio 4 | { 5 | // ----------------------------------------------------------------------------------- 6 | 7 | Device &System::DeviceIterator::operator*() const 8 | { 9 | return **ptr_; 10 | } 11 | 12 | Device *System::DeviceIterator::operator->() const 13 | { 14 | return &**this; 15 | } 16 | 17 | // ----------------------------------------------------------------------------------- 18 | 19 | System::DeviceIterator &System::DeviceIterator::operator++() 20 | { 21 | ++ptr_; 22 | return *this; 23 | } 24 | 25 | System::DeviceIterator System::DeviceIterator::operator++(int) 26 | { 27 | System::DeviceIterator prev = *this; 28 | ++*this; 29 | return prev; 30 | } 31 | 32 | System::DeviceIterator &System::DeviceIterator::operator--() 33 | { 34 | --ptr_; 35 | return *this; 36 | } 37 | 38 | System::DeviceIterator System::DeviceIterator::operator--(int) 39 | { 40 | System::DeviceIterator prev = *this; 41 | --*this; 42 | return prev; 43 | } 44 | 45 | // ----------------------------------------------------------------------------------- 46 | 47 | bool System::DeviceIterator::operator==(const System::DeviceIterator &rhs) const 48 | { 49 | return (ptr_ == rhs.ptr_); 50 | } 51 | 52 | bool System::DeviceIterator::operator!=(const System::DeviceIterator &rhs) const 53 | { 54 | return !(*this == rhs); 55 | } 56 | 57 | // ----------------------------------------------------------------------------------- 58 | } // namespace portaudio 59 | -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/SystemHostApiIterator.hxx" 2 | 3 | namespace portaudio 4 | { 5 | // ----------------------------------------------------------------------------------- 6 | 7 | HostApi &System::HostApiIterator::operator*() const 8 | { 9 | return **ptr_; 10 | } 11 | 12 | HostApi *System::HostApiIterator::operator->() const 13 | { 14 | return &**this; 15 | } 16 | 17 | // ----------------------------------------------------------------------------------- 18 | 19 | System::HostApiIterator &System::HostApiIterator::operator++() 20 | { 21 | ++ptr_; 22 | return *this; 23 | } 24 | 25 | System::HostApiIterator System::HostApiIterator::operator++(int) 26 | { 27 | System::HostApiIterator prev = *this; 28 | ++*this; 29 | return prev; 30 | } 31 | 32 | System::HostApiIterator &System::HostApiIterator::operator--() 33 | { 34 | --ptr_; 35 | return *this; 36 | } 37 | 38 | System::HostApiIterator System::HostApiIterator::operator--(int) 39 | { 40 | System::HostApiIterator prev = *this; 41 | --*this; 42 | return prev; 43 | } 44 | 45 | // ----------------------------------------------------------------------------------- 46 | 47 | bool System::HostApiIterator::operator==(const System::HostApiIterator &rhs) const 48 | { 49 | return (ptr_ == rhs.ptr_); 50 | } 51 | 52 | bool System::HostApiIterator::operator!=(const System::HostApiIterator &rhs) const 53 | { 54 | return !(*this == rhs); 55 | } 56 | 57 | // ----------------------------------------------------------------------------------- 58 | } // namespace portaudio 59 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/CallbackInterface.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX 2 | #define INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | // --------------------------------------------------------------------------------------- 9 | 10 | namespace portaudio 11 | { 12 | // ----------------------------------------------------------------------------------- 13 | 14 | ////// 15 | /// @brief Interface for an object that's callable as a PortAudioCpp callback object (ie that implements the 16 | /// paCallbackFun method). 17 | ////// 18 | class CallbackInterface 19 | { 20 | public: 21 | virtual ~CallbackInterface() {} 22 | 23 | virtual int paCallbackFun(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, 24 | const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags) = 0; 25 | }; 26 | 27 | // ----------------------------------------------------------------------------------- 28 | 29 | namespace impl 30 | { 31 | extern "C" 32 | { 33 | int callbackInterfaceToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, 34 | const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, 35 | void *userData); 36 | } // extern "C" 37 | } 38 | 39 | // ----------------------------------------------------------------------------------- 40 | 41 | } // namespace portaudio 42 | 43 | // --------------------------------------------------------------------------------------- 44 | 45 | #endif // INCLUDED_PORTAUDIO_CALLBACKINTERFACE_HXX 46 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/CFunCallbackStream.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX 2 | #define INCLUDED_PORTAUDIO_CFUNCALLBACKSTREAM_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | #include "portaudiocpp/CallbackStream.hxx" 9 | 10 | // --------------------------------------------------------------------------------------- 11 | 12 | // Forward declaration(s) 13 | namespace portaudio 14 | { 15 | class StreamParameters; 16 | } 17 | 18 | // --------------------------------------------------------------------------------------- 19 | 20 | // Declaration(s): 21 | namespace portaudio 22 | { 23 | // ----------------------------------------------------------------------------------- 24 | 25 | ////// 26 | /// @brief Callback stream using a free function with C linkage. It's important that the function 27 | /// the passed function pointer points to is declared ``extern "C"''. 28 | ////// 29 | class CFunCallbackStream : public CallbackStream 30 | { 31 | public: 32 | CFunCallbackStream(); 33 | CFunCallbackStream(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); 34 | ~CFunCallbackStream(); 35 | 36 | void open(const StreamParameters ¶meters, PaStreamCallback *funPtr, void *userData); 37 | 38 | private: 39 | CFunCallbackStream(const CFunCallbackStream &); // non-copyable 40 | CFunCallbackStream &operator=(const CFunCallbackStream &); // non-copyable 41 | }; 42 | 43 | // ----------------------------------------------------------------------------------- 44 | } // portaudio 45 | 46 | // --------------------------------------------------------------------------------------- 47 | 48 | #endif // INCLUDED_PORTAUDIO_MEMFUNCALLBACKSTREAM_HXX 49 | -------------------------------------------------------------------------------- /cmake/modules/FindOSS.cmake: -------------------------------------------------------------------------------- 1 | #[=======================================================================[.rst: 2 | FindOSS 3 | -------- 4 | 5 | Finds the Open Sound System include directory. There is no library to link. 6 | 7 | Imported Targets 8 | ^^^^^^^^^^^^^^^^ 9 | 10 | This module provides the following imported targets, if found: 11 | 12 | ``OSS::oss`` 13 | Target for the OSS header include directory. One of the following 14 | compile definitions is added to the target: 15 | HAVE_SYS_SOUNDCARD_H if the header is sys/soundcard.h 16 | HAVE_LINUX_SOUNDCARD_H if the header is linux/soundcard.h 17 | HAVE_MACHINE_SOUNDCARD_H if the header is machine/soundcard.h 18 | 19 | #]=======================================================================] 20 | 21 | find_path(OSS_INCLUDE_DIR 22 | NAMES sys/soundcard.h 23 | DOC "OSS include directory") 24 | if(OSS_INCLUDE_DIR) 25 | set(OSS_DEFINITIONS HAVE_SYS_SOUNDCARD_H) 26 | else() 27 | find_path(OSS_INCLUDE_DIR 28 | NAMES linux/soundcard.h 29 | DOC "OSS include directory") 30 | if(OSS_INCLUDE_DIR) 31 | set(OSS_DEFINITIONS HAVE_LINUX_SOUNDCARD_H) 32 | else() 33 | find_path(OSS_INCLUDE_DIR 34 | NAMES machine/soundcard.h 35 | DOC "OSS include directory") 36 | if(OSS_INCLUDE_DIR) 37 | set(OSS_DEFINITIONS HAVE_MACHINE_SOUNDCARD_H) 38 | endif() 39 | endif() 40 | endif() 41 | 42 | include(FindPackageHandleStandardArgs) 43 | find_package_handle_standard_args( 44 | OSS 45 | DEFAULT_MSG 46 | OSS_INCLUDE_DIR 47 | OSS_DEFINITIONS 48 | ) 49 | 50 | if(OSS_INCLUDE_DIR AND OSS_DEFINITIONS) 51 | set(OSS_FOUND TRUE) 52 | if(NOT TARGET OSS::oss) 53 | add_library(OSS::oss INTERFACE IMPORTED) 54 | target_include_directories(OSS::oss INTERFACE "${OSS_INCLUDE_DIR}") 55 | target_compile_definitions(OSS::oss INTERFACE "${OSS_DEFINITIONS}") 56 | endif() 57 | endif() 58 | -------------------------------------------------------------------------------- /msvc/portaudio.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 9.00 3 | # Visual Studio 2005 4 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "portaudio", "portaudio.vcproj", "{0A18A071-125E-442F-AFF7-A3F68ABECF99}" 5 | EndProject 6 | Global 7 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 8 | Debug|Win32 = Debug|Win32 9 | Debug|x64 = Debug|x64 10 | Release|Win32 = Release|Win32 11 | Release|x64 = Release|x64 12 | ReleaseMinDependency|Win32 = ReleaseMinDependency|Win32 13 | ReleaseMinDependency|x64 = ReleaseMinDependency|x64 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.ActiveCfg = Debug|Win32 17 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|Win32.Build.0 = Debug|Win32 18 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.ActiveCfg = Debug|x64 19 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Debug|x64.Build.0 = Debug|x64 20 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.ActiveCfg = Release|Win32 21 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|Win32.Build.0 = Release|Win32 22 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.ActiveCfg = Release|x64 23 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.Release|x64.Build.0 = Release|x64 24 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseMinDependency|Win32.ActiveCfg = ReleaseMinDependency|Win32 25 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseMinDependency|Win32.Build.0 = ReleaseMinDependency|Win32 26 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseMinDependency|x64.ActiveCfg = ReleaseMinDependency|x64 27 | {0A18A071-125E-442F-AFF7-A3F68ABECF99}.ReleaseMinDependency|x64.Build.0 = ReleaseMinDependency|x64 28 | EndGlobalSection 29 | GlobalSection(SolutionProperties) = preSolution 30 | HideSolutionNode = FALSE 31 | EndGlobalSection 32 | EndGlobal 33 | -------------------------------------------------------------------------------- /src/hostapi/wasapi/mingw-include/AudioSessionTypes.h: -------------------------------------------------------------------------------- 1 | /** 2 | * This file is part of the mingw-w64 runtime package. 3 | * No warranty is given; refer to the file DISCLAIMER within this package. 4 | */ 5 | 6 | #include 7 | 8 | #ifndef __AUDIOSESSIONTYPES__ 9 | #define __AUDIOSESSIONTYPES__ 10 | 11 | #if WINAPI_FAMILY_PARTITION (WINAPI_PARTITION_APP) 12 | #if defined (__WIDL__) 13 | #define MIDL_SIZE_IS(x) [size_is (x)] 14 | #define MIDL_STRING [string] 15 | #define MIDL_ANYSIZE_ARRAY 16 | #else 17 | #define MIDL_SIZE_IS(x) 18 | #define MIDL_STRING 19 | #define MIDL_ANYSIZE_ARRAY ANYSIZE_ARRAY 20 | #endif 21 | 22 | typedef enum _AudioSessionState { 23 | AudioSessionStateInactive = 0, 24 | AudioSessionStateActive = 1, 25 | AudioSessionStateExpired = 2 26 | } AudioSessionState; 27 | 28 | typedef enum _AUDCLNT_SHAREMODE { 29 | AUDCLNT_SHAREMODE_SHARED, 30 | AUDCLNT_SHAREMODE_EXCLUSIVE 31 | } AUDCLNT_SHAREMODE; 32 | 33 | typedef enum _AUDIO_STREAM_CATEGORY { 34 | AudioCategory_Other = 0, 35 | AudioCategory_ForegroundOnlyMedia, 36 | AudioCategory_BackgroundCapableMedia, 37 | AudioCategory_Communications, 38 | AudioCategory_Alerts, 39 | AudioCategory_SoundEffects, 40 | AudioCategory_GameEffects, 41 | AudioCategory_GameMedia, 42 | AudioCategory_GameChat, 43 | AudioCategory_Speech, 44 | AudioCategory_Movie, 45 | AudioCategory_Media 46 | } AUDIO_STREAM_CATEGORY; 47 | 48 | #define AUDCLNT_STREAMFLAGS_CROSSPROCESS 0x00010000 49 | #define AUDCLNT_STREAMFLAGS_LOOPBACK 0x00020000 50 | #define AUDCLNT_STREAMFLAGS_EVENTCALLBACK 0x00040000 51 | #define AUDCLNT_STREAMFLAGS_NOPERSIST 0x00080000 52 | #define AUDCLNT_STREAMFLAGS_RATEADJUST 0x00100000 53 | #define AUDCLNT_SESSIONFLAGS_EXPIREWHENUNOWNED 0x10000000 54 | #define AUDCLNT_SESSIONFLAGS_DISPLAY_HIDE 0x20000000 55 | #define AUDCLNT_SESSIONFLAGS_DISPLAY_HIDEWHENEXPIRED 0x40000000 56 | 57 | #endif 58 | #endif 59 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX 2 | #define INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include 7 | #include 8 | 9 | #include "portaudiocpp/System.hxx" 10 | 11 | // --------------------------------------------------------------------------------------- 12 | 13 | // Forward declaration(s): 14 | namespace portaudio 15 | { 16 | class HostApi; 17 | } 18 | 19 | // --------------------------------------------------------------------------------------- 20 | 21 | // Declaration(s): 22 | namespace portaudio 23 | { 24 | 25 | 26 | ////// 27 | /// @brief Iterator class for iterating through all HostApis in a System. 28 | /// 29 | /// Compliant with the STL bidirectional iterator concept. 30 | ////// 31 | class System::HostApiIterator 32 | { 33 | public: 34 | typedef std::bidirectional_iterator_tag iterator_category; 35 | typedef Device value_type; 36 | typedef ptrdiff_t difference_type; 37 | typedef HostApi * pointer; 38 | typedef HostApi & reference; 39 | 40 | HostApi &operator*() const; 41 | HostApi *operator->() const; 42 | 43 | HostApiIterator &operator++(); 44 | HostApiIterator operator++(int); 45 | HostApiIterator &operator--(); 46 | HostApiIterator operator--(int); 47 | 48 | bool operator==(const HostApiIterator &rhs) const; 49 | bool operator!=(const HostApiIterator &rhs) const; 50 | 51 | private: 52 | friend class System; 53 | HostApi **ptr_; 54 | }; 55 | 56 | 57 | } // namespace portaudio 58 | 59 | // --------------------------------------------------------------------------------------- 60 | 61 | #endif // INCLUDED_PORTAUDIO_SYSTEMHOSTAPIITERATOR_HXX 62 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Test projects 2 | # Use the macro to add test projects 3 | 4 | add_test(pa_minlat) 5 | add_test(patest1) 6 | add_test(patest_buffer) 7 | add_test(patest_callbackstop) 8 | add_test(patest_clip) 9 | if(LINK_PRIVATE_SYMBOLS) 10 | add_test(patest_converters) 11 | endif() 12 | add_test(patest_dither) 13 | if(PA_USE_DS) 14 | add_test(patest_dsound_find_best_latency_params) 15 | add_test(patest_dsound_low_level_latency_params) 16 | add_test(patest_dsound_surround) 17 | endif() 18 | add_test(patest_hang) 19 | add_test(patest_in_overflow) 20 | if(PA_USE_WASAPI) 21 | add_test(patest_jack_wasapi) 22 | add_test(patest_wasapi_ac3) 23 | add_test(patest_wasapi_eac3) 24 | add_test(patest_read_write_wire_wasapi) 25 | add_test(patest_read_record_wasapi) 26 | endif() 27 | add_test(patest_latency) 28 | add_test(patest_leftright) 29 | add_test(patest_long_record) 30 | add_test(patest_longsine) 31 | add_test(patest_many) 32 | add_test(patest_maxsines) 33 | add_test(patest_mono) 34 | add_test(patest_multi_sine) 35 | add_test(patest_out_underflow) 36 | add_test(patest_prime) 37 | add_test(patest_read_record) 38 | add_test(patest_ringmix) 39 | add_test(patest_sine8) 40 | add_test(patest_sine_channelmaps) 41 | add_test(patest_sine_formats) 42 | add_test(patest_sine_srate) 43 | add_test(patest_sine_time) 44 | add_test(patest_start_stop) 45 | add_test(patest_stop) 46 | add_test(patest_stop_playout) 47 | add_test(patest_suggested_vs_streaminfo_latency) 48 | if(LINK_PRIVATE_SYMBOLS) 49 | add_test(patest_sync) 50 | endif() 51 | add_test(patest_timing) 52 | add_test(patest_toomanysines) 53 | add_test(patest_two_rates) 54 | add_test(patest_underflow) 55 | add_test(patest_unplug) 56 | add_test(patest_wire) 57 | if(PA_USE_WMME) 58 | add_test(patest_wmme_find_best_latency_params) 59 | add_test(patest_wmme_low_level_latency_params) 60 | endif() 61 | add_test(patest_write_stop) 62 | if(UNIX) 63 | add_test(patest_write_stop_hang_illegal) 64 | endif() 65 | add_test(patest_enumerate_default_latency) 66 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/AutoSystem.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX 2 | #define INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudiocpp/System.hxx" 7 | 8 | // --------------------------------------------------------------------------------------- 9 | 10 | namespace portaudio 11 | { 12 | 13 | 14 | ////// 15 | /// @brief A RAII idiom class to ensure automatic clean-up when an exception is 16 | /// raised. 17 | /// 18 | /// A simple helper class which uses the 'Resource Acquisition is Initialization' 19 | /// idiom (RAII). Use this class to initialize/terminate the System rather than 20 | /// using System directly. AutoSystem must be created on stack and must be valid 21 | /// throughout the time you wish to use PortAudioCpp. Your 'main' function might be 22 | /// a good place for it. 23 | /// 24 | /// To avoid having to type portaudio::System::instance().xyz() all the time, it's usually 25 | /// a good idea to make a reference to the System which can be accessed directly. 26 | /// @verbatim 27 | /// portaudio::AutoSys autoSys; 28 | /// portaudio::System &sys = portaudio::System::instance(); 29 | /// @endverbatim 30 | ////// 31 | class AutoSystem 32 | { 33 | public: 34 | AutoSystem(bool initialize = true) 35 | { 36 | if (initialize) 37 | System::initialize(); 38 | } 39 | 40 | ~AutoSystem() 41 | { 42 | if (System::exists()) 43 | System::terminate(); 44 | } 45 | 46 | void initialize() 47 | { 48 | System::initialize(); 49 | } 50 | 51 | void terminate() 52 | { 53 | System::terminate(); 54 | } 55 | }; 56 | 57 | 58 | } // namespace portaudio 59 | 60 | // --------------------------------------------------------------------------------------- 61 | 62 | #endif // INCLUDED_PORTAUDIO_AUTOSYSTEM_HXX 63 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX 2 | #define INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include 7 | #include 8 | 9 | #include "portaudiocpp/System.hxx" 10 | 11 | // --------------------------------------------------------------------------------------- 12 | 13 | // Forward declaration(s): 14 | namespace portaudio 15 | { 16 | class Device; 17 | class HostApi; 18 | } 19 | 20 | // --------------------------------------------------------------------------------------- 21 | 22 | // Declaration(s): 23 | namespace portaudio 24 | { 25 | 26 | 27 | ////// 28 | /// @brief Iterator class for iterating through all Devices in a System. 29 | /// 30 | /// Devices will be iterated by iterating all Devices in each 31 | /// HostApi in the System. Compliant with the STL bidirectional 32 | /// iterator concept. 33 | ////// 34 | class System::DeviceIterator 35 | { 36 | public: 37 | typedef std::bidirectional_iterator_tag iterator_category; 38 | typedef Device value_type; 39 | typedef ptrdiff_t difference_type; 40 | typedef Device * pointer; 41 | typedef Device & reference; 42 | 43 | Device &operator*() const; 44 | Device *operator->() const; 45 | 46 | DeviceIterator &operator++(); 47 | DeviceIterator operator++(int); 48 | DeviceIterator &operator--(); 49 | DeviceIterator operator--(int); 50 | 51 | bool operator==(const DeviceIterator &rhs) const; 52 | bool operator!=(const DeviceIterator &rhs) const; 53 | 54 | private: 55 | friend class System; 56 | friend class HostApi; 57 | Device **ptr_; 58 | }; 59 | 60 | 61 | } // namespace portaudio 62 | 63 | // --------------------------------------------------------------------------------------- 64 | 65 | #endif // INCLUDED_PORTAUDIO_SYSTEMDEVICEITERATOR_HXX 66 | -------------------------------------------------------------------------------- /qa/loopback/src/test_audio_analyzer.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * PortAudio Portable Real-Time Audio Library 4 | * Latest Version at: http://www.portaudio.com 5 | * 6 | * Copyright (c) 1999-2010 Phil Burk and Ross Bencina 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files 10 | * (the "Software"), to deal in the Software without restriction, 11 | * including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, 13 | * and to permit persons to whom the Software is furnished to do so, 14 | * subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 23 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | /* 29 | * The text above constitutes the entire PortAudio license; however, 30 | * the PortAudio community also makes the following non-binding requests: 31 | * 32 | * Any person wishing to distribute modifications to the Software is 33 | * requested to send the modifications to the original developer so that 34 | * they can be incorporated into the canonical version. It is also 35 | * requested that these non-binding requests be included along with the 36 | * license above. 37 | */ 38 | 39 | #ifndef _TEST_AUDIO_ANALYZER_H 40 | #define _TEST_AUDIO_ANALYZER_H 41 | 42 | /** Test the audio analyzer by itself without any PortAudio calls. */ 43 | int PaQa_TestAnalyzer( void ); 44 | 45 | 46 | #endif /* _TEST_AUDIO_ANALYZER_H */ 47 | -------------------------------------------------------------------------------- /cmake/modules/FindJACK.cmake: -------------------------------------------------------------------------------- 1 | #[=======================================================================[.rst: 2 | FindJACK 3 | -------- 4 | 5 | Finds the JACK Audio Connection Kit library. 6 | 7 | Imported Targets 8 | ^^^^^^^^^^^^^^^^ 9 | 10 | This module provides the following imported targets, if found: 11 | 12 | ``JACK::jack`` 13 | The JACK library 14 | 15 | #]=======================================================================] 16 | 17 | # Prefer finding the libraries from pkgconfig rather than find_library. This is 18 | # required to build with PipeWire's reimplementation of the JACK library. 19 | # 20 | # This also enables using PortAudio with the jack2 port in vcpkg. That only 21 | # builds JackWeakAPI (not the JACK server) which dynamically loads the real 22 | # JACK library and forwards API calls to it. JackWeakAPI requires linking `dl` 23 | # in addition to jack, as specified in the pkgconfig file in vcpkg. 24 | find_package(PkgConfig QUIET) 25 | if(PkgConfig_FOUND) 26 | pkg_check_modules(JACK jack) 27 | else() 28 | find_library(JACK_LINK_LIBRARIES 29 | NAMES jack 30 | DOC "JACK library" 31 | ) 32 | find_path(JACK_INCLUDEDIR 33 | NAMES jack/jack.h 34 | DOC "JACK header" 35 | ) 36 | endif() 37 | 38 | find_package(Regex) 39 | list(APPEND JACK_LINK_LIBRARIES Regex::regex) 40 | 41 | if(NOT CMAKE_USE_PTHREADS_INIT) 42 | # This CMake find module is provided by the pthreads port in vcpkg. 43 | find_package(pthreads QUIET) 44 | if(pthreads_FOUND) 45 | list(APPEND JACK_LINK_LIBRARIES PThreads4W::PThreads4W) 46 | endif() 47 | endif() 48 | 49 | if(CMAKE_USE_PTHREADS_INIT OR TARGET PThreads4W::PThreads4W) 50 | set(PTHREADS_AVAILABLE TRUE) 51 | else() 52 | set(PTHREADS_AVAILABLE FALSE) 53 | endif() 54 | 55 | include(FindPackageHandleStandardArgs) 56 | find_package_handle_standard_args( 57 | JACK 58 | DEFAULT_MSG 59 | JACK_LINK_LIBRARIES 60 | JACK_INCLUDEDIR 61 | PTHREADS_AVAILABLE 62 | Regex_FOUND 63 | ) 64 | 65 | if(JACK_FOUND AND NOT TARGET JACK::jack) 66 | add_library(JACK::jack INTERFACE IMPORTED) 67 | target_link_libraries(JACK::jack INTERFACE "${JACK_LINK_LIBRARIES}" Regex::regex) 68 | target_include_directories(JACK::jack INTERFACE "${JACK_INCLUDEDIR}") 69 | endif() 70 | -------------------------------------------------------------------------------- /doc/src/tutorial/compile_windows_mingw.dox: -------------------------------------------------------------------------------- 1 | /** @page compile_windows_mingw Building Portaudio for Windows with MinGW 2 | @ingroup tutorial 3 | 4 | @section comp_mingw1 Portaudio for Windows With MinGW 5 | 6 | This document contains old or out-of-date information. Please see 7 | a draft of new MinGW information on our 8 | Wiki: 9 | PortAudio Wiki: Notes about building PortAudio with MinGW 10 | If you are new to MinGW, consider MinGW-64: \ref compile_windows_mingw-w64. It is a newer project. 11 | 12 | = MinGW/MSYS = 13 | 14 | From the [http://www.mingw.org MinGW projectpage]: 15 | 16 | MinGW: A collection of freely available and freely distributable 17 | Windows specific header files and import libraries, augmenting 18 | the GNU Compiler Collection, (GCC), and its associated 19 | tools, (GNU binutils). MinGW provides a complete Open Source 20 | programming tool set which is suitable for the development of 21 | native Windows programs that do not depend on any 3rd-party C 22 | runtime DLLs. 23 | 24 | MSYS: A Minimal SYStem providing a POSIX compatible Bourne shell 25 | environment, with a small collection of UNIX command line 26 | tools. Primarily developed as a means to execute the configure 27 | scripts and Makefiles used to build Open Source software, but 28 | also useful as a general purpose command line interface to 29 | replace Windows cmd.exe. 30 | 31 | MinGW provides a compiler/linker toolchain while MSYS is required 32 | to actually run the PortAudio configure script. 33 | 34 | Once MinGW and MSYS are installed (see the [http://www.mingw.org/MinGWiki MinGW-Wiki]) open an MSYS shell and run the famous: 35 | 36 | @code 37 | ./configure 38 | make 39 | make install 40 | @endcode 41 | 42 | The above should create a working version though you might want to 43 | provide '--prefix=' to configure. 44 | 45 | './configure --help' gives details as to what can be tinkered with. 46 | 47 | --- Mikael Magnusson 48 | 49 | To update your copy or check out a fresh copy of the source 50 | 51 | [wiki:UsingThePortAudioSvnRepository SVN instructions] 52 | 53 | --- Bob !McGwier 54 | 55 | Back to the Tutorial: \ref tutorial_start 56 | 57 | */ 58 | -------------------------------------------------------------------------------- /qa/loopback/src/paqa_tools.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * PortAudio Portable Real-Time Audio Library 4 | * Latest Version at: http://www.portaudio.com 5 | * 6 | * Copyright (c) 1999-2010 Phil Burk and Ross Bencina 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files 10 | * (the "Software"), to deal in the Software without restriction, 11 | * including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, 13 | * and to permit persons to whom the Software is furnished to do so, 14 | * subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 23 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | /* 29 | * The text above constitutes the entire PortAudio license; however, 30 | * the PortAudio community also makes the following non-binding requests: 31 | * 32 | * Any person wishing to distribute modifications to the Software is 33 | * requested to send the modifications to the original developer so that 34 | * they can be incorporated into the canonical version. It is also 35 | * requested that these non-binding requests be included along with the 36 | * license above. 37 | */ 38 | 39 | #ifndef _PAQA_TOOLS_H 40 | #define _PAQA_TOOLS_H 41 | 42 | 43 | #include 44 | #include "portaudio.h" 45 | 46 | void PaQa_ListAudioDevices(void); 47 | 48 | void PaQa_ConvertToFloat( const void *input, int numSamples, PaSampleFormat inFormat, float *output ); 49 | 50 | void PaQa_ConvertFromFloat( const float *input, int numSamples, PaSampleFormat outFormat, void *output ); 51 | 52 | #endif /* _PAQA_TOOLS_H */ 53 | -------------------------------------------------------------------------------- /bindings/cpp/build/gnu/aclocal.m4: -------------------------------------------------------------------------------- 1 | 2 | dnl PKG_CHECK_MODULES(GSTUFF, gtk+-2.0 >= 1.3 glib = 1.3.4, action-if, action-not) 3 | dnl defines GSTUFF_LIBS, GSTUFF_CFLAGS, see pkg-config man page 4 | dnl also defines GSTUFF_PKG_ERRORS on error 5 | AC_DEFUN(PKG_CHECK_MODULES, [ 6 | succeeded=no 7 | 8 | if test -z "$PKG_CONFIG"; then 9 | AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 10 | fi 11 | 12 | if test "$PKG_CONFIG" = "no" ; then 13 | echo "*** The pkg-config script could not be found. Make sure it is" 14 | echo "*** in your path, or set the PKG_CONFIG environment variable" 15 | echo "*** to the full path to pkg-config." 16 | echo "*** Or see http://www.freedesktop.org/software/pkgconfig to get pkg-config." 17 | else 18 | PKG_CONFIG_MIN_VERSION=0.9.0 19 | if $PKG_CONFIG --atleast-pkgconfig-version $PKG_CONFIG_MIN_VERSION; then 20 | AC_MSG_CHECKING(for $2) 21 | 22 | if $PKG_CONFIG --exists "$2" ; then 23 | AC_MSG_RESULT(yes) 24 | succeeded=yes 25 | 26 | AC_MSG_CHECKING($1_CFLAGS) 27 | $1_CFLAGS=`$PKG_CONFIG --cflags "$2"` 28 | AC_MSG_RESULT($$1_CFLAGS) 29 | 30 | AC_MSG_CHECKING($1_LIBS) 31 | $1_LIBS=`$PKG_CONFIG --libs "$2"` 32 | AC_MSG_RESULT($$1_LIBS) 33 | else 34 | $1_CFLAGS="" 35 | $1_LIBS="" 36 | ## If we have a custom action on failure, don't print errors, but 37 | ## do set a variable so people can do so. 38 | $1_PKG_ERRORS=`$PKG_CONFIG --errors-to-stdout --print-errors "$2"` 39 | ifelse([$4], ,echo $$1_PKG_ERRORS,) 40 | fi 41 | 42 | AC_SUBST($1_CFLAGS) 43 | AC_SUBST($1_LIBS) 44 | else 45 | echo "*** Your version of pkg-config is too old. You need version $PKG_CONFIG_MIN_VERSION or newer." 46 | echo "*** See http://www.freedesktop.org/software/pkgconfig" 47 | fi 48 | fi 49 | 50 | if test $succeeded = yes; then 51 | ifelse([$3], , :, [$3]) 52 | else 53 | ifelse([$4], , AC_MSG_ERROR([Library requirements ($2) not met; consider adjusting the PKG_CONFIG_PATH environment variable if your libraries are in a nonstandard prefix so pkg-config can find them.]), [$4]) 54 | fi 55 | ]) 56 | 57 | 58 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/HostApi.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_HOSTAPI_HXX 2 | #define INCLUDED_PORTAUDIO_HOSTAPI_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | #include "portaudiocpp/System.hxx" 9 | 10 | // --------------------------------------------------------------------------------------- 11 | 12 | // Forward declaration(s): 13 | namespace portaudio 14 | { 15 | class Device; 16 | } 17 | 18 | // --------------------------------------------------------------------------------------- 19 | 20 | // Declaration(s): 21 | namespace portaudio 22 | { 23 | 24 | 25 | ////// 26 | /// @brief HostApi represents a host API (usually type of driver) in the System. 27 | /// 28 | /// A single System can support multiple HostApi's each one typically having 29 | /// a set of Devices using that HostApi (usually driver type). All Devices in 30 | /// the HostApi can be enumerated and the default input/output Device for this 31 | /// HostApi can be retrieved. 32 | ////// 33 | class HostApi 34 | { 35 | public: 36 | typedef System::DeviceIterator DeviceIterator; 37 | 38 | // query info: id, name, numDevices 39 | PaHostApiTypeId typeId() const; 40 | PaHostApiIndex index() const; 41 | const char *name() const; 42 | int deviceCount() const; 43 | 44 | // iterate devices 45 | DeviceIterator devicesBegin(); 46 | DeviceIterator devicesEnd(); 47 | 48 | // default devices 49 | Device &defaultInputDevice() const; 50 | Device &defaultOutputDevice() const; 51 | 52 | // comparison operators 53 | bool operator==(const HostApi &rhs) const; 54 | bool operator!=(const HostApi &rhs) const; 55 | 56 | private: 57 | const PaHostApiInfo *info_; 58 | Device **devices_; 59 | 60 | private: 61 | friend class System; 62 | 63 | explicit HostApi(PaHostApiIndex index); 64 | ~HostApi(); 65 | 66 | HostApi(const HostApi &); // non-copyable 67 | HostApi &operator=(const HostApi &); // non-copyable 68 | }; 69 | 70 | 71 | } 72 | 73 | // --------------------------------------------------------------------------------------- 74 | 75 | #endif // INCLUDED_PORTAUDIO_HOSTAPI_HXX 76 | -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/AsioDeviceAdapter.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/AsioDeviceAdapter.hxx" 2 | 3 | #include "portaudio.h" 4 | #include "pa_asio.h" 5 | 6 | #include "portaudiocpp/Device.hxx" 7 | #include "portaudiocpp/HostApi.hxx" 8 | #include "portaudiocpp/Exception.hxx" 9 | 10 | namespace portaudio 11 | { 12 | AsioDeviceAdapter::AsioDeviceAdapter(Device &device) 13 | { 14 | if (device.hostApi().typeId() != paASIO) 15 | throw PaCppException(PaCppException::UNABLE_TO_ADAPT_DEVICE); 16 | 17 | device_ = &device; 18 | 19 | PaError err = PaAsio_GetAvailableLatencyValues(device_->index(), &minBufferSize_, &maxBufferSize_, 20 | &preferredBufferSize_, &granularity_); 21 | 22 | if (err != paNoError) 23 | throw PaException(err); 24 | 25 | } 26 | 27 | Device &AsioDeviceAdapter::device() 28 | { 29 | return *device_; 30 | } 31 | 32 | long AsioDeviceAdapter::minBufferSize() const 33 | { 34 | return minBufferSize_; 35 | } 36 | 37 | long AsioDeviceAdapter::maxBufferSize() const 38 | { 39 | return maxBufferSize_; 40 | } 41 | 42 | long AsioDeviceAdapter::preferredBufferSize() const 43 | { 44 | return preferredBufferSize_; 45 | } 46 | 47 | long AsioDeviceAdapter::granularity() const 48 | { 49 | return granularity_; 50 | } 51 | 52 | void AsioDeviceAdapter::showControlPanel(void *systemSpecific) 53 | { 54 | PaError err = PaAsio_ShowControlPanel(device_->index(), systemSpecific); 55 | 56 | if (err != paNoError) 57 | throw PaException(err); 58 | } 59 | 60 | const char *AsioDeviceAdapter::inputChannelName(int channelIndex) const 61 | { 62 | const char *channelName; 63 | PaError err = PaAsio_GetInputChannelName(device_->index(), channelIndex, &channelName); 64 | 65 | if (err != paNoError) 66 | throw PaException(err); 67 | 68 | return channelName; 69 | } 70 | 71 | const char *AsioDeviceAdapter::outputChannelName(int channelIndex) const 72 | { 73 | const char *channelName; 74 | PaError err = PaAsio_GetOutputChannelName(device_->index(), channelIndex, &channelName); 75 | 76 | if (err != paNoError) 77 | throw PaException(err); 78 | 79 | return channelName; 80 | } 81 | } 82 | -------------------------------------------------------------------------------- /src/os/win/pa_x86_plain_converters.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Plain Intel IA32 assembly implementations of PortAudio sample converter functions. 3 | * Copyright (c) 1999-2002 Ross Bencina, Phil Burk 4 | * 5 | * Permission is hereby granted, free of charge, to any person obtaining 6 | * a copy of this software and associated documentation files 7 | * (the "Software"), to deal in the Software without restriction, 8 | * including without limitation the rights to use, copy, modify, merge, 9 | * publish, distribute, sublicense, and/or sell copies of the Software, 10 | * and to permit persons to whom the Software is furnished to do so, 11 | * subject to the following conditions: 12 | * 13 | * The above copyright notice and this permission notice shall be 14 | * included in all copies or substantial portions of the Software. 15 | * 16 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 20 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 21 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | */ 24 | 25 | /* 26 | * The text above constitutes the entire PortAudio license; however, 27 | * the PortAudio community also makes the following non-binding requests: 28 | * 29 | * Any person wishing to distribute modifications to the Software is 30 | * requested to send the modifications to the original developer so that 31 | * they can be incorporated into the canonical version. It is also 32 | * requested that these non-binding requests be included along with the 33 | * license above. 34 | */ 35 | 36 | /** @file 37 | @ingroup win_src 38 | */ 39 | 40 | #ifndef PA_X86_PLAIN_CONVERTERS_H 41 | #define PA_X86_PLAIN_CONVERTERS_H 42 | 43 | #ifdef __cplusplus 44 | extern "C" 45 | { 46 | #endif /* __cplusplus */ 47 | 48 | 49 | /** 50 | @brief Install optimized converter functions suitable for all IA32 processors 51 | 52 | It is recommended to call PaUtil_InitializeX86PlainConverters prior to calling Pa_Initialize 53 | */ 54 | void PaUtil_InitializeX86PlainConverters( void ); 55 | 56 | 57 | #ifdef __cplusplus 58 | } 59 | #endif /* __cplusplus */ 60 | #endif /* PA_X86_PLAIN_CONVERTERS_H */ 61 | -------------------------------------------------------------------------------- /cmake/modules/FindRegex.cmake: -------------------------------------------------------------------------------- 1 | #[=======================================================================[.rst: 2 | FindRegex 3 | -------- 4 | 5 | Finds an implementation of POSIX regular expressions. It first checks if the 6 | standard regex.h POSIX header is available. If not, it looks for the TRE library. 7 | MinGW does not come with regex.h, so TRE is useful with MinGW. 8 | 9 | Imported Targets 10 | ^^^^^^^^^^^^^^^^ 11 | 12 | This module provides the following imported targets, if found: 13 | 14 | ``Regex::regex`` 15 | The POSIX regular expression implementation 16 | 17 | #]=======================================================================] 18 | 19 | include(FindPackageHandleStandardArgs) 20 | include(CheckIncludeFile) 21 | 22 | set(CMAKE_REQUIRED_QUIET TRUE) 23 | check_include_file(regex.h REGEX_H) 24 | set(CMAKE_REQUIRED_QUIET FALSE) 25 | 26 | if(REGEX_H) 27 | # No need to add any include directories or link any libraries; 28 | # simply provide a dummy target. 29 | if(NOT TARGET Regex::regex) 30 | add_library(Regex::regex INTERFACE IMPORTED) 31 | endif() 32 | 33 | # check_include_file sets the variable to "1" which looks odd in the output 34 | # of find_package_handle_standard_args, so show the user what was actually found. 35 | set(REGEX_H "POSIX regex.h") 36 | find_package_handle_standard_args( 37 | Regex 38 | DEFAULT_MSG 39 | REGEX_H 40 | ) 41 | else() 42 | # MinGW does not include regex.h but this can be supplied by the TRE library. 43 | find_path(TRE_REGEX_H NAMES tre/regex.h) 44 | if(TRE_REGEX_H) 45 | # The POSIX #include is simply but the tre regex.h is at , 46 | # so add the directory containing tre's headers to the include path. 47 | set(TRE_INCLUDE_DIR "${TRE_REGEX_H}/tre") 48 | endif() 49 | find_library(TRE_LIBRARY NAMES tre) 50 | if(TRE_REGEX_H AND TRE_LIBRARY) 51 | message(STATUS "Found regex.h from TRE") 52 | else() 53 | message(STATUS "regex.h POSIX header NOT found and NOT available from TRE") 54 | endif() 55 | 56 | if(NOT TARGET Regex::regex) 57 | add_library(Regex::regex INTERFACE IMPORTED) 58 | target_include_directories(Regex::regex INTERFACE "${TRE_INCLUDE_DIR}") 59 | target_link_libraries(Regex::regex INTERFACE "${TRE_LIBRARY}") 60 | endif() 61 | 62 | find_package_handle_standard_args( 63 | Regex 64 | DEFAULT_MSG 65 | TRE_INCLUDE_DIR 66 | TRE_LIBRARY 67 | ) 68 | endif() 69 | -------------------------------------------------------------------------------- /src/os/win/pa_win_util.h: -------------------------------------------------------------------------------- 1 | #ifndef PA_WIN_UTIL_H 2 | #define PA_WIN_UTIL_H 3 | 4 | /* 5 | * $Id$ 6 | * Portable Audio I/O Library 7 | * Win32 platform-specific support functions 8 | * 9 | * Based on the Open Source API proposed by Ross Bencina 10 | * Copyright (c) 1999-2008 Ross Bencina 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining 13 | * a copy of this software and associated documentation files 14 | * (the "Software"), to deal in the Software without restriction, 15 | * including without limitation the rights to use, copy, modify, merge, 16 | * publish, distribute, sublicense, and/or sell copies of the Software, 17 | * and to permit persons to whom the Software is furnished to do so, 18 | * subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be 21 | * included in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 26 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 27 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 28 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | /* 33 | * The text above constitutes the entire PortAudio license; however, 34 | * the PortAudio community also makes the following non-binding requests: 35 | * 36 | * Any person wishing to distribute modifications to the Software is 37 | * requested to send the modifications to the original developer so that 38 | * they can be incorporated into the canonical version. It is also 39 | * requested that these non-binding requests be included along with the 40 | * license above. 41 | */ 42 | 43 | #include "portaudio.h" 44 | 45 | #ifdef __cplusplus 46 | extern "C" 47 | { 48 | #endif /* __cplusplus */ 49 | 50 | /** 51 | Convert a Windows error code into a PaError. Sets the host-api specific error 52 | information if needed. 53 | 54 | @param hostApiType The calling host api type. Used when reporting paUnanticipatedHostError 55 | 56 | @param winError A Windows error code. 57 | */ 58 | void PaWinUtil_SetLastSystemErrorInfo( PaHostApiTypeId hostApiType, long winError ); 59 | 60 | #ifdef __cplusplus 61 | } 62 | #endif /* __cplusplus */ 63 | 64 | #endif /* PA_WIN_UTIL_H */ 65 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/Stream.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_STREAM_HXX 2 | #define INCLUDED_PORTAUDIO_STREAM_HXX 3 | 4 | #include "portaudio.h" 5 | 6 | // --------------------------------------------------------------------------------------- 7 | 8 | // Forward declaration(s): 9 | namespace portaudio 10 | { 11 | class StreamParameters; 12 | } 13 | 14 | // --------------------------------------------------------------------------------------- 15 | 16 | // Declaration(s): 17 | namespace portaudio 18 | { 19 | 20 | 21 | ////// 22 | /// @brief A Stream represents an active or inactive input and/or output data 23 | /// stream in the System. 24 | /// 25 | /// Concrete Stream classes should ensure themselves being in a closed state at 26 | /// destruction (i.e. by calling their own close() method in their deconstructor). 27 | /// Following good C++ programming practices, care must be taken to ensure no 28 | /// exceptions are thrown by the deconstructor of these classes. As a consequence, 29 | /// clients need to explicitly call close() to ensure the stream closed successfully. 30 | /// 31 | /// The Stream object can be used to manipulate the Stream's state. Also, time-constant 32 | /// and time-varying information about the Stream can be retrieved. 33 | ////// 34 | class Stream 35 | { 36 | public: 37 | // Opening/closing: 38 | virtual ~Stream(); 39 | 40 | virtual void close(); 41 | bool isOpen() const; 42 | 43 | // Additional set up: 44 | void setStreamFinishedCallback(PaStreamFinishedCallback *callback); 45 | 46 | // State management: 47 | void start(); 48 | void stop(); 49 | void abort(); 50 | 51 | bool isStopped() const; 52 | bool isActive() const; 53 | 54 | // Stream info (time-constant, but might become time-variant soon): 55 | PaTime inputLatency() const; 56 | PaTime outputLatency() const; 57 | double sampleRate() const; 58 | 59 | // Stream info (time-varying): 60 | PaTime time() const; 61 | 62 | // Accessors for PortAudio PaStream, useful for interfacing 63 | // with PortAudio add-ons (such as PortMixer) for instance: 64 | const PaStream *paStream() const; 65 | PaStream *paStream(); 66 | 67 | protected: 68 | Stream(); // abstract class 69 | 70 | PaStream *stream_; 71 | 72 | private: 73 | Stream(const Stream &); // non-copyable 74 | Stream &operator=(const Stream &); // non-copyable 75 | }; 76 | 77 | 78 | } // namespace portaudio 79 | 80 | 81 | #endif // INCLUDED_PORTAUDIO_STREAM_HXX 82 | -------------------------------------------------------------------------------- /src/os/win/pa_win_wdmks_utils.h: -------------------------------------------------------------------------------- 1 | #ifndef PA_WIN_WDMKS_UTILS_H 2 | #define PA_WIN_WDMKS_UTILS_H 3 | 4 | /* 5 | * PortAudio Portable Real-Time Audio Library 6 | * Windows WDM KS utilities 7 | * 8 | * Copyright (c) 1999 - 2007 Ross Bencina, Andrew Baldwin 9 | * 10 | * Permission is hereby granted, free of charge, to any person obtaining 11 | * a copy of this software and associated documentation files 12 | * (the "Software"), to deal in the Software without restriction, 13 | * including without limitation the rights to use, copy, modify, merge, 14 | * publish, distribute, sublicense, and/or sell copies of the Software, 15 | * and to permit persons to whom the Software is furnished to do so, 16 | * subject to the following conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be 19 | * included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 23 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 24 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 25 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 26 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 27 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 28 | */ 29 | 30 | /* 31 | * The text above constitutes the entire PortAudio license; however, 32 | * the PortAudio community also makes the following non-binding requests: 33 | * 34 | * Any person wishing to distribute modifications to the Software is 35 | * requested to send the modifications to the original developer so that 36 | * they can be incorporated into the canonical version. It is also 37 | * requested that these non-binding requests be included along with the 38 | * license above. 39 | */ 40 | 41 | /** @file 42 | @brief Utilities for working with the Windows WDM KS API 43 | */ 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | /** 50 | Query for the maximum number of channels supported by any pin of the 51 | specified device. Returns 0 if the query fails for any reason. 52 | 53 | @param wcharDevicePath A system level PnP interface path, supplied as a WCHAR unicode string. 54 | Declared as void* to avoid introducing a dependency on wchar_t here. 55 | 56 | @param isInput A flag specifying whether to query for input (non-zero) or output (zero) channels. 57 | */ 58 | int PaWin_WDMKS_QueryFilterMaximumChannelCount( void *wcharDevicePath, int isInput ); 59 | 60 | 61 | #ifdef __cplusplus 62 | } 63 | #endif /* __cplusplus */ 64 | 65 | #endif /* PA_WIN_WDMKS_UTILS_H */ 66 | -------------------------------------------------------------------------------- /doc/src/tutorial/start_stop_abort.dox: -------------------------------------------------------------------------------- 1 | /** @page start_stop_abort Starting, Stopping and Aborting a Stream 2 | @ingroup tutorial 3 | 4 | @section tut_startstop1 Starting, Stopping and Aborting a Stream 5 | 6 | PortAudio will not start playing back audio until you start the stream. After calling Pa_StartStream(), PortAudio will start calling your callback function to perform the audio processing. 7 | 8 | @code 9 | err = Pa_StartStream( stream ); 10 | if( err != paNoError ) goto error; 11 | @endcode 12 | 13 | You can communicate with your callback routine through the data structure you passed in on the open call, or through global variables, or using other interprocess communication techniques, but please be aware that your callback function may be called at interrupt time when your foreground process is least expecting it. So avoid sharing complex data structures that are easily corrupted like double linked lists, and avoid using locks such as mutexes as this may cause your callback function to block and therefore drop audio. Such techniques may even cause deadlock on some platforms. 14 | 15 | PortAudio will continue to call your callback and process audio until you stop the stream. This can be done in one of several ways, but, before we do so, we'll want to see that some of our audio gets processed by sleeping for a few seconds. This is easy to do with Pa_Sleep(), which is used by many of the examples in the patests/ directory for exactly this purpose. Note that, for a variety of reasons, you can not rely on this function for accurate scheduling, so your stream may not run for exactly the same amount of time as you expect, but it's good enough for our example. 16 | 17 | @code 18 | /* Sleep for several seconds. */ 19 | Pa_Sleep(NUM_SECONDS*1000); 20 | @endcode 21 | 22 | Now we need to stop playback. There are several ways to do this, the simplest of which is to call Pa_StopStream(): 23 | 24 | @code 25 | err = Pa_StopStream( stream ); 26 | if( err != paNoError ) goto error; 27 | @endcode 28 | 29 | Pa_StopStream() is designed to make sure that the buffers you've processed in your callback are all played, which may cause some delay. Alternatively, you could call Pa_AbortStream(). On some platforms, aborting the stream is much faster and may cause some data processed by your callback not to be played. 30 | 31 | Another way to stop the stream is to return either paComplete, or paAbort from your callback. paComplete ensures that the last buffer is played whereas paAbort stops the stream as soon as possible. If you stop the stream using this technique, you will need to call Pa_StopStream() before starting the stream again. 32 | 33 | Previous: \ref open_default_stream | Next: \ref terminating_portaudio 34 | 35 | */ -------------------------------------------------------------------------------- /doc/src/tutorial/utility_functions.dox: -------------------------------------------------------------------------------- 1 | /** @page utility_functions Utility Functions 2 | @ingroup tutorial 3 | 4 | In addition to the functions described elsewhere in this tutorial, PortAudio provides a number of Utility functions that are useful in a variety of circumstances. 5 | You'll want to read the portaudio.h reference, which documents the entire V19 API for details, but we'll try to cover the basics here. 6 | 7 | @section tut_util2 Version Information 8 | 9 | PortAudio offers two functions to determine the PortAudio Version. This is most useful when you are using PortAudio as a dynamic library, but it may also be useful at other times. 10 | 11 | @code 12 | int Pa_GetVersion (void) 13 | const char * Pa_GetVersionText (void) 14 | @endcode 15 | 16 | @section tut_util3 Error Text 17 | 18 | PortAudio allows you to get error text from an error number. 19 | 20 | @code 21 | const char * Pa_GetErrorText (PaError errorCode) 22 | @endcode 23 | 24 | @section tut_util4 Stream State 25 | 26 | PortAudio Streams exist in 3 states: Active, Stopped, and Callback Stopped. If a stream is in callback stopped state, you'll need to stop it before you can start it again. If you need to query the state of a PortAudio stream, there are two functions for doing so: 27 | 28 | @code 29 | PaError Pa_IsStreamStopped (PaStream *stream) 30 | PaError Pa_IsStreamActive (PaStream *stream) 31 | @endcode 32 | 33 | @section tut_util5 Stream Info 34 | 35 | If you need to retrieve info about a given stream, such as latency, and sample rate info, there's a function for that too: 36 | 37 | @code 38 | const PaStreamInfo * Pa_GetStreamInfo (PaStream *stream) 39 | @endcode 40 | 41 | @section tut_util6 Stream Time 42 | 43 | If you need to synchronise other activities such as display updates or MIDI output with the PortAudio callback you need to know the current time according to the same timebase used by the stream callback timestamps. 44 | 45 | @code 46 | PaTime Pa_GetStreamTime (PaStream *stream) 47 | @endcode 48 | 49 | @section tut_util6CPU Usage 50 | 51 | To determine how much CPU is being used by the callback, use these: 52 | 53 | @code 54 | double Pa_GetStreamCpuLoad (PaStream *stream) 55 | @endcode 56 | 57 | @section tut_util7 Other utilities 58 | 59 | These functions allow you to determine the size of a sample from its format and sleep for a given amount of time. The sleep function should not be used for precise timing or synchronization because it makes few guarantees about the exact length of time it waits. It is most useful for testing. 60 | 61 | @code 62 | PaError Pa_GetSampleSize (PaSampleFormat format) 63 | void Pa_Sleep (long msec) 64 | @endcode 65 | 66 | 67 | Previous: \ref terminating_portaudio | Next: \ref querying_devices 68 | 69 | */ -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/BlockingStream.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/BlockingStream.hxx" 2 | 3 | #include "portaudio.h" 4 | 5 | #include "portaudiocpp/StreamParameters.hxx" 6 | #include "portaudiocpp/Exception.hxx" 7 | 8 | namespace portaudio 9 | { 10 | 11 | // -------------------------------------------------------------------------------------- 12 | 13 | BlockingStream::BlockingStream() 14 | { 15 | } 16 | 17 | BlockingStream::BlockingStream(const StreamParameters ¶meters) 18 | { 19 | open(parameters); 20 | } 21 | 22 | BlockingStream::~BlockingStream() 23 | { 24 | try 25 | { 26 | close(); 27 | } 28 | catch (...) 29 | { 30 | // ignore all errors 31 | } 32 | } 33 | 34 | // -------------------------------------------------------------------------------------- 35 | 36 | void BlockingStream::open(const StreamParameters ¶meters) 37 | { 38 | PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), 39 | parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), NULL, NULL); 40 | 41 | if (err != paNoError) 42 | { 43 | throw PaException(err); 44 | } 45 | } 46 | 47 | // -------------------------------------------------------------------------------------- 48 | 49 | void BlockingStream::read(void *buffer, unsigned long numFrames) 50 | { 51 | PaError err = Pa_ReadStream(stream_, buffer, numFrames); 52 | 53 | if (err != paNoError) 54 | { 55 | throw PaException(err); 56 | } 57 | } 58 | 59 | void BlockingStream::write(const void *buffer, unsigned long numFrames) 60 | { 61 | PaError err = Pa_WriteStream(stream_, buffer, numFrames); 62 | 63 | if (err != paNoError) 64 | { 65 | throw PaException(err); 66 | } 67 | } 68 | 69 | // -------------------------------------------------------------------------------------- 70 | 71 | signed long BlockingStream::availableReadSize() const 72 | { 73 | signed long avail = Pa_GetStreamReadAvailable(stream_); 74 | 75 | if (avail < 0) 76 | { 77 | throw PaException(avail); 78 | } 79 | 80 | return avail; 81 | } 82 | 83 | signed long BlockingStream::availableWriteSize() const 84 | { 85 | signed long avail = Pa_GetStreamWriteAvailable(stream_); 86 | 87 | if (avail < 0) 88 | { 89 | throw PaException(avail); 90 | } 91 | 92 | return avail; 93 | } 94 | 95 | // -------------------------------------------------------------------------------------- 96 | 97 | } // portaudio 98 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/DirectionSpecificStreamParameters.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX 2 | #define INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include 7 | 8 | #include "portaudio.h" 9 | 10 | #include "portaudiocpp/System.hxx" 11 | #include "portaudiocpp/SampleDataFormat.hxx" 12 | 13 | // --------------------------------------------------------------------------------------- 14 | 15 | // Forward declaration(s): 16 | namespace portaudio 17 | { 18 | class Device; 19 | } 20 | 21 | // --------------------------------------------------------------------------------------- 22 | 23 | // Declaration(s): 24 | namespace portaudio 25 | { 26 | 27 | ////// 28 | /// @brief All parameters for one direction (either in or out) of a Stream. Together with 29 | /// parameters common to both directions, two DirectionSpecificStreamParameters can make up 30 | /// a StreamParameters object which contains all parameters for a Stream. 31 | ////// 32 | class DirectionSpecificStreamParameters 33 | { 34 | public: 35 | static DirectionSpecificStreamParameters null(); 36 | 37 | DirectionSpecificStreamParameters(); 38 | DirectionSpecificStreamParameters(const Device &device, int numChannels, SampleDataFormat format, 39 | bool interleaved, PaTime suggestedLatency, void *hostApiSpecificStreamInfo); 40 | 41 | // Set up methods: 42 | void setDevice(const Device &device); 43 | void setNumChannels(int numChannels); 44 | 45 | void setSampleFormat(SampleDataFormat format, bool interleaved = true); 46 | void setHostApiSpecificSampleFormat(PaSampleFormat format, bool interleaved = true); 47 | 48 | void setSuggestedLatency(PaTime latency); 49 | 50 | void setHostApiSpecificStreamInfo(void *streamInfo); 51 | 52 | // Accessor methods: 53 | PaStreamParameters *paStreamParameters(); 54 | const PaStreamParameters *paStreamParameters() const; 55 | 56 | Device &device() const; 57 | int numChannels() const; 58 | 59 | SampleDataFormat sampleFormat() const; 60 | bool isSampleFormatInterleaved() const; 61 | bool isSampleFormatHostApiSpecific() const; 62 | PaSampleFormat hostApiSpecificSampleFormat() const; 63 | 64 | PaTime suggestedLatency() const; 65 | 66 | void *hostApiSpecificStreamInfo() const; 67 | 68 | private: 69 | PaStreamParameters paStreamParameters_; 70 | }; 71 | 72 | 73 | } // namespace portaudio 74 | 75 | // --------------------------------------------------------------------------------------- 76 | 77 | #endif // INCLUDED_PORTAUDIO_SINGLEDIRECTIONSTREAMPARAMETERS_HXX 78 | -------------------------------------------------------------------------------- /test/patest_init.c: -------------------------------------------------------------------------------- 1 | /** @file patest_init.c 2 | @ingroup test_src 3 | @brief Initialize and terminate PortAudio 4 | @author Ross Bencina 5 | */ 6 | /* 7 | * $Id$ 8 | * 9 | * This program uses the PortAudio Portable Audio Library. 10 | * For more information see: http://www.portaudio.com 11 | * Copyright (c) 1999-2024 Ross Bencina and Phil Burk 12 | * 13 | * Permission is hereby granted, free of charge, to any person obtaining 14 | * a copy of this software and associated documentation files 15 | * (the "Software"), to deal in the Software without restriction, 16 | * including without limitation the rights to use, copy, modify, merge, 17 | * publish, distribute, sublicense, and/or sell copies of the Software, 18 | * and to permit persons to whom the Software is furnished to do so, 19 | * subject to the following conditions: 20 | * 21 | * The above copyright notice and this permission notice shall be 22 | * included in all copies or substantial portions of the Software. 23 | * 24 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 25 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 26 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 27 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 28 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 29 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 30 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 31 | */ 32 | 33 | /* 34 | * The text above constitutes the entire PortAudio license; however, 35 | * the PortAudio community also makes the following non-binding requests: 36 | * 37 | * Any person wishing to distribute modifications to the Software is 38 | * requested to send the modifications to the original developer so that 39 | * they can be incorporated into the canonical version. It is also 40 | * requested that these non-binding requests be included along with the 41 | * license above. 42 | */ 43 | 44 | #include 45 | 46 | #include "portaudio.h" 47 | 48 | int main(void); 49 | int main(void) 50 | { 51 | PaError err; 52 | 53 | printf("PortAudio Test: initialize and terminate.\n"); 54 | 55 | err = Pa_Initialize(); 56 | if( err != paNoError ) { 57 | fprintf( stderr, "An error occurred while initializing PortAudio\n" ); 58 | goto error; 59 | } 60 | 61 | err = Pa_Terminate(); 62 | if( err != paNoError ) { 63 | fprintf( stderr, "An error occurred while terminating PortAudio\n" ); 64 | goto error; 65 | } 66 | 67 | printf("Test completed successfully.\n"); 68 | return err; 69 | 70 | error: 71 | Pa_Terminate(); 72 | 73 | fprintf( stderr, "Error number: %d\n", err ); 74 | fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) ); 75 | return err; 76 | } 77 | -------------------------------------------------------------------------------- /src/hostapi/oss/recplay.c: -------------------------------------------------------------------------------- 1 | /* 2 | * recplay.c 3 | * Phil Burk 4 | * Minimal record and playback test. 5 | * 6 | */ 7 | #include 8 | #include 9 | #include 10 | #ifndef __STDC__ 11 | /* #include */ 12 | #endif /* __STDC__ */ 13 | #include 14 | #ifdef __STDC__ 15 | #include 16 | #else /* __STDC__ */ 17 | #include 18 | #endif /* __STDC__ */ 19 | #include 20 | 21 | #define NUM_BYTES (64*1024) 22 | #define BLOCK_SIZE (4*1024) 23 | 24 | #define AUDIO "/dev/dsp" 25 | 26 | char buffer[NUM_BYTES]; 27 | 28 | int audioDev = 0; 29 | 30 | main (int argc, char *argv[]) 31 | { 32 | int numLeft; 33 | char *ptr; 34 | int num; 35 | int samplesize; 36 | 37 | /********** RECORD ********************/ 38 | /* Open audio device. */ 39 | audioDev = open (AUDIO, O_RDONLY, 0); 40 | if (audioDev == -1) 41 | { 42 | perror (AUDIO); 43 | exit (-1); 44 | } 45 | 46 | /* Set to 16 bit samples. */ 47 | samplesize = 16; 48 | ioctl(audioDev, SNDCTL_DSP_SAMPLESIZE, &samplesize); 49 | if (samplesize != 16) 50 | { 51 | perror("Unable to set the sample size."); 52 | exit(-1); 53 | } 54 | 55 | /* Record in blocks */ 56 | printf("Begin recording.\n"); 57 | numLeft = NUM_BYTES; 58 | ptr = buffer; 59 | while( numLeft >= BLOCK_SIZE ) 60 | { 61 | if ( (num = read (audioDev, ptr, BLOCK_SIZE)) < 0 ) 62 | { 63 | perror (AUDIO); 64 | exit (-1); 65 | } 66 | else 67 | { 68 | printf("Read %d bytes\n", num); 69 | ptr += num; 70 | numLeft -= num; 71 | } 72 | } 73 | 74 | close( audioDev ); 75 | 76 | /********** PLAYBACK ********************/ 77 | /* Open audio device for writing. */ 78 | audioDev = open (AUDIO, O_WRONLY, 0); 79 | if (audioDev == -1) 80 | { 81 | perror (AUDIO); 82 | exit (-1); 83 | } 84 | 85 | /* Set to 16 bit samples. */ 86 | samplesize = 16; 87 | ioctl(audioDev, SNDCTL_DSP_SAMPLESIZE, &samplesize); 88 | if (samplesize != 16) 89 | { 90 | perror("Unable to set the sample size."); 91 | exit(-1); 92 | } 93 | 94 | /* Play in blocks */ 95 | printf("Begin playing.\n"); 96 | numLeft = NUM_BYTES; 97 | ptr = buffer; 98 | while( numLeft >= BLOCK_SIZE ) 99 | { 100 | if ( (num = write (audioDev, ptr, BLOCK_SIZE)) < 0 ) 101 | { 102 | perror (AUDIO); 103 | exit (-1); 104 | } 105 | else 106 | { 107 | printf("Wrote %d bytes\n", num); 108 | ptr += num; 109 | numLeft -= num; 110 | } 111 | } 112 | 113 | close( audioDev ); 114 | } 115 | -------------------------------------------------------------------------------- /msvc/portaudio.def: -------------------------------------------------------------------------------- 1 | EXPORTS 2 | 3 | ; 4 | Pa_GetVersion @1 5 | Pa_GetVersionText @2 6 | Pa_GetErrorText @3 7 | Pa_Initialize @4 8 | Pa_Terminate @5 9 | Pa_GetHostApiCount @6 10 | Pa_GetDefaultHostApi @7 11 | Pa_GetHostApiInfo @8 12 | Pa_HostApiTypeIdToHostApiIndex @9 13 | Pa_HostApiDeviceIndexToDeviceIndex @10 14 | Pa_GetLastHostErrorInfo @11 15 | Pa_GetDeviceCount @12 16 | Pa_GetDefaultInputDevice @13 17 | Pa_GetDefaultOutputDevice @14 18 | Pa_GetDeviceInfo @15 19 | Pa_IsFormatSupported @16 20 | Pa_OpenStream @17 21 | Pa_OpenDefaultStream @18 22 | Pa_CloseStream @19 23 | Pa_SetStreamFinishedCallback @20 24 | Pa_StartStream @21 25 | Pa_StopStream @22 26 | Pa_AbortStream @23 27 | Pa_IsStreamStopped @24 28 | Pa_IsStreamActive @25 29 | Pa_GetStreamInfo @26 30 | Pa_GetStreamTime @27 31 | Pa_GetStreamCpuLoad @28 32 | Pa_ReadStream @29 33 | Pa_WriteStream @30 34 | Pa_GetStreamReadAvailable @31 35 | Pa_GetStreamWriteAvailable @32 36 | Pa_GetSampleSize @33 37 | Pa_Sleep @34 38 | Pa_GetVersionInfo @35 39 | ; add new portable public API functions here. DO NOT CHANGE EXISTING ORDINALS! 40 | PaAsio_GetAvailableBufferSizes @50 41 | PaAsio_ShowControlPanel @51 42 | PaUtil_InitializeX86PlainConverters @52 43 | PaAsio_GetInputChannelName @53 44 | PaAsio_GetOutputChannelName @54 45 | PaUtil_SetDebugPrintFunction @55 46 | PaWasapi_GetAudioClient @56 47 | PaWasapi_UpdateDeviceList @57 48 | PaWasapi_GetDeviceCurrentFormat @58 49 | PaWasapi_GetDeviceDefaultFormat @59 50 | PaWasapi_GetDeviceMixFormat @60 51 | PaWasapi_GetDeviceRole @61 52 | PaWasapi_ThreadPriorityBoost @62 53 | PaWasapi_ThreadPriorityRevert @63 54 | PaWasapi_GetFramesPerHostBuffer @64 55 | PaWasapi_GetJackCount @65 56 | PaWasapi_GetJackDescription @66 57 | PaWasapi_SetStreamStateHandler @68 58 | PaWasapiWinrt_SetDefaultDeviceId @67 59 | PaWasapiWinrt_PopulateDeviceList @69 60 | PaWasapi_GetIMMDevice @70 61 | PaWinMME_GetStreamInputHandleCount @71 62 | PaWinMME_GetStreamInputHandle @72 63 | PaWinMME_GetStreamOutputHandleCount @73 64 | PaWinMME_GetStreamOutputHandle @74 65 | PaWasapi_IsLoopback @75 66 | ; add new host-API-specific public functions here. DO NOT CHANGE EXISTING ORDINALS! 67 | -------------------------------------------------------------------------------- /doc/src/tutorial/open_default_stream.dox: -------------------------------------------------------------------------------- 1 | /** @page open_default_stream Opening a Stream Using Defaults 2 | @ingroup tutorial 3 | 4 | The next step is to open a stream, which is similar to opening a file. You can specify whether you want audio input and/or output, how many channels, the data format, sample rate, etc. Opening a ''default'' stream means opening the default input and output devices, which saves you the trouble of getting a list of devices and choosing one from the list. (We'll see how to do that later.) 5 | @code 6 | #define SAMPLE_RATE (44100) 7 | static paTestData data; 8 | 9 | ..... 10 | 11 | PaStream *stream; 12 | PaError err; 13 | 14 | /* Open an audio I/O stream. */ 15 | err = Pa_OpenDefaultStream( &stream, 16 | 0, /* no input channels */ 17 | 2, /* stereo output */ 18 | paFloat32, /* 32 bit floating point output */ 19 | SAMPLE_RATE, 20 | 256, /* frames per buffer, i.e. the number 21 | of sample frames that PortAudio will 22 | request from the callback. Many apps 23 | may want to use 24 | paFramesPerBufferUnspecified, which 25 | tells PortAudio to pick the best, 26 | possibly changing, buffer size.*/ 27 | patestCallback, /* this is your callback function */ 28 | &data ); /*This is a pointer that will be passed to 29 | your callback*/ 30 | if( err != paNoError ) goto error; 31 | @endcode 32 | 33 | The data structure and callback are described in \ref writing_a_callback. 34 | 35 | The above example opens the stream for writing, which is sufficient for playback. It is also possible to open a stream for reading, to do recording, or both reading and writing, for simultaneous recording and playback or even real-time audio processing. If you plan to do playback and recording at the same time, open only one stream with valid input and output parameters. 36 | 37 | There are some caveats to note about simultaneous read/write: 38 | 39 | - Some platforms can only open a read/write stream using the same device. 40 | - Although multiple streams can be opened, it is difficult to synchronize them. 41 | - Some platforms don't support opening multiple streams on the same device. 42 | - Using multiple streams may not be as well tested as other features. 43 | - The PortAudio library calls must be made from the same thread or synchronized by the user. 44 | 45 | 46 | Previous: \ref initializing_portaudio | Next: \ref start_stop_abort 47 | 48 | */ -------------------------------------------------------------------------------- /src/common/pa_cpuload.h: -------------------------------------------------------------------------------- 1 | #ifndef PA_CPULOAD_H 2 | #define PA_CPULOAD_H 3 | /* 4 | * $Id$ 5 | * Portable Audio I/O Library CPU Load measurement functions 6 | * Portable CPU load measurement facility. 7 | * 8 | * Based on the Open Source API proposed by Ross Bencina 9 | * Copyright (c) 2002 Ross Bencina 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining 12 | * a copy of this software and associated documentation files 13 | * (the "Software"), to deal in the Software without restriction, 14 | * including without limitation the rights to use, copy, modify, merge, 15 | * publish, distribute, sublicense, and/or sell copies of the Software, 16 | * and to permit persons to whom the Software is furnished to do so, 17 | * subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be 20 | * included in all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 25 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 26 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | */ 30 | 31 | /* 32 | * The text above constitutes the entire PortAudio license; however, 33 | * the PortAudio community also makes the following non-binding requests: 34 | * 35 | * Any person wishing to distribute modifications to the Software is 36 | * requested to send the modifications to the original developer so that 37 | * they can be incorporated into the canonical version. It is also 38 | * requested that these non-binding requests be included along with the 39 | * license above. 40 | */ 41 | 42 | /** @file 43 | @ingroup common_src 44 | 45 | @brief Functions to assist in measuring the CPU utilization of a callback 46 | stream. Used to implement the Pa_GetStreamCpuLoad() function. 47 | */ 48 | 49 | 50 | #ifdef __cplusplus 51 | extern "C" 52 | { 53 | #endif /* __cplusplus */ 54 | 55 | 56 | typedef struct { 57 | double samplingPeriod; 58 | double measurementStartTime; 59 | double averageLoad; 60 | } PaUtilCpuLoadMeasurer; /**< @todo need better name than measurer */ 61 | 62 | void PaUtil_InitializeCpuLoadMeasurer( PaUtilCpuLoadMeasurer* measurer, double sampleRate ); 63 | void PaUtil_BeginCpuLoadMeasurement( PaUtilCpuLoadMeasurer* measurer ); 64 | void PaUtil_EndCpuLoadMeasurement( PaUtilCpuLoadMeasurer* measurer, unsigned long framesProcessed ); 65 | void PaUtil_ResetCpuLoadMeasurer( PaUtilCpuLoadMeasurer* measurer ); 66 | double PaUtil_GetCpuLoad( PaUtilCpuLoadMeasurer* measurer ); 67 | 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif /* __cplusplus */ 72 | #endif /* PA_CPULOAD_H */ 73 | -------------------------------------------------------------------------------- /include/pa_linux_pulseaudio.h: -------------------------------------------------------------------------------- 1 | #ifndef PA_LINUX_PULSEAUDIO_H 2 | #define PA_LINUX_PULSEAUDIO_H 3 | 4 | /* 5 | * $Id$ 6 | * PortAudio Portable Real-Time Audio Library 7 | * PulseAudio-specific extensions 8 | * 9 | * Copyright (c) 1999-2000 Ross Bencina and Phil Burk 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining 12 | * a copy of this software and associated documentation files 13 | * (the "Software"), to deal in the Software without restriction, 14 | * including without limitation the rights to use, copy, modify, merge, 15 | * publish, distribute, sublicense, and/or sell copies of the Software, 16 | * and to permit persons to whom the Software is furnished to do so, 17 | * subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be 20 | * included in all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 25 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 26 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | */ 30 | 31 | /* 32 | * The text above constitutes the entire PortAudio license; however, 33 | * the PortAudio community also makes the following non-binding requests: 34 | * 35 | * Any person wishing to distribute modifications to the Software is 36 | * requested to send the modifications to the original developer so that 37 | * they can be incorporated into the canonical version. It is also 38 | * requested that these non-binding requests be included along with the 39 | * license above. 40 | */ 41 | 42 | /** @file 43 | * @ingroup public_header 44 | * @brief PulseAudio-specific PortAudio API extension header file. 45 | */ 46 | 47 | #include "portaudio.h" 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /** 54 | * Renames the PulseAudio description for the source that is opened 55 | * by PortAudio. 56 | * 57 | * @param s The PortAudio stream to operate on. 58 | * @param streamName The new name/description of the source. 59 | * 60 | * @return paNoError on success or the error encountered otherwise. 61 | */ 62 | PaError PaPulseAudio_RenameSource( PaStream *s, const char *streamName ); 63 | 64 | /** 65 | * Renames the PulseAudio description for the sink that is opened 66 | * by PortAudio. 67 | * 68 | * @param s The PortAudio stream to operate on. 69 | * @param streamName The new name/description of the sink. 70 | * 71 | * @return paNoError on success or the error encountered otherwise. 72 | */ 73 | PaError PaPulseAudio_RenameSink( PaStream *s, const char *streamName ); 74 | 75 | #ifdef __cplusplus 76 | } 77 | #endif 78 | 79 | #endif 80 | -------------------------------------------------------------------------------- /qa/paqa_macros.h: -------------------------------------------------------------------------------- 1 | 2 | #ifndef PORTAUDIO_QA_PAQA_MACROS_H 3 | #define PORTAUDIO_QA_PAQA_MACROS_H 4 | 5 | extern int paQaNumPassed; 6 | extern int paQaNumFailed; 7 | 8 | /* You must use this macro exactly once in each test program. */ 9 | #define PAQA_INSTANTIATE_GLOBALS\ 10 | int paQaNumPassed = 0;\ 11 | int paQaNumFailed = 0; 12 | 13 | /*------------------- Macros ------------------------------*/ 14 | /* Print ERROR if it fails. Tally success or failure. Odd */ 15 | /* do-while wrapper seems to be needed for some compilers. */ 16 | #define CHECK_TRUE(_exp, _on_error) \ 17 | do \ 18 | { \ 19 | if (_exp) {\ 20 | paQaNumPassed++; \ 21 | } \ 22 | else { \ 23 | printf("ERROR at %s:%d, (%s) not true\n", \ 24 | __FILE__, __LINE__, #_exp ); \ 25 | paQaNumFailed++; \ 26 | _on_error; \ 27 | } \ 28 | } while(0) 29 | 30 | #define ASSERT_TRUE(_exp) CHECK_TRUE(_exp, goto error) 31 | #define EXPECT_TRUE(_exp) CHECK_TRUE(_exp, (void)0) 32 | 33 | #define CHECK_AB(_a, _b, _op, _opn, _on_error) \ 34 | do \ 35 | { \ 36 | int mA = (int)(_a); \ 37 | int mB = (int)(_b); \ 38 | if (mA _op mB) {\ 39 | paQaNumPassed++; \ 40 | } \ 41 | else { \ 42 | printf("ERROR at %s:%d, (%s) %s (%s), %d %s %d\n", \ 43 | __FILE__, __LINE__, #_a, #_opn, #_b, mA, #_opn, mB ); \ 44 | paQaNumFailed++; \ 45 | _on_error; \ 46 | } \ 47 | } while(0) 48 | 49 | #define ASSERT_AB(_a, _b, _op, _opn) CHECK_AB(_a, _b, _op, _opn, goto error) 50 | #define ASSERT_EQ(_a, _b) ASSERT_AB(_a, _b, ==, !=) 51 | #define ASSERT_NE(_a, _b) ASSERT_AB(_a, _b, !=, ==) 52 | #define ASSERT_GT(_a, _b) ASSERT_AB(_a, _b, >, <=) 53 | #define ASSERT_GE(_a, _b) ASSERT_AB(_a, _b, >=, <) 54 | #define ASSERT_LT(_a, _b) ASSERT_AB(_a, _b, <, >=) 55 | #define ASSERT_LE(_a, _b) ASSERT_AB(_a, _b, <=, >) 56 | 57 | #define EXPECT_AB(_a, _b, _op, _opn) CHECK_AB(_a, _b, _op, _opn, (void)0) 58 | #define EXPECT_EQ(_a, _b) EXPECT_AB(_a, _b, ==, !=) 59 | #define EXPECT_NE(_a, _b) EXPECT_AB(_a, _b, !=, ==) 60 | #define EXPECT_GT(_a, _b) EXPECT_AB(_a, _b, >, <=) 61 | #define EXPECT_GE(_a, _b) EXPECT_AB(_a, _b, >=, <) 62 | #define EXPECT_LT(_a, _b) EXPECT_AB(_a, _b, <, >=) 63 | #define EXPECT_LE(_a, _b) EXPECT_AB(_a, _b, <=, >) 64 | 65 | #define HOPEFOR(_exp) \ 66 | do \ 67 | { \ 68 | if ((_exp)) {\ 69 | paQaNumPassed++; \ 70 | } \ 71 | else { \ 72 | printf("\nERROR - 0x%x - %s for %s\n", result, Pa_GetErrorText(result), #_exp ); \ 73 | paQaNumFailed++; \ 74 | } \ 75 | } while(0) 76 | 77 | #define PAQA_PRINT_RESULT \ 78 | printf("QA Report: %d passed, %d failed.\n", paQaNumPassed, paQaNumFailed ) 79 | 80 | #define PAQA_EXIT_RESULT \ 81 | (((paQaNumFailed > 0) || (paQaNumPassed == 0)) ? EXIT_FAILURE : EXIT_SUCCESS) 82 | 83 | #endif /* PORTAUDIO_QA_PAQA_MACROS_H */ 84 | -------------------------------------------------------------------------------- /doc/src/tutorial/compile_windows_mingw-w64.dox: -------------------------------------------------------------------------------- 1 | /** @page compile_windows_mingw-w64 Building PortAudio for Windows with MinGW-w64 2 | @ingroup tutorial 3 | 4 | @section comp_mingw-w64_1 PortAudio for Windows with MinGW-w64 5 | 6 | MinGW-w64 is a port of Linux toolchains (gcc, clang) to Windows. It comes packaged with Msys2 in its preferred configuration. Msys2 provides a Linux environment and the package manager pacman. 7 | Install MinGW-w64 from https://www.msys2.org/. Follow the instructions on this page. 8 | 9 | Brief excursion: there are many toolchain variants in Msys2, and you must use the same toolchain to compile all projects together. In this tutorial, we will use the msvcrt-gcc toolchain, simply because it's already present on all Windows versions. Readers may eventually want to switch to the ucrt-gcc toolchain later, for their Windows 10+ builds, although there is hardly any benefit to doing so. A list of available toolchains is at https://www.msys2.org/docs/environments/. 10 | 11 | In addition, you have a choice of Windows audio APIs; see the bottom of \ref compile_windows for a list. 12 | 13 | You can either use msys2's precompiled PortAudio or compile PortAudio yourself. To install msys2's precompiled PortAudio, see the next section. To compile PortAudio on your own, skip to the next next section. 14 | 15 | @section comp_mingw-w64_2 Pre-compiled package 16 | 17 | Open your msys2 shell and run "pacman -S mingw-w64-x86_64-portaudio". This will get you a default build of PortAudio. I believe it comes with DirectSound, WASAPI, WD/MKS, WD/MKS_DEVICE_INFO, and WMME. Note the "-x86_64" in the middle of the package name. When you install msys2 packages, you specify the toolchain name in the middle, and "-x86_64" chooses the msvcrt-gcc toolchain. 18 | 19 | @section comp_mingw-w64_3 Compiling from scratch 20 | 21 | We will build with WASAPI only, with no fallback APIs, simply as an example. In the msys2 shell, navigate into your folder of PortAudio. Run: 22 | 23 | @code 24 | pacman -S mingw-w64-x86_64-cmake mingw-w64-x86_64-ninja 25 | mkdir build 26 | cd build 27 | cmake -G Ninja .. -DCMAKE_BUILD_TYPE=Release -DPA_USE_DS=0 -DPA_USE_WDMKS=0 -DPA_USE_WDMKS_DEVICE_INFO=0 -DPA_USE_WMME=0 28 | cmake --build . 29 | @endcode 30 | 31 | To test if it is working, you can run the sawtooth example (warning, it is very loud!): 32 | 33 | @code 34 | gcc ../examples/paex_saw.c -I../src/common -lportaudio 35 | ./a.exe 36 | @endcode 37 | 38 | You can enable the desired fallback APIs again by deleting the terms like "-DPA_USE_WMME=0" in the cmake command. When releasing your application to the public, make sure to copy libportaudio.dll (in the build folder) into your own application's folder. (You'll also need to ship a copy of MinGW-w64's various shared libraries; you can figure out which ones using Microsoft's Process Explorer, and seeing which dlls are accessed from your msys64 folder.) 39 | 40 | Or, compile statically to avoid the issue of dll copies. 41 | 42 | Back to the Tutorial: \ref tutorial_start 43 | 44 | */ 45 | -------------------------------------------------------------------------------- /src/os/win/pa_win_version.h: -------------------------------------------------------------------------------- 1 | #ifndef PA_WIN_VERSION_H 2 | #define PA_WIN_VERSION_H 3 | 4 | /* 5 | * $Id$ 6 | * Portable Audio I/O Library 7 | * Win32 platform-specific support functions 8 | * 9 | * Based on the Open Source API proposed by Ross Bencina 10 | * Copyright (c) 1999-2008 Ross Bencina 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining 13 | * a copy of this software and associated documentation files 14 | * (the "Software"), to deal in the Software without restriction, 15 | * including without limitation the rights to use, copy, modify, merge, 16 | * publish, distribute, sublicense, and/or sell copies of the Software, 17 | * and to permit persons to whom the Software is furnished to do so, 18 | * subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be 21 | * included in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 26 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 27 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 28 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | /* 33 | * The text above constitutes the entire PortAudio license; however, 34 | * the PortAudio community also makes the following non-binding requests: 35 | * 36 | * Any person wishing to distribute modifications to the Software is 37 | * requested to send the modifications to the original developer so that 38 | * they can be incorporated into the canonical version. It is also 39 | * requested that these non-binding requests be included along with the 40 | * license above. 41 | */ 42 | 43 | #include "portaudio.h" 44 | 45 | #ifdef __cplusplus 46 | extern "C" 47 | { 48 | #endif /* __cplusplus */ 49 | 50 | /** 51 | Windows OS version. 52 | */ 53 | typedef enum PaOsVersion 54 | { 55 | paOsVersionWindowsUnknown = 0, 56 | paOsVersionWindows9x, // Windows 95, Windows 98, Windows ME 57 | paOsVersionWindowsNT4, 58 | paOsVersionWindows2000, 59 | paOsVersionWindowsXP, 60 | paOsVersionWindowsXPServer2003, 61 | paOsVersionWindowsVistaServer2008, 62 | paOsVersionWindows7Server2008R2, 63 | paOsVersionWindows8Server2012, 64 | paOsVersionWindows8_1Server2012R2, 65 | paOsVersionWindows10Server2016, 66 | // insert subsequent Windows versions below: 67 | // ... 68 | // paOsVersionWindowsFuture must be the last in the list 69 | paOsVersionWindowsFuture = 1000 70 | } PaOsVersion; 71 | 72 | /** 73 | Get Windows OS version. 74 | @return OS version via PaOsVersion enum. 75 | @see PaOsVersion 76 | */ 77 | PaOsVersion PaWinUtil_GetOsVersion(); 78 | 79 | #ifdef __cplusplus 80 | } 81 | #endif /* __cplusplus */ 82 | 83 | #endif /* PA_WIN_VERSION_H */ 84 | -------------------------------------------------------------------------------- /bindings/cpp/source/portaudiocpp/CppFunCallbackStream.cxx: -------------------------------------------------------------------------------- 1 | #include "portaudiocpp/CppFunCallbackStream.hxx" 2 | 3 | #include "portaudiocpp/StreamParameters.hxx" 4 | #include "portaudiocpp/Exception.hxx" 5 | 6 | namespace portaudio 7 | { 8 | namespace impl 9 | { 10 | ////// 11 | /// Adapts any a C++ callback to a C-callable function (ie this function). A 12 | /// pointer to a struct with the C++ function pointer and the actual user data should be 13 | /// passed as the ``userData'' parameter when setting up the callback. 14 | ////// 15 | int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, 16 | const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, void *userData) 17 | { 18 | FunCallbackStream::CppToCCallbackData *data = static_cast(userData); 19 | return data->funPtr(inputBuffer, outputBuffer, numFrames, timeInfo, statusFlags, data->userData); 20 | } 21 | } 22 | 23 | // ----------------------------------------------------------------------------------- 24 | 25 | FunCallbackStream::CppToCCallbackData::CppToCCallbackData() 26 | { 27 | } 28 | 29 | FunCallbackStream::CppToCCallbackData::CppToCCallbackData(CallbackFunPtr funPtr, void *userData) : funPtr(funPtr), userData(userData) 30 | { 31 | } 32 | 33 | void FunCallbackStream::CppToCCallbackData::init(CallbackFunPtr funPtr, void *userData) 34 | { 35 | this->funPtr = funPtr; 36 | this->userData = userData; 37 | } 38 | 39 | // ----------------------------------------------------------------------------------- 40 | 41 | FunCallbackStream::FunCallbackStream() 42 | { 43 | } 44 | 45 | FunCallbackStream::FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData) : adapterData_(funPtr, userData) 46 | { 47 | open(parameters); 48 | } 49 | 50 | FunCallbackStream::~FunCallbackStream() 51 | { 52 | try 53 | { 54 | close(); 55 | } 56 | catch (...) 57 | { 58 | // ignore all errors 59 | } 60 | } 61 | 62 | void FunCallbackStream::open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData) 63 | { 64 | adapterData_.init(funPtr, userData); 65 | open(parameters); 66 | } 67 | 68 | void FunCallbackStream::open(const StreamParameters ¶meters) 69 | { 70 | PaError err = Pa_OpenStream(&stream_, parameters.inputParameters().paStreamParameters(), parameters.outputParameters().paStreamParameters(), 71 | parameters.sampleRate(), parameters.framesPerBuffer(), parameters.flags(), &impl::cppCallbackToPaCallbackAdapter, 72 | static_cast(&adapterData_)); 73 | 74 | if (err != paNoError) 75 | { 76 | throw PaException(err); 77 | } 78 | } 79 | 80 | // ----------------------------------------------------------------------------------- 81 | } 82 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/StreamParameters.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX 2 | #define INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | #include "portaudiocpp/DirectionSpecificStreamParameters.hxx" 9 | 10 | // --------------------------------------------------------------------------------------- 11 | 12 | // Declaration(s): 13 | namespace portaudio 14 | { 15 | 16 | ////// 17 | /// @brief The entire set of parameters needed to configure and open 18 | /// a Stream. 19 | /// 20 | /// It contains parameters of input, output and shared parameters. 21 | /// Using the isSupported() method, the StreamParameters can be 22 | /// checked if opening a Stream using this StreamParameters would 23 | /// succeed or not. Accessors are provided to higher-level parameters 24 | /// aswell as the lower-level parameters which are mainly intended for 25 | /// internal use. 26 | ////// 27 | class StreamParameters 28 | { 29 | public: 30 | StreamParameters(); 31 | StreamParameters(const DirectionSpecificStreamParameters &inputParameters, 32 | const DirectionSpecificStreamParameters &outputParameters, double sampleRate, 33 | unsigned long framesPerBuffer, PaStreamFlags flags); 34 | 35 | // Set up for direction-specific: 36 | void setInputParameters(const DirectionSpecificStreamParameters ¶meters); 37 | void setOutputParameters(const DirectionSpecificStreamParameters ¶meters); 38 | 39 | // Set up for common parameters: 40 | void setSampleRate(double sampleRate); 41 | void setFramesPerBuffer(unsigned long framesPerBuffer); 42 | void setFlag(PaStreamFlags flag); 43 | void unsetFlag(PaStreamFlags flag); 44 | void clearFlags(); 45 | 46 | // Validation: 47 | bool isSupported() const; 48 | 49 | // Accessors (direction-specific): 50 | DirectionSpecificStreamParameters &inputParameters(); 51 | const DirectionSpecificStreamParameters &inputParameters() const; 52 | DirectionSpecificStreamParameters &outputParameters(); 53 | const DirectionSpecificStreamParameters &outputParameters() const; 54 | 55 | // Accessors (common): 56 | double sampleRate() const; 57 | unsigned long framesPerBuffer() const; 58 | PaStreamFlags flags() const; 59 | bool isFlagSet(PaStreamFlags flag) const; 60 | 61 | private: 62 | // Half-duplex specific parameters: 63 | DirectionSpecificStreamParameters inputParameters_; 64 | DirectionSpecificStreamParameters outputParameters_; 65 | 66 | // Common parameters: 67 | double sampleRate_; 68 | unsigned long framesPerBuffer_; 69 | PaStreamFlags flags_; 70 | }; 71 | 72 | 73 | } // namespace portaudio 74 | 75 | // --------------------------------------------------------------------------------------- 76 | 77 | #endif // INCLUDED_PORTAUDIO_STREAMPARAMETERS_HXX 78 | -------------------------------------------------------------------------------- /include/pa_jack.h: -------------------------------------------------------------------------------- 1 | #ifndef PA_JACK_H 2 | #define PA_JACK_H 3 | 4 | /* 5 | * $Id: 6 | * PortAudio Portable Real-Time Audio Library 7 | * JACK-specific extensions 8 | * 9 | * Copyright (c) 1999-2000 Ross Bencina and Phil Burk 10 | * 11 | * Permission is hereby granted, free of charge, to any person obtaining 12 | * a copy of this software and associated documentation files 13 | * (the "Software"), to deal in the Software without restriction, 14 | * including without limitation the rights to use, copy, modify, merge, 15 | * publish, distribute, sublicense, and/or sell copies of the Software, 16 | * and to permit persons to whom the Software is furnished to do so, 17 | * subject to the following conditions: 18 | * 19 | * The above copyright notice and this permission notice shall be 20 | * included in all copies or substantial portions of the Software. 21 | * 22 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 23 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 24 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 25 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 26 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 27 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 28 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 29 | */ 30 | 31 | /* 32 | * The text above constitutes the entire PortAudio license; however, 33 | * the PortAudio community also makes the following non-binding requests: 34 | * 35 | * Any person wishing to distribute modifications to the Software is 36 | * requested to send the modifications to the original developer so that 37 | * they can be incorporated into the canonical version. It is also 38 | * requested that these non-binding requests be included along with the 39 | * license above. 40 | */ 41 | 42 | /** @file 43 | * @ingroup public_header 44 | * @brief JACK-specific PortAudio API extension header file. 45 | */ 46 | 47 | #include "portaudio.h" 48 | 49 | #ifdef __cplusplus 50 | extern "C" { 51 | #endif 52 | 53 | /** Set the JACK client name. 54 | * 55 | * During Pa_Initialize, When PA JACK connects as a client of the JACK server, it requests a certain 56 | * name, which is for instance prepended to port names. By default this name is "PortAudio". The 57 | * JACK server may append a suffix to the client name, in order to avoid clashes among clients that 58 | * try to connect with the same name (e.g., different PA JACK clients). 59 | * 60 | * This function must be called before Pa_Initialize, otherwise it won't have any effect. Note that 61 | * the string is not copied, but instead referenced directly, so it must not be freed for as long as 62 | * PA might need it. 63 | * @sa PaJack_GetClientName 64 | */ 65 | PaError PaJack_SetClientName( const char* name ); 66 | 67 | /** Get the JACK client name used by PA JACK. 68 | * 69 | * The caller is responsible for freeing the returned pointer. 70 | */ 71 | PaError PaJack_GetClientName(const char** clientName); 72 | 73 | #ifdef __cplusplus 74 | } 75 | #endif 76 | 77 | #endif 78 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/CppFunCallbackStream.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX 2 | #define INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | #include "portaudiocpp/CallbackStream.hxx" 9 | 10 | // --------------------------------------------------------------------------------------- 11 | 12 | // Forward declaration(s): 13 | namespace portaudio 14 | { 15 | class StreamParameters; 16 | } 17 | 18 | // --------------------------------------------------------------------------------------- 19 | 20 | // Declaration(s): 21 | namespace portaudio 22 | { 23 | 24 | 25 | namespace impl 26 | { 27 | extern "C" 28 | { 29 | int cppCallbackToPaCallbackAdapter(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, 30 | const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, 31 | void *userData); 32 | } // extern "C" 33 | } 34 | 35 | // ----------------------------------------------------------------------------------- 36 | 37 | ////// 38 | /// @brief Callback stream using a C++ function (either a free function or a static function) 39 | /// callback. 40 | ////// 41 | class FunCallbackStream : public CallbackStream 42 | { 43 | public: 44 | typedef int (*CallbackFunPtr)(const void *inputBuffer, void *outputBuffer, unsigned long numFrames, 45 | const PaStreamCallbackTimeInfo *timeInfo, PaStreamCallbackFlags statusFlags, 46 | void *userData); 47 | 48 | // ------------------------------------------------------------------------------- 49 | 50 | ////// 51 | /// @brief Simple structure containing a function pointer to the C++ callback function and a 52 | /// (void) pointer to the user supplied data. 53 | ////// 54 | struct CppToCCallbackData 55 | { 56 | CppToCCallbackData(); 57 | CppToCCallbackData(CallbackFunPtr funPtr, void *userData); 58 | void init(CallbackFunPtr funPtr, void *userData); 59 | 60 | CallbackFunPtr funPtr; 61 | void *userData; 62 | }; 63 | 64 | // ------------------------------------------------------------------------------- 65 | 66 | FunCallbackStream(); 67 | FunCallbackStream(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); 68 | ~FunCallbackStream(); 69 | 70 | void open(const StreamParameters ¶meters, CallbackFunPtr funPtr, void *userData); 71 | 72 | private: 73 | FunCallbackStream(const FunCallbackStream &); // non-copyable 74 | FunCallbackStream &operator=(const FunCallbackStream &); // non-copyable 75 | 76 | CppToCCallbackData adapterData_; 77 | 78 | void open(const StreamParameters ¶meters); 79 | }; 80 | 81 | 82 | } // portaudio 83 | 84 | // --------------------------------------------------------------------------------------- 85 | 86 | #endif // INCLUDED_PORTAUDIO_CPPFUNCALLBACKSTREAM_HXX 87 | -------------------------------------------------------------------------------- /doc/utils/checkfiledocs.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import os 4 | import os.path 5 | 6 | paRootDirectory = '../../' 7 | paHtmlDocDirectory = os.path.join( paRootDirectory, "doc", "html" ) 8 | 9 | ## Script to check documentation status 10 | ## this script assumes that html doxygen documentation has been generated 11 | ## 12 | ## it then walks the entire portaudio source tree and check that 13 | ## - every source file (.c,.h,.cpp) has a doxygen comment block containing 14 | ## - a @file directive 15 | ## - a @brief directive 16 | ## - a @ingroup directive 17 | ## - it also checks that a corresponding html documentation file has been generated. 18 | ## 19 | ## This can be used as a first-level check to make sure the documentation is in order. 20 | ## 21 | ## The idea is to get a list of which files are missing doxygen documentation. 22 | ## 23 | ## How to run: 24 | ## $ cd doc/utils 25 | ## $ python checkfiledocs.py 26 | 27 | def oneOf_a_in_b(a, b): 28 | for x in a: 29 | if x in b: 30 | return True 31 | return False 32 | 33 | # recurse from top and return a list of all with the given 34 | # extensions. ignore .svn directories. return absolute paths 35 | def recursiveFindFiles( top, extensions, dirBlacklist, includePaths ): 36 | result = [] 37 | for (dirpath, dirnames, filenames) in os.walk(top): 38 | if not oneOf_a_in_b(dirBlacklist, dirpath): 39 | for f in filenames: 40 | if os.path.splitext(f)[1] in extensions: 41 | if includePaths: 42 | result.append( os.path.abspath( os.path.join( dirpath, f ) ) ) 43 | else: 44 | result.append( f ) 45 | return result 46 | 47 | # generate the html file name that doxygen would use for 48 | # a particular source file. this is a brittle conversion 49 | # which i worked out by trial and error 50 | def doxygenHtmlDocFileName( sourceFile ): 51 | return sourceFile.replace( '_', '__' ).replace( '.', '_8' ) + '.html' 52 | 53 | 54 | sourceFiles = recursiveFindFiles( os.path.join(paRootDirectory,'src'), [ '.c', '.h', '.cpp' ], ['.svn', 'mingw-include'], True ) 55 | sourceFiles += recursiveFindFiles( os.path.join(paRootDirectory,'include'), [ '.c', '.h', '.cpp' ], ['.svn'], True ) 56 | docFiles = recursiveFindFiles( paHtmlDocDirectory, [ '.html' ], ['.svn'], False ) 57 | 58 | 59 | 60 | currentFile = "" 61 | 62 | def printError( f, message ): 63 | global currentFile 64 | if f != currentFile: 65 | currentFile = f 66 | print(f, ":") 67 | print("\t!", message) 68 | 69 | 70 | for f in sourceFiles: 71 | if doxygenHtmlDocFileName( os.path.basename(f) ) not in docFiles: 72 | printError( f, "no doxygen generated doc page" ) 73 | 74 | s = open( f, 'rt' ).read() 75 | 76 | if '/**' not in s: 77 | printError( f, "no doxygen /** block" ) 78 | 79 | if '@file' not in s: 80 | printError( f, "no doxygen @file tag" ) 81 | 82 | if '@brief' not in s: 83 | printError( f, "no doxygen @brief tag" ) 84 | 85 | if '@ingroup' not in s: 86 | printError( f, "no doxygen @ingroup tag" ) 87 | -------------------------------------------------------------------------------- /.github/workflows/autotools_msys2.yml: -------------------------------------------------------------------------------- 1 | name: MSYS2 autotools build (Windows) 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | env: 10 | # GitHub CI Actions-specific environment variables: 11 | 12 | # Location for user-local `make install` 13 | PORTAUDIO_INSTALL_DIR: ${HOME}/.local 14 | 15 | # Environment variables for compiling and running the test program. 16 | # Usually none of this is needed as `make install` would install to system locations 17 | # where include and library search paths are already set up to just work. 18 | # gcc environment variables. see https://gcc.gnu.org/onlinedocs/gcc/Environment-Variables.html 19 | C_INCLUDE_PATH: ${HOME}/.local/include 20 | LIBRARY_PATH: ${HOME}/.local/lib 21 | # LD_LIBRARY_PATH: ${HOME}/.local/lib 22 | # NOTE: msys2 doesn't use LD_LIBRARY_PATH. .dll files are installed in .local/bin 23 | # so add ./local/bin to PATH 24 | BIN_PATH: ${HOME}/.local/bin 25 | 26 | jobs: 27 | msys2-ucrt64: 28 | # based on official recommended msys2 CI setup. see: https://www.msys2.org/docs/ci/ 29 | runs-on: windows-latest 30 | defaults: 31 | run: 32 | shell: msys2 {0} 33 | steps: 34 | - name: checkout PortAudio git repo 35 | uses: actions/checkout@v3 36 | - name: setup msys2 37 | uses: msys2/setup-msys2@v2 38 | with: 39 | msystem: UCRT64 40 | update: true 41 | install: git mingw-w64-ucrt-x86_64-gcc 42 | # regenerate configure script due to MSYS2 "Known Issues" see: https://www.msys2.org/docs/autotools/ 43 | - name: setup autotools for autoreconf 44 | run: | 45 | pacman --noconfirm -S "${MINGW_PACKAGE_PREFIX}-autotools" 46 | pacman --noconfirm -S "autoconf-archive" 47 | - name: autoreconf 48 | run: | 49 | autoreconf -fvi 50 | # test configure and build 51 | - name: configure 52 | run: ./configure --prefix=${{ env.PORTAUDIO_INSTALL_DIR }} 53 | - name: make 54 | run: make 55 | # test make install 56 | - name: install 57 | run: make install 58 | - name: list install dirs (post-install) 59 | run: ls ${{ env.PORTAUDIO_INSTALL_DIR }} ${{ env.BIN_PATH }} ${{ env.C_INCLUDE_PATH }} ${{ env.LIBRARY_PATH }} 60 | - name: build patest_init.c (test just calls Pa_Initialize();Pa_Terminate();) 61 | run: | 62 | C_INCLUDE_PATH=${{ env.C_INCLUDE_PATH }} 63 | LIBRARY_PATH=${{ env.LIBRARY_PATH }} 64 | gcc -o patest_init.exe ./test/patest_init.c -lportaudio 65 | ls 66 | - name: run patest_init.exe 67 | run: | 68 | export PATH=${{ env.BIN_PATH }}:$PATH 69 | ./patest_init.exe 70 | # test make uninstall 71 | - name: uninstall 72 | run: make uninstall 73 | - name: list install dirs (post-uninstall) 74 | run: ls ${{ env.PORTAUDIO_INSTALL_DIR }} ${{ env.BIN_PATH }} ${{ env.C_INCLUDE_PATH }} ${{ env.LIBRARY_PATH }} 75 | - name: build patest_init.c to check uninstall (expect failure) 76 | run: | 77 | C_INCLUDE_PATH=${{ env.C_INCLUDE_PATH }} 78 | LIBRARY_PATH=${{ env.LIBRARY_PATH }} 79 | if gcc -o patest_init.exe ./test/patest_init.c -lportaudio; then exit 1; else exit 0; fi 80 | -------------------------------------------------------------------------------- /bindings/cpp/cmake/modules/FindASIO.cmake: -------------------------------------------------------------------------------- 1 | #[=======================================================================[.rst: 2 | FindASIO 3 | -------- 4 | 5 | Finds the ASIO SDK by searching for the SDK ZIP in CMAKE_PREFIX_PATH and 6 | CMAKE_CURRENT_BINARY_DIR. Alternatively, you may manually specify the path of 7 | the SDK ZIP with the ASIO_SDK_ZIP_PATH variable, which can be used for caching 8 | in CI scripts. 9 | 10 | If the ZIP is found, this module extracts it. 11 | The ZIP extraction is skipped if the unzipped SDK is found. 12 | 13 | This module provides an `ASIO::host` IMPORT library target for building host 14 | applications which use ASIO drivers. If you want to build an ASIO driver, this 15 | module may serve as a useful start but you will need to modify it. 16 | 17 | #]=======================================================================] 18 | 19 | if(NOT WIN32) 20 | message(WARNING "ASIO is only supported on Windows.") 21 | set(ASIO_FOUND OFF) 22 | return() 23 | endif() 24 | 25 | file(GLOB HEADER_FILE 26 | "${CMAKE_CURRENT_BINARY_DIR}/asiosdk*/common/asio.h" 27 | "${CMAKE_PREFIX_PATH}/asiosdk*/common/asio.h" 28 | # The old build systems before PortAudio 19.8 used to look for the ASIO SDK 29 | # in the same parent directory as the source code repository. This is no 30 | # longer advised or documented but kept for backwards compatibility. 31 | "${CMAKE_CURRENT_SOURCE_DIR}/../asiosdk*/common/asio.h" 32 | ) 33 | if(NOT EXISTS "${HEADER_FILE}") 34 | # The file(ARCHIVE_EXTRACT) command was added in CMake 3.18, so if using an 35 | # older version of CMake, the user needs to extract it themselves. 36 | if(CMAKE_VERSION VERSION_LESS 3.18) 37 | message(STATUS "ASIO SDK NOT found. Download the ASIO SDK ZIP from " 38 | "https://www.steinberg.net/asiosdk and extract it to " 39 | "${CMAKE_PREFIX_PATH} or ${CMAKE_CURRENT_BINARY_DIR}" 40 | ) 41 | return() 42 | endif() 43 | file(GLOB results 44 | "${ASIO_SDK_ZIP_PATH}" 45 | "${CMAKE_CURRENT_BINARY_DIR}/asiosdk*.zip" 46 | "${CMAKE_PREFIX_PATH}/asiosdk*.zip" 47 | "${CMAKE_CURRENT_SOURCE_DIR}/../asiosdk*.zip" 48 | ) 49 | foreach(f ${results}) 50 | if(EXISTS "${f}") 51 | message(STATUS "Extracting ASIO SDK ZIP archive: ${f}") 52 | file(ARCHIVE_EXTRACT INPUT "${f}" DESTINATION "${CMAKE_CURRENT_BINARY_DIR}") 53 | endif() 54 | endforeach() 55 | file(GLOB HEADER_FILE "${CMAKE_CURRENT_BINARY_DIR}/asiosdk*/common/asio.h") 56 | endif() 57 | 58 | get_filename_component(HEADER_DIR "${HEADER_FILE}" DIRECTORY) 59 | get_filename_component(ASIO_ROOT "${HEADER_DIR}" DIRECTORY) 60 | 61 | if(ASIO_ROOT) 62 | set(ASIO_FOUND TRUE) 63 | message(STATUS "Found ASIO SDK: ${ASIO_ROOT}") 64 | 65 | if(ASIO_FOUND AND NOT TARGET ASIO::host) 66 | add_library(ASIO::host INTERFACE IMPORTED) 67 | target_sources(ASIO::host INTERFACE 68 | "${ASIO_ROOT}/common/asio.cpp" 69 | "${ASIO_ROOT}/host/asiodrivers.cpp" 70 | "${ASIO_ROOT}/host/pc/asiolist.cpp" 71 | ) 72 | target_include_directories(ASIO::host INTERFACE 73 | "${ASIO_ROOT}/common" 74 | "${ASIO_ROOT}/host" 75 | "${ASIO_ROOT}/host/pc" 76 | ) 77 | target_link_libraries(ASIO::host INTERFACE ole32 uuid) 78 | endif() 79 | else() 80 | message(STATUS "ASIO SDK NOT found") 81 | endif() 82 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # PortAudio - portable audio I/O library 2 | 3 | PortAudio is a portable audio I/O library designed for cross-platform 4 | support of audio. It uses either a callback mechanism to request audio 5 | processing, or blocking read/write calls to buffer data between the 6 | native audio subsystem and the client. Audio can be processed in various 7 | formats, including 32 bit floating point, and will be converted to the 8 | native format internally. 9 | 10 | ## Documentation: 11 | 12 | * Documentation is available at http://www.portaudio.com/docs/ 13 | * Or at `/doc/html/index.html` after running Doxygen. 14 | * Also see `src/common/portaudio.h` for the API spec. 15 | * And see the `examples/` and `test/` directories for many examples of usage. (We suggest `examples/paex_saw.c` for an example.) 16 | 17 | For information on compiling programs with PortAudio, please see the 18 | tutorial at: 19 | 20 | http://portaudio.com/docs/v19-doxydocs/tutorial_start.html 21 | 22 | We have an active mailing list for user and developer discussions. 23 | Please feel free to join. See http://www.portaudio.com for details. 24 | 25 | ## Important Files and Folders: 26 | 27 | include/portaudio.h = header file for PortAudio API. Specifies API. 28 | src/common/ = platform independent code, host independent 29 | code for all implementations. 30 | src/os = os specific (but host api neutral) code 31 | src/hostapi = implementations for different host apis 32 | 33 | 34 | ### Host API Implementations: 35 | 36 | src/hostapi/alsa = Advanced Linux Sound Architecture (ALSA) 37 | src/hostapi/asihpi = AudioScience HPI 38 | src/hostapi/asio = ASIO for Windows and Macintosh 39 | src/hostapi/audioio = /dev/audio (Solaris/NetBSD Audio) 40 | src/hostapi/coreaudio = Macintosh Core Audio for OS X 41 | src/hostapi/dsound = Windows Direct Sound 42 | src/hostapi/jack = JACK Audio Connection Kit 43 | src/hostapi/oss = Unix Open Sound System (OSS) 44 | src/hostapi/pulseaudio = Sound system for POSIX OSes 45 | src/hostapi/sndio = Small audio and MIDI framework (sndio) 46 | src/hostapi/wasapi = Windows Vista WASAPI 47 | src/hostapi/wdmks = Windows WDM Kernel Streaming 48 | src/hostapi/wmme = Windows MultiMedia Extensions (MME) 49 | 50 | 51 | ### Test Programs: 52 | 53 | test/pa_fuzz.c = guitar fuzz box 54 | test/pa_devs.c = print a list of available devices 55 | test/pa_minlat.c = determine minimum latency for your machine 56 | test/paqa_devs.c = self test that opens all devices 57 | test/paqa_errs.c = test error detection and reporting 58 | test/patest_clip.c = hear a sine wave clipped and unclipped 59 | test/patest_dither.c = hear effects of dithering (extremely subtle) 60 | test/patest_pink.c = fun with pink noise 61 | test/patest_record.c = record and playback some audio 62 | test/patest_maxsines.c = how many sine waves can we play? Tests Pa_GetCPULoad(). 63 | test/patest_sine.c = output a sine wave in a simple PA app 64 | test/patest_sync.c = test synchronization of audio and video 65 | test/patest_wire.c = pass input to output, wire simulator 66 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/Device.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_DEVICE_HXX 2 | #define INCLUDED_PORTAUDIO_DEVICE_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include 7 | 8 | #include "portaudio.h" 9 | 10 | #include "portaudiocpp/SampleDataFormat.hxx" 11 | 12 | // --------------------------------------------------------------------------------------- 13 | 14 | // Forward declaration(s): 15 | namespace portaudio 16 | { 17 | class System; 18 | class HostApi; 19 | } 20 | 21 | // --------------------------------------------------------------------------------------- 22 | 23 | // Declaration(s): 24 | namespace portaudio 25 | { 26 | 27 | ////// 28 | /// @brief Class which represents a PortAudio device in the System. 29 | /// 30 | /// A single physical device in the system may have multiple PortAudio 31 | /// Device representations using different HostApi 's though. A Device 32 | /// can be half-duplex or full-duplex. A half-duplex Device can be used 33 | /// to create a half-duplex Stream. A full-duplex Device can be used to 34 | /// create a full-duplex Stream. If supported by the HostApi, two 35 | /// half-duplex Devices can even be used to create a full-duplex Stream. 36 | /// 37 | /// Note that Device objects are very light-weight and can be passed around 38 | /// by-value. 39 | ////// 40 | class Device 41 | { 42 | public: 43 | // query info: name, max in channels, max out channels, 44 | // default low/high input/output latency, default sample rate 45 | PaDeviceIndex index() const; 46 | const char *name() const; 47 | int maxInputChannels() const; 48 | int maxOutputChannels() const; 49 | PaTime defaultLowInputLatency() const; 50 | PaTime defaultHighInputLatency() const; 51 | PaTime defaultLowOutputLatency() const; 52 | PaTime defaultHighOutputLatency() const; 53 | double defaultSampleRate() const; 54 | 55 | bool isInputOnlyDevice() const; // extended 56 | bool isOutputOnlyDevice() const; // extended 57 | bool isFullDuplexDevice() const; // extended 58 | bool isSystemDefaultInputDevice() const; // extended 59 | bool isSystemDefaultOutputDevice() const; // extended 60 | bool isHostApiDefaultInputDevice() const; // extended 61 | bool isHostApiDefaultOutputDevice() const; // extended 62 | 63 | bool operator==(const Device &rhs) const; 64 | bool operator!=(const Device &rhs) const; 65 | 66 | // host api reference 67 | HostApi &hostApi(); 68 | const HostApi &hostApi() const; 69 | 70 | private: 71 | PaDeviceIndex index_; 72 | const PaDeviceInfo *info_; 73 | 74 | private: 75 | friend class System; 76 | 77 | explicit Device(PaDeviceIndex index); 78 | ~Device(); 79 | 80 | Device(const Device &); // non-copyable 81 | Device &operator=(const Device &); // non-copyable 82 | }; 83 | 84 | // ----------------------------------------------------------------------------------- 85 | 86 | } // namespace portaudio 87 | 88 | // --------------------------------------------------------------------------------------- 89 | 90 | #endif // INCLUDED_PORTAUDIO_DEVICE_HXX 91 | -------------------------------------------------------------------------------- /doc/src/mainpage.dox: -------------------------------------------------------------------------------- 1 | /* doxygen index page */ 2 | /** @mainpage 3 | 4 | @section overview Overview 5 | 6 | PortAudio is a cross-platform, open-source C language library for real-time audio input and output. 7 | The library provides functions that allow your software to acquire and output real-time audio streams from your computer's hardware audio interfaces. It is designed to simplify writing cross-platform audio applications, and also to simplify the development of audio software in general by hiding the complexities of dealing directly with each native audio API. PortAudio is used to implement sound recording, editing and mixing applications, software synthesizers, effects processors, music players, internet telephony applications, software defined radios and more. Supported platforms include MS Windows, Mac OS X and Linux. Third-party language bindings make it possible to call PortAudio from other programming languages including @ref java_binding "Java", C++, C#, Python, PureBasic, FreePascal and Lazarus. 8 | 9 | @section start_here Start here 10 | 11 | - @ref api_overview
12 | A top-down view of the PortAudio API, its capabilities, functions and data structures 13 | 14 | - @ref tutorial_start
15 | Get started writing code with PortAudio tutorials 16 | 17 | - @ref examples_src "Examples"
18 | Simple example programs demonstrating PortAudio usage 19 | 20 | - @ref License
21 | PortAudio is licenced under the MIT Expat open source licence. We make a non-binding request for you to contribute your changes back to the project. 22 | 23 | 24 | @section reference API Reference 25 | 26 | - portaudio.h Portable API
27 | Detailed documentation for each portable API function and data type 28 | 29 | - @ref public_header "Host API Specific Extensions"
30 | Documentation for non-portable platform-specific host API extensions 31 | 32 | 33 | @section resources Resources 34 | 35 | - The PortAudio website 36 | 37 | - Our mailing list for users and developers
38 | 39 | - The PortAudio wiki 40 | 41 | @section developer_resources Developer Resources 42 | 43 | @if INTERNAL 44 | - @ref srcguide 45 | @endif 46 | 47 | - Our repository on GitHub 48 | 49 | - Developer guidelines 50 | 51 | - Implementation style guidelines 52 | 53 | If you're interested in helping out with PortAudio development we're more than happy for you to be involved. 54 | Just drop by the PortAudio mailing list and ask how you can help. 55 | Or check out these 56 | recommended starter issues. 57 | 58 | @section older_api_versions Older API Versions 59 | 60 | This documentation covers the current API version: PortAudio V19, API version 2.0. API 2.0 differs in a number of ways from previous versions (most often encountered in PortAudio V18), please consult the enhancement proposals for details of what was added/changed for V19: 61 | http://www.portaudio.com/docs/proposals/index.html 62 | 63 | */ 64 | -------------------------------------------------------------------------------- /qa/loopback/src/qa_tools.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * PortAudio Portable Real-Time Audio Library 4 | * Latest Version at: http://www.portaudio.com 5 | * 6 | * Copyright (c) 1999-2010 Phil Burk and Ross Bencina 7 | * 8 | * Permission is hereby granted, free of charge, to any person obtaining 9 | * a copy of this software and associated documentation files 10 | * (the "Software"), to deal in the Software without restriction, 11 | * including without limitation the rights to use, copy, modify, merge, 12 | * publish, distribute, sublicense, and/or sell copies of the Software, 13 | * and to permit persons to whom the Software is furnished to do so, 14 | * subject to the following conditions: 15 | * 16 | * The above copyright notice and this permission notice shall be 17 | * included in all copies or substantial portions of the Software. 18 | * 19 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 20 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 21 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 22 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 23 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 24 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 25 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 26 | */ 27 | 28 | /* 29 | * The text above constitutes the entire PortAudio license; however, 30 | * the PortAudio community also makes the following non-binding requests: 31 | * 32 | * Any person wishing to distribute modifications to the Software is 33 | * requested to send the modifications to the original developer so that 34 | * they can be incorporated into the canonical version. It is also 35 | * requested that these non-binding requests be included along with the 36 | * license above. 37 | */ 38 | 39 | #ifndef _QA_TOOLS_H 40 | #define _QA_TOOLS_H 41 | 42 | extern int g_testsPassed; 43 | extern int g_testsFailed; 44 | 45 | #define QA_ASSERT_TRUE( message, flag ) \ 46 | if( !(flag) ) \ 47 | { \ 48 | printf( "%s:%d - ERROR - %s\n", __FILE__, __LINE__, message ); \ 49 | g_testsFailed++; \ 50 | goto error; \ 51 | } \ 52 | else g_testsPassed++; 53 | 54 | 55 | #define QA_ASSERT_EQUALS( message, expected, actual ) \ 56 | if( ((expected) != (actual)) ) \ 57 | { \ 58 | printf( "%s:%d - ERROR - %s, expected %d, got %d\n", __FILE__, __LINE__, message, expected, actual ); \ 59 | g_testsFailed++; \ 60 | goto error; \ 61 | } \ 62 | else g_testsPassed++; 63 | 64 | #define QA_ASSERT_CLOSE( message, expected, actual, tolerance ) \ 65 | if (fabs((expected)-(actual))>(tolerance)) \ 66 | { \ 67 | printf( "%s:%d - ERROR - %s, expected %f, got %f, tol=%f\n", __FILE__, __LINE__, message, ((double)(expected)), ((double)(actual)), ((double)(tolerance)) ); \ 68 | g_testsFailed++; \ 69 | goto error; \ 70 | } \ 71 | else g_testsPassed++; 72 | 73 | #define QA_ASSERT_CLOSE_INT( message, expected, actual, tolerance ) \ 74 | if (abs((expected)-(actual))>(tolerance)) \ 75 | { \ 76 | printf( "%s:%d - ERROR - %s, expected %d, got %d, tol=%d\n", __FILE__, __LINE__, message, ((int)(expected)), ((int)(actual)), ((int)(tolerance)) ); \ 77 | g_testsFailed++; \ 78 | goto error; \ 79 | } \ 80 | else g_testsPassed++; 81 | 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /bindings/cpp/include/portaudiocpp/System.hxx: -------------------------------------------------------------------------------- 1 | #ifndef INCLUDED_PORTAUDIO_SYSTEM_HXX 2 | #define INCLUDED_PORTAUDIO_SYSTEM_HXX 3 | 4 | // --------------------------------------------------------------------------------------- 5 | 6 | #include "portaudio.h" 7 | 8 | // --------------------------------------------------------------------------------------- 9 | 10 | // Forward declaration(s): 11 | namespace portaudio 12 | { 13 | class Device; 14 | class Stream; 15 | class HostApi; 16 | } 17 | 18 | // --------------------------------------------------------------------------------------- 19 | 20 | // Declaration(s): 21 | namespace portaudio 22 | { 23 | 24 | 25 | ////// 26 | /// @brief System singleton which represents the PortAudio system. 27 | /// 28 | /// The System is used to initialize/terminate PortAudio and provide 29 | /// a single access point to the PortAudio System (instance()). 30 | /// It can be used to iterate through all HostApi 's in the System as 31 | /// well as all devices in the System. It also provides some utility 32 | /// functionality of PortAudio. 33 | /// 34 | /// Terminating the System will also abort and close the open streams. 35 | /// The Stream objects will need to be deallocated by the client though 36 | /// (it's usually a good idea to have them cleaned up automatically). 37 | ////// 38 | class System 39 | { 40 | public: 41 | class HostApiIterator; // forward declaration 42 | class DeviceIterator; // forward declaration 43 | 44 | // ------------------------------------------------------------------------------- 45 | 46 | static int version(); 47 | static const char *versionText(); 48 | 49 | static void initialize(); 50 | static void terminate(); 51 | 52 | static System &instance(); 53 | static bool exists(); 54 | 55 | // ------------------------------------------------------------------------------- 56 | 57 | // host apis: 58 | HostApiIterator hostApisBegin(); 59 | HostApiIterator hostApisEnd(); 60 | 61 | HostApi &defaultHostApi(); 62 | 63 | HostApi &hostApiByTypeId(PaHostApiTypeId type); 64 | HostApi &hostApiByIndex(PaHostApiIndex index); 65 | 66 | int hostApiCount(); 67 | 68 | // ------------------------------------------------------------------------------- 69 | 70 | // devices: 71 | DeviceIterator devicesBegin(); 72 | DeviceIterator devicesEnd(); 73 | 74 | Device &defaultInputDevice(); 75 | Device &defaultOutputDevice(); 76 | 77 | Device &deviceByIndex(PaDeviceIndex index); 78 | 79 | int deviceCount(); 80 | 81 | static Device &nullDevice(); 82 | 83 | // ------------------------------------------------------------------------------- 84 | 85 | // misc: 86 | void sleep(long msec); 87 | int sizeOfSample(PaSampleFormat format); 88 | 89 | private: 90 | System(); 91 | ~System(); 92 | 93 | static System *instance_; 94 | static int initCount_; 95 | 96 | static HostApi **hostApis_; 97 | static Device **devices_; 98 | 99 | static Device *nullDevice_; 100 | }; 101 | 102 | 103 | } // namespace portaudio 104 | 105 | 106 | #endif // INCLUDED_PORTAUDIO_SYSTEM_HXX 107 | -------------------------------------------------------------------------------- /bindings/cpp/build/gnu/Makefile.in: -------------------------------------------------------------------------------- 1 | # 2 | # Makefile template for PortAudioCpp 3 | # Ludwig Schwardt 4 | # 01/10/2003 5 | # 6 | # Not much to edit here - rather check configure.ac 7 | # 8 | 9 | PREFIX = @prefix@ 10 | CC = @CC@ 11 | CXX = @CXX@ 12 | CFLAGS = @CFLAGS@ @DEFS@ 13 | CXXFLAGS = @CXXFLAGS@ 14 | SHARED_FLAGS = @SHARED_FLAGS@ 15 | LIBS = @LIBS@ 16 | DLL_LIBS = @DLL_LIBS@ 17 | AR = @AR@ 18 | RANLIB = @RANLIB@ 19 | INSTALL = @INSTALL@ 20 | 21 | PACPP_ROOT = @PACPP_ROOT@ 22 | PORTAUDIO = @PORTAUDIO@ 23 | PADLL = @PADLL@ 24 | PACPP_DLL = @PACPP_DLL@ 25 | PALIB = libportaudio.a 26 | PACPP_LIB = libportaudiocpp.a 27 | PACPP_DLLV = $(PACPP_DLL).0.0.12 28 | 29 | SRCDIR = $(PACPP_ROOT)/source/portaudiocpp 30 | BINDIR = $(PACPP_ROOT)/example 31 | LIBDIR = $(PACPP_ROOT)/lib 32 | DOCDIR = $(PACPP_ROOT)/doc 33 | 34 | OBJS = \ 35 | $(SRCDIR)/BlockingStream.o \ 36 | $(SRCDIR)/CallbackInterface.o \ 37 | $(SRCDIR)/CallbackStream.o \ 38 | $(SRCDIR)/CFunCallbackStream.o \ 39 | $(SRCDIR)/CppFunCallbackStream.o \ 40 | $(SRCDIR)/Device.o \ 41 | $(SRCDIR)/DirectionSpecificStreamParameters.o \ 42 | $(SRCDIR)/Exception.o \ 43 | $(SRCDIR)/HostApi.o \ 44 | $(SRCDIR)/InterfaceCallbackStream.o \ 45 | $(SRCDIR)/MemFunCallbackStream.o \ 46 | $(SRCDIR)/Stream.o \ 47 | $(SRCDIR)/StreamParameters.o \ 48 | $(SRCDIR)/System.o \ 49 | $(SRCDIR)/SystemDeviceIterator.o \ 50 | $(SRCDIR)/SystemHostApiIterator.o 51 | 52 | # Not supported yet 53 | # $(SRCDIR)/AsioDeviceAdapter.o 54 | 55 | EXAMPLES = \ 56 | $(BINDIR)/devs \ 57 | $(BINDIR)/sine 58 | 59 | .PHONY: all clean docs 60 | 61 | all: $(EXAMPLES) $(LIBDIR)/$(PACPP_LIB) $(LIBDIR)/$(PACPP_DLL) 62 | 63 | clean: 64 | rm -rf $(SRCDIR)/*.o $(BINDIR)/*.o $(EXAMPLES) $(LIBDIR) $(DOCDIR)/api_reference 65 | rm -rf autom4te.cache config.status config.log 66 | 67 | docs: 68 | cd $(DOCDIR); doxygen config.doxy.linux 69 | 70 | %.o: %.c 71 | $(CC) -c $(CFLAGS) $< -o $@ 72 | 73 | %.o: %.cxx 74 | $(CXX) -c $(CXXFLAGS) $< -o $@ 75 | 76 | 77 | $(EXAMPLES): $(BINDIR)/%: $(BINDIR)/%.o $(OBJS) 78 | $(CXX) $^ -o $@ $(LIBS) 79 | 80 | $(LIBDIR)/$(PACPP_LIB): $(LIBDIR) $(OBJS) 81 | $(AR) ruv $(LIBDIR)/$(PACPP_LIB) $(OBJS) 82 | $(RANLIB) $(LIBDIR)/$(PACPP_LIB) 83 | 84 | $(LIBDIR)/$(PACPP_DLLV): $(LIBDIR) $(OBJS) 85 | $(CXX) $(SHARED_FLAGS) -o $(LIBDIR)/$(PACPP_DLLV) $(OBJS) $(DLL_LIBS) 86 | 87 | $(LIBDIR)/$(PACPP_DLL): $(LIBDIR) $(OBJS) 88 | $(CXX) $(SHARED_FLAGS) -o $(LIBDIR)/$(PACPP_DLL) $(OBJS) $(DLL_LIBS) 89 | 90 | #install: $(LIBDIR)/$(PACPP_LIB) $(LIBDIR)/$(PACPP_DLLV) 91 | # $(INSTALL) -m 644 $(LIBDIR)/$(PACPP_DLLV) $(PREFIX)/lib/$(PACPP_DLLV) 92 | # $(INSTALL) -m 644 $(LIBDIR)/$(PACPP_LIB) $(PREFIX)/lib/$(PACPP_LIB) 93 | # cd $(PREFIX)/lib && rm -f $(PACPP_DLL) && ln -s $(PACPP_DLLV) $(PACPP_DLL) 94 | # @echo "" 95 | # @echo "------------------------------------------------------------" 96 | # @echo "PortAudioCpp was successfully installed." 97 | # @echo "" 98 | # @echo "On some systems (e.g. Linux) you should run 'ldconfig' now" 99 | # @echo "to make the shared object available. You may also need to" 100 | # @echo "modify your LD_LIBRARY_PATH environment variable to include" 101 | # @echo "the directory $(PREFIX)/lib" 102 | # @echo "------------------------------------------------------------" 103 | # @echo "" 104 | 105 | $(LIBDIR): 106 | mkdir $(LIBDIR) 107 | -------------------------------------------------------------------------------- /src/hostapi/pulseaudio/pa_linux_pulseaudio_block_internal.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * PulseAudio host to play natively in Linux based systems without 4 | * ALSA emulation 5 | * 6 | * Copyright (c) 2014-2023 Tuukka Pasanen 7 | * Copyright (c) 2016 Sqweek 8 | * 9 | * Based on the Open Source API proposed by Ross Bencina 10 | * Copyright (c) 1999-2002 Ross Bencina, Phil Burk 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining 13 | * a copy of this software and associated documentation files 14 | * (the "Software"), to deal in the Software without restriction, 15 | * including without limitation the rights to use, copy, modify, merge, 16 | * publish, distribute, sublicense, and/or sell copies of the Software, 17 | * and to permit persons to whom the Software is furnished to do so, 18 | * subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be 21 | * included in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 26 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 27 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 28 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | /* 33 | * The text above constitutes the entire PortAudio license; however, 34 | * the PortAudio community also makes the following non-binding requests: 35 | * 36 | * Any person wishing to distribute modifications to the Software is 37 | * requested to send the modifications to the original developer so that 38 | * they can be incorporated into the canonical version. It is also 39 | * requested that these non-binding requests be included along with the 40 | * license above. 41 | */ 42 | 43 | #ifndef _PA_HOSTAPI_PULSEAUDIO_BLOCK_H_ 44 | #define _PA_HOSTAPI_PULSEAUDIO_BLOCK_H_ 45 | 46 | #include "pa_util.h" 47 | #include "pa_allocation.h" 48 | #include "pa_hostapi.h" 49 | #include "pa_stream.h" 50 | #include "pa_cpuload.h" 51 | #include "pa_process.h" 52 | 53 | #include "pa_unix_util.h" 54 | #include "pa_ringbuffer.h" 55 | 56 | /* PulseAudio headers */ 57 | #include 58 | #include 59 | #include 60 | 61 | #include "pa_linux_pulseaudio_internal.h" 62 | 63 | #ifdef __cplusplus 64 | extern "C" 65 | { 66 | #endif /* __cplusplus */ 67 | 68 | PaError PaPulseAudio_CloseStreamBlock( PaStream * stream ); 69 | 70 | PaError PaPulseAudio_StartStreamBlock( PaStream * stream ); 71 | 72 | PaError PaPulseAudio_StopStreamBlock( PaStream * stream ); 73 | 74 | PaError PaPulseAudio_AbortStreamBlock( PaStream * stream ); 75 | 76 | PaError PaPulseAudio_ReadStreamBlock( PaStream * stream, 77 | void *buffer, 78 | unsigned long frames ); 79 | 80 | PaError PaPulseAudio_WriteStreamBlock( PaStream * stream, 81 | const void *buffer, 82 | unsigned long frames ); 83 | 84 | signed long PaPulseAudio_GetStreamReadAvailableBlock( PaStream * stream ); 85 | 86 | #ifdef __cplusplus 87 | } 88 | #endif /* __cplusplus */ 89 | 90 | 91 | #endif 92 | -------------------------------------------------------------------------------- /doc/src/tutorial/tutorial_start.dox: -------------------------------------------------------------------------------- 1 | /** @page tutorial_start PortAudio Tutorials 2 | @ingroup tutorial 3 | 4 | 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 @ref api_overview. 5 | 6 | @section tut_start1 Downloading 7 | 8 | First thing you need to do is download the PortAudio source code either as a tarball from the website, or from the Subversion Repository. 9 | 10 | @section tut_start2 Compiling 11 | 12 | Once you've downloaded PortAudio you'll need to compile it, which of course, depends on your environment: 13 | 14 | - Windows 15 | - \ref compile_windows 16 | - \ref compile_windows_mingw-w64 17 | - \ref compile_windows_mingw 18 | - \ref compile_windows_asio_msvc 19 | - Mac OS X 20 | - \ref compile_mac_coreaudio 21 | - POSIX 22 | - \ref compile_linux 23 | 24 | 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 \ref compile_cmake. 25 | 26 | Many platforms with GCC/make can use the simple ./configure && make combination and simply use the resulting libraries in their code. 27 | 28 | @section tut_start3 Programming with PortAudio 29 | 30 | Below are the steps to writing a PortAudio application using the callback technique: 31 | 32 | - Write a callback function that will be called by PortAudio when audio processing is needed. 33 | - Initialize the PA library and open a stream for audio I/O. 34 | - Start the stream. Your callback function will be now be called repeatedly by PA in the background. 35 | - In your callback you can read audio data from the inputBuffer and/or write data to the outputBuffer. 36 | - Stop the stream by returning 1 from your callback, or by calling a stop function. 37 | - Close the stream and terminate the library. 38 | 39 | 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. 40 | 41 | 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 paex_saw.c, 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. 42 | Also see the page for tips on programming PortAudio 43 | on the PortAudio wiki. 44 | 45 | @section tut_start4 Programming Tutorial Contents 46 | 47 | - \ref writing_a_callback 48 | - \ref initializing_portaudio 49 | - \ref open_default_stream 50 | - \ref start_stop_abort 51 | - \ref terminating_portaudio 52 | - \ref utility_functions 53 | - \ref querying_devices 54 | - \ref blocking_read_write 55 | 56 | 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. 57 | 58 | Once you have a basic understanding of how to use PortAudio, you might be interested in \ref exploring. 59 | 60 | Next: \ref writing_a_callback 61 | 62 | */ 63 | -------------------------------------------------------------------------------- /cmake/portaudio.def.in: -------------------------------------------------------------------------------- 1 | ; $Id: $ 2 | ; 3 | ; !!! @GENERATED_MESSAGE@ !!! 4 | EXPORTS 5 | 6 | ; 7 | Pa_GetVersion @1 8 | Pa_GetVersionText @2 9 | Pa_GetErrorText @3 10 | Pa_Initialize @4 11 | Pa_Terminate @5 12 | Pa_GetHostApiCount @6 13 | Pa_GetDefaultHostApi @7 14 | Pa_GetHostApiInfo @8 15 | Pa_HostApiTypeIdToHostApiIndex @9 16 | Pa_HostApiDeviceIndexToDeviceIndex @10 17 | Pa_GetLastHostErrorInfo @11 18 | Pa_GetDeviceCount @12 19 | Pa_GetDefaultInputDevice @13 20 | Pa_GetDefaultOutputDevice @14 21 | Pa_GetDeviceInfo @15 22 | Pa_IsFormatSupported @16 23 | Pa_OpenStream @17 24 | Pa_OpenDefaultStream @18 25 | Pa_CloseStream @19 26 | Pa_SetStreamFinishedCallback @20 27 | Pa_StartStream @21 28 | Pa_StopStream @22 29 | Pa_AbortStream @23 30 | Pa_IsStreamStopped @24 31 | Pa_IsStreamActive @25 32 | Pa_GetStreamInfo @26 33 | Pa_GetStreamTime @27 34 | Pa_GetStreamCpuLoad @28 35 | Pa_ReadStream @29 36 | Pa_WriteStream @30 37 | Pa_GetStreamReadAvailable @31 38 | Pa_GetStreamWriteAvailable @32 39 | Pa_GetSampleSize @33 40 | Pa_Sleep @34 41 | Pa_GetVersionInfo @35 42 | ; add new portable public API functions here. DO NOT CHANGE EXISTING ORDINALS! 43 | @DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetAvailableBufferSizes @50 44 | @DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_ShowControlPanel @51 45 | @DEF_EXCLUDE_X86_PLAIN_CONVERTERS@PaUtil_InitializeX86PlainConverters @52 46 | @DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetInputChannelName @53 47 | @DEF_EXCLUDE_ASIO_SYMBOLS@PaAsio_GetOutputChannelName @54 48 | PaUtil_SetDebugPrintFunction @55 49 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetAudioClient @56 50 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_UpdateDeviceList @57 51 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceCurrentFormat @58 52 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceDefaultFormat @59 53 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceMixFormat @60 54 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetDeviceRole @61 55 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityBoost @62 56 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_ThreadPriorityRevert @63 57 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetFramesPerHostBuffer @64 58 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackCount @65 59 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetJackDescription @66 60 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_SetStreamStateHandler @68 61 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_SetDefaultDeviceId @67 62 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapiWinrt_PopulateDeviceList @69 63 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_GetIMMDevice @70 64 | @DEF_EXCLUDE_WMME_SYMBOLS@PaWinMME_GetStreamInputHandleCount @71 65 | @DEF_EXCLUDE_WMME_SYMBOLS@PaWinMME_GetStreamInputHandle @72 66 | @DEF_EXCLUDE_WMME_SYMBOLS@PaWinMME_GetStreamOutputHandleCount @73 67 | @DEF_EXCLUDE_WMME_SYMBOLS@PaWinMME_GetStreamOutputHandle @74 68 | @DEF_EXCLUDE_WASAPI_SYMBOLS@PaWasapi_IsLoopback @75 69 | ; add new host-API-specific public functions here. DO NOT CHANGE EXISTING ORDINALS! 70 | -------------------------------------------------------------------------------- /src/hostapi/pulseaudio/pa_linux_pulseaudio_cb_internal.h: -------------------------------------------------------------------------------- 1 | 2 | /* 3 | * PulseAudio host to play natively in Linux based systems without 4 | * ALSA emulation 5 | * 6 | * Copyright (c) 2014-2023 Tuukka Pasanen 7 | * Copyright (c) 2016 Sqweek 8 | * 9 | * Based on the Open Source API proposed by Ross Bencina 10 | * Copyright (c) 1999-2002 Ross Bencina, Phil Burk 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining 13 | * a copy of this software and associated documentation files 14 | * (the "Software"), to deal in the Software without restriction, 15 | * including without limitation the rights to use, copy, modify, merge, 16 | * publish, distribute, sublicense, and/or sell copies of the Software, 17 | * and to permit persons to whom the Software is furnished to do so, 18 | * subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be 21 | * included in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 26 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 27 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 28 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | /* 33 | * The text above constitutes the entire PortAudio license; however, 34 | * the PortAudio community also makes the following non-binding requests: 35 | * 36 | * Any person wishing to distribute modifications to the Software is 37 | * requested to send the modifications to the original developer so that 38 | * they can be incorporated into the canonical version. It is also 39 | * requested that these non-binding requests be included along with the 40 | * license above. 41 | */ 42 | 43 | #ifndef _PA_HOSTAPI_PULSEAUDIO_CB_H_ 44 | #define _PA_HOSTAPI_PULSEAUDIO_CB_H_ 45 | 46 | #include "pa_util.h" 47 | #include "pa_allocation.h" 48 | #include "pa_hostapi.h" 49 | #include "pa_stream.h" 50 | #include "pa_cpuload.h" 51 | #include "pa_process.h" 52 | 53 | #include "pa_unix_util.h" 54 | #include "pa_ringbuffer.h" 55 | 56 | 57 | /* PulseAudio headers */ 58 | #include 59 | #include 60 | #include 61 | 62 | #include "pa_linux_pulseaudio_internal.h" 63 | 64 | 65 | #ifdef __cplusplus 66 | extern "C" 67 | { 68 | #endif /* __cplusplus */ 69 | 70 | int PaPulseAudio_updateTimeInfo( pa_stream * s, 71 | PaStreamCallbackTimeInfo *timeInfo, 72 | int record ); 73 | 74 | void *PaPulseAudio_processThread( void *userdata ); 75 | 76 | PaError PaPulseAudio_CloseStreamCb( PaStream * stream ); 77 | 78 | PaError PaPulseAudio_StartStreamCb( PaStream * stream ); 79 | 80 | PaError PaPulseAudio_StopStreamCb( PaStream * stream ); 81 | 82 | PaError PaPulseAudio_AbortStreamCb( PaStream * stream ); 83 | 84 | void PaPulseAudio_StreamRecordCb( pa_stream * s, 85 | size_t length, 86 | void *userdata ); 87 | 88 | void PaPulseAudio_StreamPlaybackCb( pa_stream * s, 89 | size_t length, 90 | void *userdata ); 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif /* __cplusplus */ 95 | 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /doc/src/tutorial/compile_cmake.dox: -------------------------------------------------------------------------------- 1 | /** @page compile_cmake PortAudio on Windows, OS X or Linux via. CMake 2 | @ingroup tutorial 3 | 4 | @section cmake_building Building PortAudio stand-alone on Windows, OS X or Linux 5 | 6 | CMake can be used to generate Visual Studio solutions on Windows, Makefiles (on Linux and OS X) and build metadata for other build systems for PortAudio. You should obtain a recent version of CMake from [http://www.cmake.org] if you do not have one already. If you are unfamiliar with CMake, this section will provide some information on using CMake to build PortAudio. 7 | 8 | On Linux, CMake serves a very similar purpose to an autotools "configure" script - except it can generate build metadata apart from Makefiles. The equivalent of the following on POSIX'y systems: 9 | 10 | build_path> {portaudio path}/configure --prefix=/install_location 11 | build_path> make 12 | build_path> make install 13 | 14 | Would be: 15 | 16 | build_path> cmake {portaudio path} -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/install_location 17 | build_path> make 18 | build_path> make install 19 | 20 | The "-G" option specifies the type of build metadata which will be generated. You can obtain a list of supported build metadata formats by invoking (on any platform): 21 | 22 | cmake -G 23 | 24 | "make install" should install the same set of files that are installed using the usual configure script included with PortAudio along with a few extra files (similar to pkg-config metadata files) which make it easier for other CMake projects to use the installed libraries. 25 | 26 | On Windows, you can use CMake to generate Visual Studio project files which can be used to create the PortAudio libraries. The following serves as an example (and should be done from a directory outside the PortAudio tree) which will create Visual Studio 2015 project files targeting a 64-bit build: 27 | 28 | C:\PABUILD> cmake {portaudio path} -G "Visual Studio 14 2015 Win64" 29 | 30 | After executing the above, you can either open the generated solution with Visual Studio or use CMake to invoke the build process. The following shows an example of how to build a release configuration (assuming the above command was executed previously in the same directory): 31 | 32 | C:\PABUILD> cmake --build . --config Release 33 | 34 | If you want ASIO support you need to obtain the ASIO2 SDK from Steinberg and place it according to \ref compile_windows_asio_msvc. Both ASIO and the DirectX SDK are automatically searched for by the CMake script - if they are found, they will be enabled by default. 35 | 36 | @section cmake_using Using PortAudio in your CMake project 37 | 38 | PortAudio defines the following CMake targets: 39 | 40 | - "portaudio_static" for a static library and 41 | - "portaudio" for a dynamic library 42 | 43 | If you installed PortAudio as described above in \ref cmake_building and the install prefix you used (CMAKE_INSTALL_PREFIX) is in your system PATH or CMAKE_MODULE_PATH CMake variable, you should be able to use: 44 | 45 | find_package(portaudio) 46 | 47 | To define the "portaudio_static" and "portaudio" targets in your CMake project. 48 | 49 | If you do not want to install portaudio into your system but would rather just have it get built as part of your own project (which may be particularly convenient on Windows), you may also use: 50 | 51 | add_subdirectory("path to PortAudio location" "some binary directory" EXCLUDE_FROM_ALL) 52 | 53 | EXCLUDE_FROM_ALL is not strictly necessary, but will ensure that targets which you don't use in your project won't get built. 54 | 55 | Back to \ref tutorial_start 56 | 57 | */ -------------------------------------------------------------------------------- /pa_compare_def_files.py: -------------------------------------------------------------------------------- 1 | # PortAudio Repository .def file checker 2 | # 3 | # Run this script from the root of the repository using the command: 4 | # python pa_compare_def_files.py 5 | # 6 | # The PortAudio repository contains two (semi-redundant) .def 7 | # files that specify exported symbols for Windows dynamic link libraries. 8 | # 9 | # This script checks that the two .def files export the same symbols 10 | # using the same ordinals. 11 | # 12 | # The .def files are: 13 | # 14 | # 1. msvc/portaudio.def 15 | # 2. cmake/portaudio.def.in 16 | # 17 | # The CMake .def.in file is an input that generates a .def file 18 | # with host-api-specific symbols commented out when a particular host API 19 | # is not built. 20 | 21 | import sys 22 | 23 | msvc_portaudio_def_path = "msvc/portaudio.def" 24 | cmake_portaudio_def_in_path = "cmake/portaudio.def.in" 25 | 26 | def parse_def_file(file): 27 | result = {} 28 | for line in file: 29 | line = line.strip() 30 | if line: 31 | if "EXPORTS" in line or line[0] == ";": 32 | continue 33 | columns = line.split() 34 | #print(columns) 35 | symbol, ordinal = columns 36 | #print(symbol, ordinal) 37 | if ordinal in result: 38 | print(f"error: ordinal {ordinal} referenced multiple times") 39 | result[ordinal] = symbol 40 | return result 41 | 42 | with open(msvc_portaudio_def_path, mode="rt", encoding="utf-8") as msvc_portaudio_def: 43 | msvc_portaudio_def_syms = parse_def_file(msvc_portaudio_def) 44 | 45 | with open(cmake_portaudio_def_in_path, mode="rt", encoding="utf-8") as cmake_portaudio_def_in: 46 | cmake_portaudio_def_in_syms = parse_def_file(cmake_portaudio_def_in) 47 | 48 | def clear_cmake_exclude_condition_prefix(sym): 49 | if "@" in sym: 50 | return sym.split("@")[-1] 51 | else: 52 | return sym 53 | 54 | # dictionary keys are the ordinals 55 | ordinals = list(set(msvc_portaudio_def_syms.keys()).union(cmake_portaudio_def_in_syms.keys())) 56 | ordinals.sort(key=lambda s: int(s.replace("@", ""))) 57 | 58 | msvcMissingCount = 0 59 | cmakeMissingCount = 0 60 | differenceCount = 0 61 | 62 | print("ordinal, msvc, cmake, remark") 63 | for ordinal in ordinals: 64 | msvc_sym = msvc_portaudio_def_syms[ordinal] if ordinal in msvc_portaudio_def_syms else "" 65 | cmake_sym = cmake_portaudio_def_in_syms[ordinal] if ordinal in cmake_portaudio_def_in_syms else "" 66 | 67 | cmake_sym_no_cond = clear_cmake_exclude_condition_prefix(cmake_sym) 68 | 69 | remark = "" 70 | if not msvc_sym: 71 | remark = "missing in msvc/portaudio.def" 72 | msvcMissingCount += msvcMissingCount 73 | elif not cmake_sym: 74 | remark = "missing in cmake/portaudio.def.in" 75 | cmakeMissingCount += cmakeMissingCount 76 | elif msvc_sym != cmake_sym_no_cond: 77 | remark = "differs" 78 | differenceCount += 1 79 | else: 80 | remark = "ok" 81 | 82 | print(f"{ordinal}, {msvc_sym}, {cmake_sym}, {remark}") 83 | 84 | print("SUMMARY") 85 | print("=======") 86 | issuesFound = msvcMissingCount > 0 or cmakeMissingCount > 0 or differenceCount > 0 87 | if msvcMissingCount > 0: 88 | print(f"error: {msvc_portaudio_def_path} ({msvcMissingCount} missing symbols)") 89 | if cmakeMissingCount > 0: 90 | print(f"error: {cmake_portaudio_def_in_path} ({cmakeMissingCount} missing symbols)") 91 | if differenceCount > 0: 92 | print(f"error: there are {differenceCount} ordinals with non-matching symbols") 93 | 94 | if issuesFound: 95 | sys.exit(1) 96 | else: 97 | print("No issues found. All good.") 98 | sys.exit(0) 99 | -------------------------------------------------------------------------------- /test/patest_ringmix.c: -------------------------------------------------------------------------------- 1 | /** @file patest_ringmix.c 2 | @ingroup test_src 3 | @brief Ring modulate inputs to left output, mix inputs to right output. 4 | */ 5 | /* 6 | * $Id$ 7 | * 8 | * This program uses the PortAudio Portable Audio Library. 9 | * For more information see: http://www.portaudio.com 10 | * Copyright (c) 1999-2000 Ross Bencina and Phil Burk 11 | * 12 | * Permission is hereby granted, free of charge, to any person obtaining 13 | * a copy of this software and associated documentation files 14 | * (the "Software"), to deal in the Software without restriction, 15 | * including without limitation the rights to use, copy, modify, merge, 16 | * publish, distribute, sublicense, and/or sell copies of the Software, 17 | * and to permit persons to whom the Software is furnished to do so, 18 | * subject to the following conditions: 19 | * 20 | * The above copyright notice and this permission notice shall be 21 | * included in all copies or substantial portions of the Software. 22 | * 23 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 24 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 25 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 26 | * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR 27 | * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF 28 | * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 29 | * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 30 | */ 31 | 32 | /* 33 | * The text above constitutes the entire PortAudio license; however, 34 | * the PortAudio community also makes the following non-binding requests: 35 | * 36 | * Any person wishing to distribute modifications to the Software is 37 | * requested to send the modifications to the original developer so that 38 | * they can be incorporated into the canonical version. It is also 39 | * requested that these non-binding requests be included along with the 40 | * license above. 41 | */ 42 | 43 | 44 | #include 45 | #include "portaudio.h" 46 | /* This will be called asynchronously by the PortAudio engine. */ 47 | static int myCallback( const void *inputBuffer, void *outputBuffer, 48 | unsigned long framesPerBuffer, 49 | const PaStreamCallbackTimeInfo* timeInfo, 50 | PaStreamCallbackFlags statusFlags, 51 | void *userData ) 52 | { 53 | const float *in = (const float *) inputBuffer; 54 | float *out = (float *) outputBuffer; 55 | float leftInput, rightInput; 56 | unsigned int i; 57 | 58 | /* Read input buffer, process data, and fill output buffer. */ 59 | for( i=0; i