필터 지우기
필터 지우기

Writing a wav file using Matlab

조회 수: 2 (최근 30일)
Micaela
Micaela 2012년 10월 11일
댓글: Shlomit 2014년 12월 15일
I have a question: I have created some audio files using Matlab, with a sampling frequency of 10000 Hz, and when I try to use the function wavwrite in order to generate the corresponding wav files, I have this warning:
"Data clipped during write to file..."
I know that this problem is generated by the amplitude of the signals, because it must be normalized to 1, and I have tried to use this line of code:
signal = signal/max(abs(signal));
but the problem isn't solved. Can anyone tell me how can I solve this problem? Thanks a lot.

채택된 답변

Wayne King
Wayne King 2012년 10월 11일
편집: Wayne King 2012년 10월 11일
If you are using
wavwrite(Y,FS,WAVEFILE)
then the acceptable range for the data, Y, is -1.0 <= Y < +1.0
so I'm assuming that you have values in your output equal to 1, which is resulting in the clipping. One thing you can do is to use 32 bits to write the file. That has output format implications -- see the help for wavwrite
wavwrite(Y,FS,32,WAVEFILE)
or you can add a small deltaA to your scaling factor that would avoid you getting a 1.
deltaA = 0.1;
signal = signal./(max(abs(signal))+deltaA);
  댓글 수: 3
Micaela
Micaela 2012년 10월 12일
Ok, I have solved the problem with this line of code (supposing that I write the file with 24 bits) :
signal = signal./max(abs(signal(:)))*(1-(2^-(24-1)));
Thank you of all:)
Shlomit
Shlomit 2014년 12월 15일
This helped a lot, Thank you Micaela!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by