portaudio - Time between callback calls? -


I have a laboratory project that primarily uses PyAudio and to understand the way it works I have done some measurements in this case between the callback (using the callback mode)

I gave it time and found an interesting result

(@ 256 Chuck size, 44.1 Km FS): 0.0099701; 0.0000365; 0.0000201; 0.0201579

This pattern is turned on and on.

Between two long calls, we have two small calls and sometimes short calls (you note that I do nothing from the time of callback in the program) .

If we do this outside the average we get our desired callback time:

1/44100 * 256 (approximately 5.8 m)

Here's my measurement: Enter image details here

So someone can tell that what really happens under the hood here?

What happens under the hood in PortAudio, which is dependent on many factors

  • Which Original Audio API PortAds
  • You Pa_OpenStream () Li> Including audio hardware and its drivers' capabilities, its supported buffer size, buffering model, and features of time.

    In some circumstances, PortAdoes will request larger buffers from the original audio API, and then call PortAudio user callback several times in the early succession. This can happen if you have a small callback buffer size and a Long latency is selected

    Another scenario is that the original audio API does not support buffer size, which you requested for your callback size ( frames Prbfr parameter Pa_OpenStream () ). In this case, PortAudio will be forced to use a driver-supported buffer size and then there will be "customization" between that buffer size and your callback buffer size. This optimization process can cause irregular times.

    Yet another possibility is that the original audio API uses a large ring buffer. Each time PortAudio chooses the Basic Host API, it will work to fill the original ring buffer by calling several times as needed to your callback. In this case irregular time is related to the rate of voting.

    The above possibilities are not the only ones.

    A possible explanation of what is happening in your case is that PortAudio will call you 3 times in your fast succession (estimated that the original buffer size is 3x your callback buffer size), given above For one of the reasons

    Another possibility is that the original audio subsystem is signing port audio irregularly, this can happen, if a system layer at the bottom of the port adio has been described above. Same buffer C is I saw that for example with DirectSound on Windows 7. The ASIO4ALL driver will display +/- 1ms jitter (which is not what you are seeing).

    You can try to minimize the requested stream latency and see if the result changes, it will force double-buffering, which can not produce or produce stable production. Another thing to try is to use the paFramesPerBufferUnspecified parameter, which will call the callback with the original buffer size - then you can see what is the periodicity, what buffer size is, And whether the size of the buffer varies from callback to callback.

    You did not say which operating system and Host API you are targeting, so it is difficult to give more specific details than the above.

    To answer a related question: Why is it so? In addition to the cases where this is the function of the lower layers of the original audio subsystem, or the buffer adapter process, this is often the result of specifying a major recommended latency on Pa_OpenStream () . Some PortAudio Hosts will ease API buffer periodicity if the specified latency is too high, due to high frequency timer callback to reduce system load.

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -