www.gusucode.com > dsp 案例源码程序 matlab代码 > dsp/WriteAnAudioSignalToAWAVFileExample.m
%% Write an Audio Signal to a WAV File %% % *Note*: This example runs only in R2016b or later. If you are using an % earlier release, replace each call to the function with the equivalent % |step| syntax. For example, myObject(x) becomes step(myObject,x). %% % Decimate an audio signal, and write it to disk as a WAV file. hmfr = dsp.AudioFileReader('OutputDataType',... 'double'); hfirdec = dsp.FIRDecimator; % decimate by 2 hmfw = dsp.AudioFileWriter... ('speech_dft.wav', ... 'SampleRate', hmfr.SampleRate/2); while ~isDone(hmfr) audio = hmfr(); audiod = hfirdec(audio); hmfw(audiod); end release(hmfr); release(hmfw);