Luke Drummond | 20 Dec 17:11 2014

(no subject)

Hi Scott

The `examples` directory within the portaudio source tree has some
very useful material to see how various record/playback paradigms work
(both with callback and blocking methods).  I would concentrate your
efforts there for now to see how things should work.

Basic flow is this.

    - initialize PA: `Pa_Initialize()`
    - query devices/formats:
    - Register with PA a pointer to a callback that will be given a
buffer of data from the microphone, and will expect your playback
data.  `Pa_OpenStream()` This callback will be called repeatedly from
a high-priority thread, and should not make system calls or call
functions that are not predictably bounded. To get/give data to/from
this callback, use a queue or ringbuffer.  PA provides a tested
implementation of a ringbuffer too.
   - ask PA to run for a while: `Pa_StartStream()`
   - ask PA to stop.  `Pa_StopStream()`
   - cleanup: `Pa_CloseStream()`/`Pa_tTerminate()`

See also

Hope that helps.


On 20 December 2014 at 15:58, Scott Whitney <sdw <at>> wrote:
(Continue reading)

Scott Whitney | 19 Dec 19:16 2014

Generating a tone and reading back the inputs simultaneously

I’m sorry for the simplistic nature of this question, but I am a complete beginner when it comes to PC Audio, and have not worked with PortAudio at all before.  Thanks for taking mercy on me!


My needs are pretty simple.  I am trying to generate a fixed-frequency (f) sine wave at some given amplitude (A) for some fixed duration in milliseconds (T) and send it to one or both channels of the sound card output.  Simultaneously, I need to read back whatever is being received on the sound card input channel(s) (one or both).


For example, say that I wanted to generate a 600 mV RMS sine wave at 200 Hz for 1 second, write it to one or both output channels, and read it back?  For the sake of this example, suppose that my sound card is 16-bit stereo, and has a sampling rate of either 44.1kHz or 48kHz.


How can I go about doing this in PortAudio?  Thanks very much for any advice, or even better, an actual example!


Happy holidays,





Portaudio mailing list
Portaudio <at>
Michael Cherkasov | 14 Dec 16:49 2014

capture sound that is playing on PC

Hi there!

Is it possible to capture sound that is playing on PC?

I wondering about java binding, may be you can show an example?

Portaudio mailing list
Portaudio <at>
Alexander Carôt | 11 Dec 10:13 2014

Re: Interesting "review" of PortAudio

