Can the audiostreamer buffer size be read when it is set to Auto with an ASIO driver?

In the new 'audiostreamer' object (introduced in R2025a), the DeviceBufferSize can be set to "auto", for which the documentation says "For ASIO, it is generally fixed by the device (see asiosettings)". Is there any way of reading back what buffer size it has gotten from the ASIO driver? That would be very useful in optimizing my code

Answers (1)

Hi Glenn,
I understand you want to know how to determine the actual buffer size being used by the "audiostreamer" object when set to "auto" with an ASIO driver.
To do this, you should first check which ASIO devices are available on your system by running the following command:
>> devices = audiostreamer.getAudioDevices()
Once you know the exact device name, you can use MATLAB’s ASIO settings functionality to query the current buffer size that the device is using. This buffer size is determined by the ASIO driver and is what audiostreamer will use in "auto" mode. The buffer size information can be accessed through the "asiosettings" command interface in MATLAB.
You can refer the following document to know more about audio I/O buffering:
Hope this helps!

5 Comments

Ayush is correct. For ASIO, the frame size in "auto" mode is specified by the ASIO device driver. Here's how I'd do it (at least with the latest version) :
>> as = audiostreamer(Driver="ASIO")
>> asiosettings(as)
I'm curious to know if there's a use-case for doing this entirely programmatically, but I don't think we know the "auto" frame size until the device has started playing and/or recording. Also, some drivers like DirectSound have buffer sizes that change every frame when set to "auto" mode.
I would like to know what the buffer size is programmatically rather than calling 'asiosettings' and viewing the settings. The reason is that I want to stream in audio from a soundcard input, do some processing on it, and then stream it out to the soundcard output. However, I want to do it with the least amount of latency possible. Generally, the amount of processing can be done within one buffer time, but occasionally there may times when it takes too long and then there is an underrun. In order to prevent the underrun, I want to have the audio output lag by one buffersize so that if the processing takes too long once in a while, it can recover without losing any samples. It would be helpful to know the buffersize so that I can know the optimal size of the output lag. If I make it lag by less than one buffersize, it won't help. If I make it lag by more than two buffersizes, it adds additional latency that is unnecessary.
I am only using ASIO, not DirectSound, so I believe that the buffer size is fixed.
If there is some other way to accomplish this, please let me know
Have you looked into the callback options? You could process audio the moment it becomes available, and this also keeps the Command Window unblocked. RecorderFcn can be any matlab function that takes two inputs, the audiostreamer object and the event description struct. That function can process the recorded and play the result. Just for illustration, the following displays how many samples were read in the callback.
as = audiostreamer(Mode="full-duplex",Driver="ASIO")
as.RecorderFcn = @(obj,ev)disp(size(read(as),1)) % display how many samples were read
record(as)
...
stop(as)
Yes, I am using the callback options. I guess that I can infer what the buffer size size is by looking at NumRecorderSamples a few times and assume that the buffer size is the smallest number that I read. It seems like quite an indirect way of doing things though. It would require me to run some audio data with no output to find out the buffer size before I start my actual audio processing.
By the way, in testing this, I discovered a really strange issue with my Komplete Audio 6 ASIO driver. In the asiosettings for that driver, I can view the buffer size, but whenever my MATLAB code starts playing audio with 'play' or 'playrec', I see the buffer size displayed has incremented to the next size up (i.e. doubled in size). After running my code a few times, the buffer size eventually reaches 2048, which is the largest setting, and it stays there. I don't see this behavior with a couple other ASIO drivers, so maybe it's a Komplete Audio bug? Weird! If someone else has a Komplete Audio soundcard, maybe they can test it.
Hi Glenn, I have recently seen the doubling issue. It happens with some brands but not others, so I suspect it's a device driver issue, but we found a way to avoid the problem with a change on our end. This will ship in 26a and a 25b update.

Sign in to comment.

Categories

Find more on Audio I/O and Waveform Generation in Help Center and File Exchange

Products

Release

R2025b

Asked:

on 12 Dec 2025

Commented:

on 18 Dec 2025

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!