How to input noise during the audio transmission process ?
1 次查看(过去 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!发生错误
由于页面发生更改,无法完成操作。请重新加载页面以查看其更新后的状态。
您也可以从以下列表中选择网站:
如何获得最佳网站性能
选择中国网站(中文或英文)以获得最佳网站性能。其他 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 (한국어)