portaudio timing

hello, I’m new here. I am a developer. MacOSX 10.7

I have a portaudio (v1.9) specific question.
I’m writing a program that records audio. Using a callback.
I’m trying to synchronise audio and MIDI as precisely as possible.
That is, I send MIDI notes to an external synth device, and record the audio that’s played.
Just after calling Pa_StartStream(), I get the Start Time with Pa_GetStreamTime().
About 370 ms later, when the 1st call back is fired, the ADC time of the 1st audio input buffer is 8 millisecond before the Start Time.

what does that means ?
seems that portaudio (upon CoreAudio) was already recording before I told it ?

And, why always 8 ms ?
What kind of accuracy can portaudio achieve ?

If any idea … thank you !


Topic moved to “General Audio Programming”.

You would probably do better to ask this type of question on the Portaudio mailing list. The Audacity developers rarely come to the forum, and when they do they generally only respond to questions that are specifically about Audacity.

See my previous post for how to contact Portaudio. https://forum.audacityteam.org/t/about-portaudio/31846/2

Just a quick thought.

8ns = 0.008 = 1/125 which in turn is 384 samples (typical aligned small buffer) from a 48000hrz sample rate.

You’re always going to have latency equal to the size of your buffer.