Filter löschen
Filter löschen

How to write audio without data clipping?

5 Ansichten (letzte 30 Tage)
Su Latt Sandi
Su Latt Sandi am 15 Feb. 2018
Kommentiert: Pham Xuan Trung am 9 Jul. 2020
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.

Akzeptierte Antwort

Star Strider
Star Strider am 15 Feb. 2018
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.
  3 Kommentare
Star Strider
Star Strider am 16 Feb. 2018
My pleasure.
If my Answer helps you solve your problem, please Accept it!
Pham Xuan Trung
Pham Xuan Trung am 9 Jul. 2020
It works perfectly. You are amazing!

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Audio I/O and Waveform Generation finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by