PortAudio / portaudio

PortAudio is a cross-platform, open-source C language library for real-time audio input and output.
Other
1.43k stars 296 forks source link

Error with PaStreamCallbackTimeInfo in MacOS #947

Closed oost closed 1 month ago

oost commented 1 month ago

When I open an input stream with callback on MacOS, I have noticed that that the timeInfo is returning the same time multiple buffers in a row.

If I set my framePerBuffer to 512, the inputBufferAdcTime and currentTime are constant over 4 to 6 calls to the callback.

Some old threads seem to point to CoreAudio using a larger master buffer. I understand that inputBufferAdcTime might stay contstant but why would currentTime (and Pa_GetStreamTime) also stay constant? I am running real time beat tracking on the stream and need to know the exact time of each buffer. It feels like I have to keep track of the master buffer by recording the inputBufferAdcTime from one call to the next and then the number of frames copied. What am I missing? Thanks

oost commented 1 month ago

The error was in my code. I accidentally narrowed down the time variables which are PaTime (=double) to floats and the compiled didn't complain.