www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/DecreaseUnderrunSimulinkExample.m

    %% Decrease Underrun
% Examine the Audio Device Writer block in a Simulink(R) model, determine
% underrun, and decrease underrun.
%
open_system('DecreaseUnderrunModel')

%% 
% 1. Run the model. The Audio Device Writer sends an audio stream to your
% computer's default audio output device. The Audio Device Writer block
% sends the number of samples underrun to your 
% <matlab:web(fullfile(docroot,'dsp/ref/timescope.html')) Time Scope>.
% 
open_system('DecreaseUnderrunModel/Time Scope')
sim('DecreaseUnderrunModel',5)

%%
% 2. Uncomment the Artificial Load block. This block performs computations
% that slow the simulation.
%
% 3. Run the model. If your device writer is dropping samples:
%
% a. Stop the simulation.
%
% b. Open the 
% <matlab:web(fullfile(docroot,'dsp/ref/frommultimediafile.html')) From Multimedia File>
% block.
%
% c. Set the *Samples per frame* parameter to |1024|.
%
% d. Close the block and run the simulation.
%
% If your model continues to drop samples, increase the frame size again.
% The increased frame size increases the buffer size used by the sound card. A larger buffer
% size increases the possibility of underruns at the cost of higher audio
% latency.
%
close_system('DecreaseUnderrunModel')