%% Reduce Latency Due to Input Device Buffer
% Latency due to the input device buffer is the time delay of acquiring one frame of data. In this example, you modify default properties of your audioDeviceReader object to reduce latency.
% Create an audioDeviceReader object with default settings.

deviceReader = audioDeviceReader

%
% Calculate the latency due to your device buffer.

fprintf('Latency due to device buffer: %f seconds.\n',deviceReader.SamplesPerFrame/deviceReader.SampleRate)

%
% Set the SamplesPerFrame property of your audioDeviceReader object to 64. Calculate the latency.

deviceReader.SamplesPerFrame = 64;
fprintf('Latency due to device buffer: %f seconds.\n',deviceReader.SamplesPerFrame/deviceReader.SampleRate)

%
% Set the SampleRate property of your audioDeviceReader System object to 96000. Calculate the latency.

deviceReader.SampleRate = 96000;
fprintf('Latency due to device buffer: %f seconds.\n',deviceReader.SamplesPerFrame/deviceReader.SampleRate)

% Copyright 2012 The MathWorks, Inc.