Borrar filtros
Borrar filtros

why is wavwrite clipping my data

2 visualizaciones (últimos 30 días)
tony karamp
tony karamp el 28 de Mzo. de 2013
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...

Respuesta aceptada

Jan
Jan el 28 de Mzo. de 2013
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.

Más respuestas (2)

Wayne King
Wayne King el 28 de Mzo. de 2013
Editada: Wayne King el 28 de Mzo. de 2013
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 el 1 de Abr. de 2013
Thank you all for your answers!!

Categorías

Más información sobre Data Import and Analysis en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by