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

    %% Code for the Whole System  
% This example shows how to write the full code for reading, filtering,
% and playing a file of audio data.   

%% 
% You can type this code on the command line or put it into a program file. 
audioIn = dsp.AudioFileReader('speech_dft_8kHz.wav',...
   'OutputDataType','single');
filtLP = dsp.FIRFilter('Numerator',fir1(160,.15));
audioOut = audioDeviceWriter('SampleRate',audioIn.SampleRate);

while ~isDone(audioIn)
    audio = step(audioIn);    % Read audio source file
    y = step(filtLP,audio);   % Filter the data
    step(audioOut,y);         % Play the filtered data
end 

%%
% The while loop uses the |isDone| method to read through the entire file.
% The |step| method is used on each object inside the loop.  

%% 
% Now, you are ready to run your system.