フィルターのクリア

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 Center および File ExchangeData Import and Analysis についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by