>Regarding latency, this is utter BS. I know the kind of users we have
>and they would have told us a looonng time ago. The guy probably don't
>know of the state of latencies with windows with simple MME backend.
>We compile Portaudio with VS2013 on Windows so I don't know any more
>modern compiler than this one on Windows. (though I don't use bundled
>Can't tell about surround.
>The conclusion of the article stating "If Your App or Library Depends on
>Audio, Take the Time to Write Your Own" make me think of someone which is
>never happy with anything and find an excuse to rewrite everything from
>Probably fun to do but mostly nonsense as this is a loooottt of work.



Ross Bencina | 11 Dec 07:31 2014

Interesting "review" of PortAudio

I wonder whether anyone here agrees with the following. If so, we may 
need to add some more bugs to the ticket list...

Quoting the article:

PortAudio is incredibly latent on Windows. This is because the Winmm 
backend is the only backend that works reliably. I was able to use 
PortAudio, but only by specifically turning off all of the good 
alternatives; some of them do not compile on modern compilers and the 
rest were simply broken. Ironically, it turns out that Winmm itself is 
fine, as this is what Libaudioverse uses now. But the additional 
overhead of whatever PortAudio is doing internally kills it. Like many 
projects of extremely long duration, actually fixing PortAudio is 
difficult, probably more difficult than just starting over; I was unable 
to comprehend the code.

The second is that PortAudio fails for anything more than two channel 
audio. because platforms use different standards for surround sound 
channel ordering, it is required that they be swapped according to the 
API in use. PortAudio requires that you use some tricks with void 
pointers and platform-specific code to even enable higher channel 
counts. On top of this, it does not perform the needed swapping, at 
least not that I could find. Given the proceeding point, this basically 
makes PortAudio useless save for the most undemanding applications. I 
suspect it's popularity stems from the fact that very few applications 
actually need more than stereo, and latency doesn't matter save in games 
and audio editing and synthesis programs.
Dinesh Iyer | 8 Dec 23:27 2014

Blip heard at end of playback on Linux

I am hearing a blip at the end of the playback of the following WAV file:

only on Linux. I tested this on Debian 7, RHEL6 and Ubuntu 14.04. I tried this with my application and also using Audacity.

I am not able to hear it on Windows (both my app and Audacity) on Windows 7 or on Mac OS X 10.9 (only tested using my application).

The signal does not abruptly end at a non-zero value. I am hearing this blip even with the latest version of PortAudio (Jan 30, 2014).

I wanted to know if this is a known issue or are there any workarounds.

Portaudio mailing list
Portaudio <at>
Riot | 7 Dec 23:16 2014

Patch: c++ binding comparison operators should be const

Hi, I just joined the mailing list to submit this patch - please let me know if this is not the correct channel to submit patches in future.

The C++ bindings define operator == and !=, but these are not declared const - although they have no reason not to be.

Index: bindings/cpp/include/portaudiocpp/Device.hxx
--- bindings/cpp/include/portaudiocpp/Device.hxx        (revision 1934)
+++ bindings/cpp/include/portaudiocpp/Device.hxx        (working copy)
 <at>  <at>  -27,20 +27,20  <at>  <at> 
        ///  <at> brief Class which represents a PortAudio device in the System.
-       /// A single physical device in the system may have multiple PortAudio
-       /// Device representations using different HostApi 's though. A Device
-       /// can be half-duplex or full-duplex. A half-duplex Device can be used
-       /// to create a half-duplex Stream. A full-duplex Device can be used to
-       /// create a full-duplex Stream. If supported by the HostApi, two
+       /// A single physical device in the system may have multiple PortAudio
+       /// Device representations using different HostApi 's though. A Device
+       /// can be half-duplex or full-duplex. A half-duplex Device can be used
+       /// to create a half-duplex Stream. A full-duplex Device can be used to
+       /// create a full-duplex Stream. If supported by the HostApi, two
        /// half-duplex Devices can even be used to create a full-duplex Stream.
-       /// Note that Device objects are very light-weight and can be passed around
+       /// Note that Device objects are very light-weight and can be passed around
        /// by-value.
        class Device
-               // query info: name, max in channels, max out channels,
+               // query info: name, max in channels, max out channels,
                // default low/hight input/output latency, default sample rate
                PaDeviceIndex index() const;
                const char *name() const;
 <at>  <at>  -60,8 +60,8  <at>  <at> 
                bool isHostApiDefaultInputDevice() const; // extended
                bool isHostApiDefaultOutputDevice() const; // extended

-               bool operator==(const Device &rhs);
-               bool operator!=(const Device &rhs);
+               bool operator==(const Device &rhs) const;
+               bool operator!=(const Device &rhs) const;

                // host api reference
                HostApi &hostApi();
 <at>  <at>  -73,7 +73,7  <at>  <at> 

                friend class System;
                explicit Device(PaDeviceIndex index);

Index: bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx
--- bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx  (revision 1934)
+++ bindings/cpp/include/portaudiocpp/SystemDeviceIterator.hxx  (working copy)
 <at>  <at>  -23,12 +23,12  <at>  <at> 
 namespace portaudio

        ///  <at> brief Iterator class for iterating through all Devices in a System.
-       /// Devices will be iterated by iterating all Devices in each
-       /// HostApi in the System. Compliant with the STL bidirectional
+       /// Devices will be iterated by iterating all Devices in each
+       /// HostApi in the System. Compliant with the STL bidirectional
        /// iterator concept.
        class System::DeviceIterator
 <at>  <at>  -48,8 +48,8  <at>  <at> 
                DeviceIterator &operator--();
                DeviceIterator operator--(int);

-               bool operator==(const DeviceIterator &rhs);
-               bool operator!=(const DeviceIterator &rhs);
+               bool operator==(const DeviceIterator &rhs) const;
+               bool operator!=(const DeviceIterator &rhs) const;

                friend class System;
Index: bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx
--- bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx (revision 1934)
+++ bindings/cpp/include/portaudiocpp/SystemHostApiIterator.hxx (working copy)
 <at>  <at>  -45,8 +45,8  <at>  <at> 
                HostApiIterator &operator--();
                HostApiIterator operator--(int);

-               bool operator==(const HostApiIterator &rhs);
-               bool operator!=(const HostApiIterator &rhs);
+               bool operator==(const HostApiIterator &rhs) const;
+               bool operator!=(const HostApiIterator &rhs) const;

                friend class System;
Index: bindings/cpp/source/portaudiocpp/Device.cxx
--- bindings/cpp/source/portaudiocpp/Device.cxx (revision 1934)
+++ bindings/cpp/source/portaudiocpp/Device.cxx (working copy)
 <at>  <at>  -131,12 +131,12  <at>  <at> 

                // -------------------------------------------------------------------------------

-               bool Device::operator==(const Device &rhs)
+               bool Device::operator==(const Device &rhs) const
                        return (index_ == rhs.index_);

-               bool Device::operator!=(const Device &rhs)
+               bool Device::operator!=(const Device &rhs) const
                        return !(*this == rhs);
Index: bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx
--- bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx   (revision 1934)
+++ bindings/cpp/source/portaudiocpp/SystemDeviceIterator.cxx   (working copy)
 <at>  <at>  -44,12 +44,12  <at>  <at> 

        // -----------------------------------------------------------------------------------

-       bool System::DeviceIterator::operator==(const System::DeviceIterator &rhs)
+       bool System::DeviceIterator::operator==(const System::DeviceIterator &rhs) const
                return (ptr_ == rhs.ptr_);

-       bool System::DeviceIterator::operator!=(const System::DeviceIterator &rhs)
+       bool System::DeviceIterator::operator!=(const System::DeviceIterator &rhs) const
                return !(*this == rhs);
Index: bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx
--- bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx  (revision 1934)
+++ bindings/cpp/source/portaudiocpp/SystemHostApiIterator.cxx  (working copy)
 <at>  <at>  -44,12 +44,12  <at>  <at> 

        // -----------------------------------------------------------------------------------

-       bool System::HostApiIterator::operator==(const System::HostApiIterator &rhs)
+       bool System::HostApiIterator::operator==(const System::HostApiIterator &rhs) const
                return (ptr_ == rhs.ptr_);

-       bool System::HostApiIterator::operator!=(const System::HostApiIterator &rhs)
+       bool System::HostApiIterator::operator!=(const System::HostApiIterator &rhs) const
                return !(*this == rhs);
Portaudio mailing list
Portaudio <at>
Brian Vassallo | 22 Nov 14:31 2014


Dear Sir's,

I have downloaded AUDACITY 2.0.6 and i noticed a note 'Portaudio V-19 devel' ( Built sept.20. 2014 21:45:33)
in the devices menu section.

Would appreciate if you can help me understand since i am new to this,
therefore, if this will change or effect in any way my settings in ASIO,and in latency, that i have in my CUBASE recording software and in my USB audio devide - 'UR22'.

What i wish is to use AUDACITY with Portaudio V-19 devel, which is included,
but without modifying or having modified my original settings in CUBASE & UR22 ASIO , especially in latency.

Perhaps i am confusing the two scenarios, but just want to be sure that my original settings of Cubase & UR22, remained the same and latency settings wise.

Much appreciated
Portaudio mailing list
Portaudio <at>
Dinesh Iyer | 11 Nov 20:17 2014

Audio playback stalls when playing back audio on Mac OS X

Hi all,
I am designing an application which allows users to playback multiple audio signals at different sample-rates to the same audio device. I implement this by opening a new stream to playback each signal. I let CoreAudio perform the mixing. The playback does not start simultaneously i.e the user can playback one signal, then after an arbitrary amount of time playback the next one even when the first signal is playing.

The stall occurs about 30% of the time. 

I am able to consistently reproduce a stall when I am playing back two signals at 8192 hertz and attempt to open a stream at 44100 hz. The stall occurs at __psync_mutexwait in the call to Pa_OpenStream(). 

I am not receiving this stall when I match the sample rates of all my streams.

I cam across this article in Apple's knowledge base about AUGRAPH stalls:

I am not sure if it is relevant.

I am able to reproduce this using both the March 2011 and Jan 2014 versions of the library.


Portaudio mailing list
Portaudio <at>
Stefan Hajnoczi | 11 Nov 10:39 2014

Persistent device identifiers

Applications need to save sound settings across restart so the user
does not have to select their settings each time.

My application saves the host API and device names as strings.  The
reason for saving strings instead of PortAudio's index numbers is that
adding or removing sound devices could change the index numbers.  For
example, if a USB webcam is connected that might expose an sound
capture device and affect index numbering.

Here are two issues I've encountered with strings:

1. Character set encoding is (was?) not consistent.  PortAudio strings
are supposed to be UTF-8 but not all host APIs have implemented that
correctly.  I'm not sure what the current status is, but users with
non-English Windows installations have reported problems with
PortAudio built February 27th 2014 using WinMME and DirectSound.

2. Some systems have multiple sound devices with the same name.  This
makes it impossible to uniquely identify a device from its name!  A
Windows user recently reported this problem but was able to manually
rename the sound device.  I'm not sure whether the Windows sound
settings control panel has a way of doing that or if they used a
registry hack.

Any thoughts on these issues?

Is there a more reliable method than name strings for persistent
device identifiers?

Wang, Lin | 4 Nov 16:25 2014

Quesiton about Pa_IsFormatSupported on alsa API (ubuntu)



I am using the PortAudio to query the list of capture devices and also use Pa_IsFormatSupported to probe if the actual device is compliant with the requested audio format. I realized that the Pa_IsFormatSupported’s alsa implementation tends to open the actual PCM stream under the hood to physically test the device. It seems to take a while for a device to be ready again.


In the extreme case, calling Pa_IsFormatSupported on a device back-to-back, the 2nd call will end up getting the paDeviceUnavailable error in most cases. BTW, the recording device I am using is a Bluetooth remote control, based on your experience, the latency could be caused by the PA/alsa implementation or by the physical device?




Portaudio mailing list
Portaudio <at>