frames should be the number of frames (samples) that you want to write from the buffer. Your sound system driver will start transferring these samples to the sound card immediately, and they will play at a constant speed.
The delay is entered in several places. There is a wait time from data buffered by the driver, waiting for transmission to the card. There is at least one buffer filled with data that is transferred to the card at any given time, and there it is buffered on the application side, which bothers you.
To reduce the latency on the application side, you need to write the smallest buffer that will work for you. If your application performs the DSP task, then usually this value is in one window.
It makes no sense to write small buffers in a loop - just go ahead and write everything all at once - but there is an important point to understand: to minimize latency, your application should write to the driver no faster than the driver writes data to the sound card, or youβll finish accumulating more data and accumulate more and more delays.
For a design that makes creating data in a lock with a sound driver relatively easy, look at the connector ( http://jackaudio.org/ ), which is based on registering a callback function with a sound engine. In fact, you are probably just better off using jack instead of trying to do it yourself if you're really concerned about the delay.
source share