現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
How to input noise during the audio transmission process ?
4 ビュー (過去 30 日間)
古いコメントを表示
Sisi Misi
2021 年 9 月 21 日
Hello everyone
I do audio compression with bit per sample variations like this:
[y,Fs]=audioread('water.wav');
audiowrite('testing.flac',y,Fs,'BitsPerSample', 8);
Now I also want to input noise into the process
Does anyone know how the code should be used?
thank you
採用された回答
Mathieu NOE
2021 年 9 月 21 日
hello
if you simply want to add some white noise you can do this
[y,Fs]=audioread('water.wav');
y = y + 0.1*randn(size(y)); % adjust amplitude to your needs
y = y./max(abs(y)); % normalize data to avoid saturation (may be depend on output format)
audiowrite('testing.flac',y,Fs,'BitsPerSample', 8);
you can also add a low or high or bandpass filter on the random noise if you want to have noise in a certain frequency range.
19 件のコメント
Sisi Misi
2021 年 9 月 22 日
編集済み: Sisi Misi
2021 年 9 月 22 日
alright Mr, thank you
But I have another question, when I listen to the results I completely lose the original audio. What if we want to input noise into the audio but the original audio is still heard and can keep the audio in 2 channels, because my original audio is 2 channels?
I'm confused because I'm using lossless compression here
Mathieu NOE
2021 年 9 月 22 日
hello
could you share your wav file ? the amount (amplitude) of noise must be adapted to the amplitude of your sgnal so you must probably do some trials
if you can share your wav file I can further help you;
Sisi Misi
2021 年 9 月 22 日
This is the audio folder Mr
This audio is obtained from the music cloud
This audio consists of two channels, I did a lossless compression process (into a .flac format codec) with variations in bits per sample (24, 16, and 8 bits) and in the transmission process I had to put noise into it. Then decompress it back into a wav file
I want to see the performance of the lossless audio codec how resistant the audio is to noise, because what I read for lossless compression is noise resistance
I hope you can help me because I'm still confused about what I'm doing now
Thank you very much Mr
Mathieu NOE
2021 年 9 月 22 日
hello
I simply reduced the noise amplitude so it's now clearly audible in the flac version , without hiding the audio content. You can still adjust the amplitude (here 0.01) to your needs and play with flac resolution
[y,Fs]=audioread('water.wav');
y = y + 0.01*randn(size(y)); % adjust noise amplitude to your needs
y = y./max(abs(y)); % normalize data to avoid saturation (may be depend on output format)
audiowrite('testing.flac',y,Fs,'BitsPerSample', 8);
Sisi Misi
2021 年 9 月 22 日
alright Mr
how to keep the new audio that is saved in two channels?
is there any code to add?
Mathieu NOE
2021 年 9 月 22 日
the output in flac is stereo , I didn't changed anything to the audio size (2 channels)
Sisi Misi
2021 年 9 月 22 日
ok Mr
In matlab 2015b there is an error like this :
but after i tried it in matlab online
everything is fine
I'm sorry Mr
Thank you so much
Image Analyst
2021 年 9 月 22 日
There should be no difference between local and online versions of MATLAB. Can you reproduce this error?
Mathieu NOE
2021 年 9 月 22 日
Maybe my fault
this should avoid any issue now :
replace
y = y./max(abs(y)); % normalize data to avoid saturation (may be depend on output format)
with
y = y./max(abs(y),[],'all'); % normalize data to avoid saturation (may be depend on output format)
Sisi Misi
2021 年 9 月 23 日
I don't know Mr
There is still an error here, when I use
[y,Fs]=audioread('water.wav');
y = y + 0.01*randn(size(y)); % adjust noise amplitude to your needs
y = y./max(abs(y),[],'all');% normalize data to avoid saturation (may be depend on output format)
audiowrite('testing8.flac',y,Fs,'BitsPerSample', 8);
audiowrite('testing8.wav',y,Fs)
so I try another code like this, but still errorr
[y,Fs]=audioread('water.wav');
y = y + 0.01*randn(size(y)); % adjust noise amplitude to your needs
y = y./max(abs(y),[],'omitnan');% normalize data to avoid saturation (may be depend on output format)
audiowrite('testing8.flac',y,Fs,'BitsPerSample', 8);
audiowrite('testing8.wav',y,Fs)
but in matlab online, everything is fine Mr
Mathieu NOE
2021 年 9 月 23 日
hello
I think the older 2015 release is not compatible with the syntax max(abs(y),[],'all');
I use the R2020b with works fine.
in case you stick to R2015 , try this modification :
% normalize data to avoid saturation (may be depend on output format)
% m = max(abs(y),[],'all'); % R2020
m = max(abs(y(:))); % R2015 and below
y = y./m; % normalize data
Sisi Misi
2021 年 9 月 30 日
Hi Mr Mathieu NOE
I want to ask you again
I got instructions again to input noise into the audio when we transmit
it means when we do compression
in the "audiowrite" function and in that function we directly input the noise
can we do that Mr ?
Mathieu NOE
2021 年 9 月 30 日
hello
the compression is done inside the audiowrite function , depending of the format (flac is compressed)
you don't have to do anything in your own code as compression is done by audiowrite function
Sisi Misi
2021 年 10 月 1 日
yes Mr
I mean, we input noise into the compressed audio instead of the original audio
or maybe when we save the compressed audio we input the noise,
the point is that the input noise is not original audio but compressed audio, immediately when we save the compressed audio
do you understand what I mean Mr ?
sorry I'm confused how to convey it, I hope you understand
because really I need your help
thank you Mr
Mathieu NOE
2021 年 10 月 1 日
hello
so far the code will add the noise to the original audio , not the compressed audio
the compression is done after the noise is added (y = y + 0.01*randn(size(y));) , because as explained above , the compression is done inside audiowrtite when you select a certain type of format (wav and flac are both compressed audio formats)
その他の回答 (0 件)
参考
カテゴリ
Help Center および File 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!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)