How to write audio without data clipping?

2 次查看(过去 30 天)
Hello,
I want to write audio without data clipping. I tried by multiplying audio coefficients with float number (e.g. 0.1, 0.5, 0.001, etc.) to get the value within the range of -1 to +1. But this error are still occurred Warning: Data clipped when writing file. In audiowrite>clipInputData In audiowrite . I would be grateful if someone help me in this error.

采纳的回答

Star Strider
Star Strider 2018-2-15
Try this to normalise the signals before you write them:
t = 0:99; % Time Vector (For Plotting)
V1 = randi([-9 9], 100, 1); % Create Out-Of-Range Data
V2 = V1 / max(abs(V1)); % Normalise To ±1
figure(1)
plot(t, V1, t, V2)
hold on
plot(xlim, [1 1], '--k')
plot(xlim, [-1 -1], '--k')
hold off
grid
legend('Original', 'Normalised', '±1')
The code simply divides all the data by the maximum of the absolute value (so it is not necessary to test both the positive and negative values). The plot illustrates the input and output of the normalisation.
Experiment to get the result you want.

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Audio I/O and Waveform Generation 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by