Hi.. I normalized some wav files using the following code. The reason to normalize is that I need the sound to have the same power.
When I played it in low volume everything is okay. But when I get the volume up, the sounds get terrible and distorted.
What is going on?
data_dir = sprintf('%s/data/audio_wav/Uniq_uncued',root_dir);
files = dir(sprintf('%s/*.wav', data_dir));
for idx = 1:length(files)
file = sprintf('%s/%s', data_dir, files(idx).name);
[y,Fs] = audioread(file);
signalPower = sum(y.^2,1)/size(y,1);
new_y = y ./ sqrt( signalPower )/10;
new_signalPower = sum(new_y.^2,1)/size(new_y,1);
soundsc(new_y,Fs); pause(3);
yInt(yInt == 32768) = 32767;
[pathstr, name, ext] = fileparts(file);
audiowrite(sprintf('%s/%s_norm.wav', data_dir, name), yInt, Fs);
Thanks