%% Reduce the Sample Rate of an Audio Signal
% Note:  If you are using R2016a or an earlier release, replace each call to the object with the equivalent step syntax. For example, obj(x) becomes step(obj,x).
% Note: The audioDeviceWriter System object™ is not supported in MATLAB Online.
% This example shows how to reduce the sampling rate of an audio signal by 1/2 and plays it.

afr = dsp.AudioFileReader('OutputDataType',...
  'single');
adw = audioDeviceWriter(22050/2);
firdecim = dsp.FIRDecimator;

while ~isDone(afr)
     frame = afr();
     y = firdecim(frame);
     adw(y);
end

release(afr); 
pause(0.5);
release(adw);

%
% Copyright 2012 The MathWorks, Inc.