2

我们最近学习了错误控制编码的概念 - 基本代码,如汉明码、重复码等。

我想在 MATLAB 中尝试这些概念。我的目标是比较音频文件在被噪音破坏时的播放方式,以及在文件受到基本代码保护然后被噪音破坏的情况下。

所以我在 MATLAB 中使用 audioread 函数打开了一个 20-30 秒的小音频片段。我使用了 16 位编码的 PCM 波形文件。如果以“本机”格式打开,则为 int16 格式。如果不是,它将以双重格式打开。

然后我向其中添加了两种类型的噪声: - AWGN 噪声(使用双格式)和二进制对称通道噪声(通过将 int16 转换为 uint16,然后使用 dec2bin 函数将其转换为二进制)。重新转换回原来的 int16 格式确实会增加很多噪音。

现在我的目标是尝试一个基本的重复代码。所以我所做的是通过添加冗余将由二进制数据组成的 2-d 音频文件矩阵转换为 3-d 矩阵。我使用了以下命令: -

猫(3,x,x,x,x,x);

它创建了一个 3-D 矩阵,使其在第 3 维上有 5 个版本的 x。

现在我希望使用 bsc 函数为其添加噪音。然后我希望通过在包含冗余位的向量上使用 mode() 函数删除重复位来对冗余数据进行解码。

我在这项任务中的全部问题是 MATLAB 进行计算的时间太长了。我猜一个 30 秒的文件会创建一个相当大的矩阵,所以可能需要时间。此外,我怀疑就各种数据类型而言,我所做的并不是最有效的方法。

你能建议一种我可以改进计算时间的方法吗?是否有一些功能可以帮助以更好的方式完成这项基本任务。

谢谢。(本网站上关于 MATLAB 的第一篇文章,如果发布格式不符合要求,请多多包涵。)

编辑-在此处发布代码:-

[x,Fs] = audioread('sample.wav','native'); % native loads it in int16 format , Fs of sample is 44 khz , size of x is 1796365x1
x1 = x - min(x); % to make all values non negative
s = dec2bin(x); % this makes s as a 1796365x15 matrix the binary stream stored as character string of length 15. BSC channel needs double as the data type
s1 = double(s) - 48; % to get 0s and 1s in double format

%% 现在我想比较噪声如何影响 s1 本身或错误控制编码的矩阵。

s2 = bsc(s,0.15); % this adds errors with probability of 0.15
s3 = cat(3,s,s,s,s,s) ; % the goal here is to add repetition redundancy. I will try out other efficient codes such as Hamming Code later.
s4 = bsc(s3,0.15);% this step is taking forever and my PC is unresponsive because of this one.
s5 = mode(s4(,,:)) ; % i wish to know if this is a proper syntax, what I want to do is calculate mode along the 3rd dimension just to remove redundancy and thereby reduce error.

%% 我将展示我在 s 被 s2 中的 bsc 错误破坏后所做的事情,

 d = char(s2 + 48);
 d1 = bin2dec(d) + min(x);
 sound(d1,Fs); % this plays the noisy file. I wish to do the same with error control coded matrix but as I said in a previous step it is highly unresponsive.

我想我的任务最大的问题是我采用了很大的采样率,因此向量非常大。

4

0 回答 0