How to write audio without data clipping?

조회 수: 9 (최근 30일)
Su Latt Sandi
Su Latt Sandi 2018년 2월 15일
댓글: Pham Xuan Trung 2020년 7월 9일
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.
  댓글 수: 3
Star Strider
Star Strider 2018년 2월 16일
My pleasure.
If my Answer helps you solve your problem, please Accept it!
Pham Xuan Trung
Pham Xuan Trung 2020년 7월 9일
It works perfectly. You are amazing!

댓글을 달려면 로그인하십시오.

추가 답변 (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