필터 지우기
필터 지우기

why is wavwrite clipping my data

조회 수: 2 (최근 30일)
tony karamp
tony karamp 2013년 3월 28일
Hello all,
I have this sinwave and I want to save it as a wav file. I use the wavwrite function but when I run the script I get a warning saying that the data has been clipped during write to file.
Is there a way to scale everything like the function soundsc does?
Thanks a bunch...

채택된 답변

Jan
Jan 2013년 3월 28일
Whenever you get a problem with a command in Matlab, it is recommended to read the intructions:
doc wavwrite
There you find, that the range is limited to –1.0 <= y < +1.0 for 8, 16 and 24 bits, while +1.0 is allowed for 32 bit only. Or if you have integer data (ayour see, it would be helpfujl if you explain this detail in your question), there are other ranges also.

추가 답변 (2개)

Wayne King
Wayne King 2013년 3월 28일
편집: Wayne King 2013년 3월 28일
the values in your sine wave likely exceed [-1, 1] or come so close to [-1, 1] that they are 1 for all intents and purposes. The are a number of ways to work around this.
%assuming the sine wave is zero mean
t = 0:0.001:1-0.001;
x = 2*cos(2*pi*100*t);
[val,idx] = max(abs(x));
x = x./(max(abs(x))+0.01);
wavwrite(x,1000,16,'test.wav');
If it's not zero mean then first subtract the mean
x = 2+cos(2*pi*100*t);
x = x-mean(x);
x = x./(max(abs(x))+0.01);

tony karamp
tony karamp 2013년 4월 1일
Thank you all for your answers!!

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by