How to see if a .WAV file is saturated?
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Ricardo Duarte
el 19 de Mayo de 2023
Comentada: Walter Roberson
el 25 de Mayo de 2023
Hello everyone,
I have a .wav file that I want to see if its signal is saturated or not.
In case it is saturated I would like to change the gain in order to prevent the saturation.
Do you have any idea about how to do this?
Thank you in advance.
1 comentario
Mathieu NOE
el 22 de Mayo de 2023
hello
if you take the abs of the magnitude of your data and if this is very close to 1 for a good amount of samples (above 1% ?) , then you know it's clipped
Respuesta aceptada
Walter Roberson
el 22 de Mayo de 2023
Movida: Walter Roberson
el 22 de Mayo de 2023
You may have to choose your "very close to 1" to be fairly strict for "above 1%" to work out as a boundary
Nsamp = 30000;
Fs = 8000;
t = (0:Nsamp-1)./Fs;
F = 5;
sig1 = sin(F*2*pi*t);
plot(t, sig1); title('unsaturated 5Hz')
sig2 = max(min(sig1*1.5, 1), -1);
plot(t, sig2); title('saturated 5Hz')
mean(abs(sig1) > 0.99988) * 100
mean(abs(sig2) > 0.99988) * 100
If you use a boundary of 0.99987 then more than 1% of the original non-saturated sine is "close" to 1. But more than 50% of the 1.5 * saturated signal is.
load handel %y, Fs
hNsamp = length(y);
hFs = y;
ht = (0:hNsamp-1)./Fs;
hsig1 = y;
plot(ht, hsig1); title('unsaturated Handel')
hsig2 = max(min(hsig1*1.5, 1), -1);
plot(ht, hsig2); title('saturated Handel')
mean(abs(hsig1) > 0.99988) * 100
mean(abs(hsig2) > 0.99988) * 100
max(abs(hsig1))
The original handel signal is -0.8 to +0.8 so none of it is "close" to 1 in the unsaturated version.
With 50% over-saturation, the peak would be 1.2 -- but even though this was constructed to be saturated (clipped) only about 1/4 of 1% is above the boundary that was needed for the pure sine wave.
We conclude from this that the strategy proposed by @Mathieu NOE cannot reliably distinguish clipping -- at least not by itself.
8 comentarios
Mathieu NOE
el 25 de Mayo de 2023
Just one remark
a good audio engineer asks the musicians to play the loudest part of their music and then set the microphone sensivity and analog gains so that the levels recorded remains 10 to 12 dB below clip level (headroom)
that means , we usually don't use the full range of the wav file dynamics, max 25% in practice (most of the time). Naturally there is a micro loss of accuracy vs the case you would use 99% of the range, but at your ears it would probably remains unoticeable.
At the beginning of the CD era, the co-inventors had devised that even a resolution of 14 bits was enough.
So using wav format on 16 bits with only 25% dynamic usage is good enough for many cases. Only the purist would say (maybe) something against it.
Walter Roberson
el 25 de Mayo de 2023
Some purists complain about their 24 bit per sample audio file not being good enough... (Sorry, Neil Young!)
Más respuestas (0)
Ver también
Categorías
Más información sobre Applications en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!