www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/ReduceLatencyDueToOutputDeviceBufferExample.m
%% Reduce Latency due to Output Device Buffer % Modify default properties of your |audioDeviceWriter| System object(TM) % to reduce latency due to device buffer size. %% % Create a |dsp.AudioFileReader| System object to read an audio file with % default settings. fileReader = dsp.AudioFileReader('speech_dft.mp3'); %% % Create an |audioDeviceWriter| System object and specify the sample rate % to match that of the audio file reader. deviceWriter = audioDeviceWriter(... 'SampleRate',fileReader.SampleRate); %% % Calculate the latency due to your device buffer, in seconds. bufferLatency = fileReader.SamplesPerFrame/deviceWriter.SampleRate %% % Set the |SamplesPerFrame| property of your |dsp.AudioFileReader| System % object to 256. Calculate the buffer latency in seconds. fileReader.SamplesPerFrame = 256; bufferLatency = fileReader.SamplesPerFrame/deviceWriter.SampleRate