Getting a warning with audiowrite ( audiowrite​>clipInput​Data)

3 ビュー (過去 30 日間)
carine
carine 2023 年 6 月 14 日
コメント済み: Walter Roberson 2023 年 6 月 15 日
I'm trying to read an audio file, add a white noise and then write the resampled audio to a file at 48 kHz. I'm getting a warning
" Warning: Data clipped when writing file. > In audiowrite>clipInputData (line 481)"
can someone please help me with that?
clc
clear
[y, Fs] = audioread('test.wav');% y samples from audio with Fs sampling frequency in [Hz]
sound(y, Fs); % listen to the audio input
Sigma = 1; % Standard deviation of the noise
N = length(y); % sample lenth
w = Sigma*randn(1,N); % Generate Gaussian noise
x = y+w'; % Add noise to the audio signal
figure (1)
plot(x); % Plot the noisy audio signal
figure (2)
plot(y); % plot the audio
x_sampled = resample(x,3,1); % sampling frequency to 48 kHz
audiowrite('Noisy_resampled.wav',x_sampled, Fs); % Write the resampled audio to a file
[y, Fs] = audioread('Noisy_resampled.wav'); % Read the resampled audio
sound(y, Fs);

回答 (1 件)

Richard Burnside
Richard Burnside 2023 年 6 月 14 日
編集済み: Richard Burnside 2023 年 6 月 14 日
Probably exceeding the audiowrite range for the data type. ML Docs shows:
Data Type of Y Valid Range for Y
-----------------------------------
uint8 0 <= Y <= 255
int16 -32768 <= Y <= +32767
int32 -2^31 <= Y <= 2^31-1
single -1.0 <= Y <= +1.0
double -1.0 <= Y <= +1.0
"Data beyond the valid range is clipped."
You could try a scalar attenuation of your data.
  2 件のコメント
carine
carine 2023 年 6 月 14 日
thanks for your response Ricahard. how can I do the scalar attenuation?
Walter Roberson
Walter Roberson 2023 年 6 月 15 日
x = x ./ max(abs(x));

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeAudio Processing Algorithm Design についてさらに検索

タグ

製品


リリース

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by