2015-11-04 76 views
1

我只是试图用wavwrite输出3个声音文件(.wav)。我在MATLAB中使用的数据使用soundsc可以播放声音,但由于某些原因,3个声音文件中的2个没有任何声音。在此之后wavwrite输出文件没有声音

[data,Fs] = wavread('prj1.wav'); %Data file I read in 
...%filtering with cascaded FIR filter 

dataFiltered = filter(Hd,data); %applying filter to data 
soundsc(dataFiltered,Fs) %plays perfectly 
pause(6) 
wavwrite(dataFiltered,Fs,'FIR_Cascade_Signal.wav'); %writes out perfectly, can play back fine. 

我的问题出现了:

...%Filter with different method, simple IIR filter if curious 

dataFiltered2 = filter(Gd,data); %applying second type of filter 
soundsc(dataFiltered2,Fs) %plays back fine, loud and clear 
pause(6) 

播放的声音完美

wavwrite(dataFiltered2,Fs,'IIR_Cascade_Signal.wav');%Outputted file has NO SOUND 

写出一个声音文件,但不能听到任何

...%Filtering with notch filter. This uses dataFiltered2 as the first stage, and then filters out a 30Hz harmonic with the Notch filter 

Yfilt_stage2 = filter(B,a,dataFiltered2); 
soundsc(Yfilt_stage2,Fs); %Plays loud and clear, can hear everything 
wavwrite(Yfilt_stage2,Fs,'Notch_Filtered_Signal.wav');%Again, no sound in output file 

任何帮助,将不胜感激!

+1

如果你用'sound'而不是'soundsc'来听它会发生什么?此外,'wavwrite'将在未来版本中被删除,也许你可以考虑使用'audiowrite'。 – JacobD

+0

听起来像'soundsc'。我也意识到'audiowrite'将会取代'wavewrite'。现在,功能是相同的,都不写出任何声音。我认为这可能只是我的电脑的一个问题,我正在研究它。 –

+0

你能提供一个极简的例子,我们可以重现这个问题吗?也许使用一些示例WAV文件和过滤器。另外,你是否能够通过每个阶段绘制信号并在'wavwrite'处找出问题? – JacobD

回答

0

这是我的电脑本身的问题。我在另一台计算机上试过我的代码,它工作正常。