typograph | 20 May 01:37 2016

be prepared



I'm sure you are interested in such info, be prepared for something really great! More info here http://jecrupipe.pondpublishing.com/lnqkh


Warmest regards, typograph <at> elec.ru

Portaudio mailing list
Portaudio <at> lists.columbia.edu
Phil Burk | 19 May 07:41 2016

fix for non-power-of-2 ready for review

PortAudio asserted on Mac if one tried to write() or read() N channels where N was not a power of 2.

A possible fix is ready here for review:

Here is the bug report:

Phil Burk

Portaudio mailing list
Portaudio <at> lists.columbia.edu
Raphael Melgar | 18 May 22:15 2016

Getting lowest latency on Mac OS X


I’m learning PortAudio and so far it’s pretty straight forward to get it working. I’m basically
writing a program that is attempting to test the roundtrip latency of a thunderbolt audio interface I have
by sending the output of ch1 to input ch1. 

I hope this question isn’t inappropriate for this mailing list but I’m having trouble with setting up
my Pa parameters such that I get the lowest latency possible (<10ms).

First I’m not clear on how to use the functions in pa_mac_core.h or from port audio.h to setup an optimized
environment for low latency, this is what I’m doing:

#define SAMPLE_RATE 48000
#define BLOCK_SIZE 32
#define NUM_CHANNELS 1
#define DESIRED_LATENCY 0.0	// I read that you can set this to 0 to tell PA you want the lowest latency possible

    // Get default input device 
    inputParameters.device = Pa_GetDefaultInputDevice(); /* Get the default output device. */

    // Get default output device
    outputParameters.device = Pa_GetDefaultOutputDevice(); /* Get the default output device. */

    // set pa_mac_core info
    PaMacCore_SetupStreamInfo(&mac_info, paMacCoreChangeDeviceParameters);

    // set input device params
    inputParameters.channelCount = 1;   
    inputParameters.sampleFormat = paFloat32;       
    inputParameters.hostApiSpecificStreamInfo = &mac_info;
    inputParameters.suggestedLatency = DESIRED_LATENCY;

    // set output device params
    outputParameters.channelCount = 1;               
    outputParameters.sampleFormat = paFloat32;   
    outputParameters.hostApiSpecificStreamInfo = &mac_info;
    outputParameters.suggestedLatency = DESIRED_LATENCY;

    /****************** open a stream *********************/
    pa_error = Pa_OpenStream(&stream,

Then I have a setup where in my callback function I first send audio to the output buffer, then immediately
get the input sample. I test to see if the current input sample passes a certain threshold, and if so I abort
the process:

    for(i = 0; i < framesPerBuffer; i++){

        // send a test signal out of the DAC,
        // the first sample is a unit impulse.
        *out++ = test_sig[i];

        // get current input sample from input buffer
        input_samp = *in++;

        // detect a signal value above THRESHOLD
        // if detected, abort the stream
        if (input_samp > THRESHOLD ) {
            return paAbort;                 // quit processing samples

Using timing info I get from port audio, my program reports on average a roundtrip latency about ~240ms. am I
missing any steps or is it not possible to get the <10ms latency I desire?


Portaudio mailing list
Portaudio <at> lists.columbia.edu
Phil Burk | 17 May 07:40 2016

no assert in pa_mac_core.c

I cleaned up some comments in the pa_mac_core.c merge request.
This change list (CL) replaces asserts with code that stops the stream.

I have not gotten any feedback. So I plan to just merge the code tomorrow, unless I hear otherwise.

This CL is to fix this bug:

Phil Burk

Portaudio mailing list
Portaudio <at> lists.columbia.edu
Åke Forslund | 16 May 22:52 2016

underrun when using usb headset


we're using portaudio as a sound backend for mimic (a continuation of the flite TTS) http://github.com/MycroftAI/mimic

We are using portaudio as our default backend and it has always worked fine. Now we've encountered underrun on some devices:

The message
"ALSA lib pcm.c:7905:(snd_pcm_recover) underrun occurred"
is printed repeatedly and the sound is chopped up and slow.

I myself can reproduce the issue using an usb headset and latest portaudio from subversion. (Logitech B530 USB Headset)

When selecting my internal sound device (HDA-Intel - HD-Audio Generic) there is no problem.

I've run the tests included in the portaudio and all triggers similar underruns, basically all applications using portaudio gets underruns.

I'm too new to these systems to know where to start looking, any pointers would be much appreciated. Can I enable debugging somehow?

Any help is much appreciated

Best regards

Åke Forslund
Web: http://akeiexil.wordpress.com
Tel: 070 - 3052159
-Smoke me a kipper I'll be back for breakfast
Portaudio mailing list
Portaudio <at> lists.columbia.edu
Rainer Schuetz | 12 May 15:13 2016

Building PA with MinGW - DSound with MinGW DirectX?


I was trying to build Portaudio using MinGW (on Windows) and got quite far borrowing from the patches to be
found in various forks/distributions. With regards to DSound support a friend made me aware that MinGW
comes with direct sound libs and headers. So I tried using those instead of DirectX 7, which is almost
impossible to obtain, but seems to be the only version that can be used on MinGW (please correct me if I’m
wrong). I know building with MinGW is not supported, but some people seem nevertheless to try it, and might
be listening here.

I am using MinGW 4.8.2 that comes with Qt (original distribution). I can build, if I switch of `Use
DirectSound full duplex create`. Is there a solution to this using MinGW-DirectX? With `...full duplex
create = on` I get

warning: "_WIN32_WINNT" redefined [enabled by default]
 #define _WIN32_WINNT 0x0400 /* required to get waitable timer APIs */
In file included from C:/Qt/Tools/mingw482_32/i686-w64-mingw32/include/crtdefs.h:10:0,
                 from C:/Qt/Tools/mingw482_32/i686-w64-mingw32/include/assert.h:15,
                 from C:\Users\Rainer\Projects\sc\supercollider\external_libraries\portaudio\src\hostapi\dsound\pa_win_ds.c:50:
C:/Qt/Tools/mingw482_32/i686-w64-mingw32/include/_mingw.h:229:0: note: this is the location of
the previous definition
 #define _WIN32_WINNT 0x502

error: unknown type name 'LPDIRECTSOUNDFULLDUPLEX8'
     LPDIRECTSOUNDFULLDUPLEX8 pDirectSoundFullDuplex8;

In function
warning: passing argument 7 of 'paWinDsDSoundEntryPoints.DirectSoundFullDuplexCreate' from
incompatible pointer type [enabled by default]

note: expected 'struct IDirectSoundFullDuplex **' but argument is of type 'int
warning: assignment makes integer from pointer without a cast [enabled by default]
             stream->pDirectSoundFullDuplex8 = NULL;

In function
warning: passing argument 1 of 'CalculateBufferSettings' from incompatible pointer type [enabled by default]
                     sampleRate, framesPerBuffer );

note: expected 'long unsigned int *' but argument is of type 'int *'
 static void CalculateBufferSettings( unsigned long *hostBufferSizeFrames,
In file included from
error: invalid type argument of '->' (have 'int')
             IDirectSoundFullDuplex_Release( stream->pDirectSoundFullDuplex8 );

warning: assignment makes integer from pointer without a cast [enabled by default]
             stream->pDirectSoundFullDuplex8 = NULL;
In file included from
In function
error: invalid type argument of '->' (have 'int')
         IDirectSoundFullDuplex_Release( stream->pDirectSoundFullDuplex8 );

warning: assignment makes integer from pointer without a cast [enabled by default]
         stream->pDirectSoundFullDuplex8 = NULL;
external_libraries\portaudio\CMakeFiles\portaudio.dir\build.make:337: recipe for target
'external_libraries/portaudio/CMakeFiles/portaudio.dir/src/hostapi/dsound/pa_win_ds.c.obj' failed
mingw32-make.exe[3]: ***
Error 1
CMakeFiles\Makefile2:1012: recipe for target
'external_libraries/portaudio/CMakeFiles/portaudio.dir/all' failed
mingw32-make.exe[2]: *** [external_libraries/portaudio/CMakeFiles/portaudio.dir/all] Error 2
CMakeFiles\Makefile2:1024: recipe for target
'external_libraries/portaudio/CMakeFiles/portaudio.dir/rule' failed
mingw32-make.exe[1]: *** [external_libraries/portaudio/CMakeFiles/portaudio.dir/rule] Error 2
Makefile:549: recipe for target 'portaudio' failed
mingw32-make.exe: *** [portaudio] Error 2

Also I am not really sure what I lose with this. Maybe someone has advice?

Thank you in advance

PS: thanks for moving PA to Git, greatly appreciated!
Portaudio mailing list
Portaudio <at> lists.columbia.edu
Puneet Rana | 10 May 20:26 2016

Missing samples on startup

Hello all,

I am observing an unusual startup behavior using Portaudio v19 (Jan 30, 2014 version) with a MOTU UltraLite AVB device. In my simple experiment, I play audio through the sound card and record the same using a loopback cable. The audio seems to start recording after about 2 seconds of silence. It isn’t 2 seconds of latency, but rather 2 seconds of missing samples. Once the audio starts recording, I can see it matches with the played audio with a few ms of latency. Moreover, if I have a DAW (e.g. Reaper) open in the background, configured to access the device, and then I start recording through Portaudio, there are no missing samples anymore. I have uploaded the files that you can use to compare:

1. Audio played: https://drive.google.com/open?id=0B4xKSR5ZhGraSU1YZGoxN0MxSzg
2. Audio recorded (has ~2 seconds of silence in the beginning): https://drive.google.com/open?id=0B4xKSR5ZhGraZ1ozeXAtZi1pcGc
3. Audio recorded with Reaper open in the background (doesn't have any missing samples): https://drive.google.com/open?id=0B4xKSR5ZhGradzFOaXFmaE53TzQ

Here are some more observations:
* The same behavior can be seen both on Mac (10.10.5) using CoreAudio and on Windows (7 and 10) using ASIO.
* I could reproduce this using Audacity 2.0.5 which also uses Portaudio v19.
* I could not reproduce this with a DAW that does not use Portaudio (like Reaper).
* I could not reproduce this with Steinberg UR44.
* I have verified this behavior on multiple computers.

Can someone please help me debug this issue?

Portaudio mailing list
Portaudio <at> lists.columbia.edu
Phil Burk | 10 May 18:28 2016

snapshot now coming from Git

I modified the nightly script that generates the PortAudio snapshot.
It now gets the code from the Git repository.

Note that you can also download a Zipped snapshot using the "Download" link on this page:

Phil Burk

Portaudio mailing list
Portaudio <at> lists.columbia.edu
Tim Bunnell | 8 May 17:33 2016

Mac 10.11 deprecation warning

Hi All,

I see some discussion on the list of the deprecation warning related to the component manager for audio
units, but not sure I am seeing a resolution. Just upgraded to 10.11 and starting to see this warning. Has
anyone fixed this issue?


Director, Center for Pediatric Auditory and Speech Sciences (CPASS)
Head, Speech Research Lab    | Adjunct Professor
duPont Hospital for Children | Comp. and Info. Sciences / Linguistics
Voice: 1+302+651-6835        | University of Delaware
Fax:   1+302+651-6895        | URL: www.asel.udel.edu/speech/
Babak Khataee | 5 May 11:44 2016

Pa_StopStream never returning on Linux


I work on a multiplatform (windows/osx/linux) video application that uses portaudio for playing back audio. I've been investigating an intermittent bug we have that causes hangs when playing back video with audio on Linux. I was hoping some one on this list might be able to provide me with some advice/insight as to what is going on at the portaudio level, as the hang seems to be in Pa_StopStream. I'm not very familiar with audio programming so apologies for any obvious things I might have missed.

The general problem is that our application can hang when trying to stop the audio stream. It's quite intermittent and machine specific. I'm able to reproduce it semi reliably on my machine which has the following..

Distro -RHEL 6.4
Kernel - 2.6.32-358.11.1.el6.x86_64
Alsa version - 1.0.21
Audio device - HDA Intel

We're using portaudio v19_20111221 and use the callback interface. If I step through the program with gdb once it's hung I see that the main thread is waiting for a thread to join..

#0  0x000000352600822d in pthread_join () from /lib64/libpthread.so.0
#1  0x00007fa2af795931 in PaUnixThread_Terminate (self=0x84fee78, wait=<value optimized out>, exitResult=0x7fffb80a0d1c) at src/os/unix/pa_unix_util.c:441
#2  0x00007fa2af78e7d5 in RealStop (stream=0x84fece0, abort=<value optimized out>) at src/hostapi/alsa/pa_linux_alsa.c:3047

Presumably it's waiting on the portaudio thread, which is doing the following..

#0  0x00000035254df0d3 in poll () from /lib64/libc.so.6
#1  0x00007fa2af790d4a in PaAlsaStream_WaitForFrames (self=0x84fece0, framesAvail=0x7fa0a7ffee50, xrunOccurred=0x7fa0a7ffee58) at src/hostapi/alsa/pa_linux_alsa.c:3778
#2  0x00007fa2af791c59 in CallbackThreadFunc (userData=0x84fece0) at src/hostapi/alsa/pa_linux_alsa.c:4222
#3  0x00000035260079d1 in start_thread () from /lib64/libpthread.so.0
#4  0x00000035254e88fd in clone () from /lib64/libc.so.6

I'm able to get the same hang in the patest_start_stop test, built from v19_20140130, when I have some other audio playing (normally spotify running in chrome). I've been using that to try and debug things a bit. Here's what I've found.

* Stepping through the callback thread it seems that it is stuck in the while loop of CallbackThreadFunc, because framesAvail, set in PaAlsaStream_WaitForFrames, is always 0 and PaUtil_IsBufferProcessorOutputEmpty returns false.

* Stepping into PaAlsaStream_WaitForFrames -> PaAlsaStream_GetAvailableFrames -> PaAlsaStreamComponent_GetAvailableFrames, the call to alsa_snd_pcm_avail_update is always returning 0. 

* The poll in the while loop of PaAlsaStream_WaitForFrames is returning 1 

* The alsa_snd_pcm_poll_descriptors_revents call, in PaAlsaStreamComponent_EndPolling, sets revents to 4 (POLLOUT).

* If I add a call to snd_pcm_state in PaAlsaStreamComponent_GetAvailableFrames then I get SND_PCM_STATE_RUNNING.

I've no idea what causes it to get in this state but I've noticed that if I change the suggestedLatency used in patest_start_stop from defaultLowOutputLatency to defaultHighOutputLatency then I no longer get the hang. Also if I restart the pulseaudio service then that temporarily fixes the problem, but only for an hour or so, after that it starts happening again. It seems possible to work around the hang by replacing the call to Pa_StopStream with Pa_AbortStream but I'm a bit worried that the hang is actually a symptom of something else. Similarly if I call AlsaRestart(stream) from gdb, while it's hung, then it comes back to life. I've also noticed that in the cases where patest_start_stop doesn't hang it plays audio right up to the point where Pa_StopStream is called, while in the cases where it hangs it stops playing audio first then hangs once Pa_StopStream is called. In both cases there are a lot of "ALSA lib pcm.c:7246:(snd_pcm_recover) underrun occured" messages and scratching sounds, which aren't there when defaultHighOutputLatency is used. Our application uses defaultLowOutputLatency but doesn't get any underrun messages or scratching sounds.

I've searched around online for similar issues and the only thing I could find was (http://music.columbia.edu/pipermail/portaudio/2010-May/010234.html) which seems very similar but caused by something which is fixed in v19_20111221.

Thanks in advance,
Portaudio mailing list
Portaudio <at> lists.columbia.edu
Benjamin Gittins | 5 May 08:34 2016

Compiling project in code blocks not finding portaudio.h


I've been trying to get some code based on the paex_record_file.c to compile in code blocks, but have been having problems with compiling it. When I compile the project in code blocks, I get the error message from pa_util.h saying "fatal error: portaudio.h no such file or folder found".

I've gotten the ./configure make and make install to work, so portaudio itself should be installed properly.

In my project, i have recursively added the portaudio/src/ folder and the portaudio/include into the folder. Also under build options -> Compiler settings -> #defines i have added _WIN32. Furthermore under build options -> Linker settings i have added the portaudio.a file to the link libraries.

If anyone could help me that would be great.

Kind Regards,

Ben Gittins

Portaudio mailing list
Portaudio <at> lists.columbia.edu