A list,

1 Overall process design 1.1 Spectrum analysis of sample audio signals 1.2 Filtering of audio signals 1.3 PCM coding of audio signals 1.4 Hamming coding of encoded signals 1.5 QPSK modulation of encoded signals 1.6 Sending signals into AWGN channel 1.7 QPSK demodulation for received signals 1.8 Channel decoding – Hamming error correction and decoding 1.9 PCM decoding and playback of audio signals

2 Description of main modules

2.1 PCM Codec – PCMcoder ()& PCMdecoder ()

PCM is pulse modulation, the compression characteristic selected is a-law, and the 13-broken line coding algorithm is adopted, as shown in the figure below.



As can be seen from the figure, 0 ~ 1 of X axis is divided into 8 non-uniform segments, which are divided as follows: divide 0 ~ 1 into two parts, where the point is L, 2, and take 1/2 ~ 1 as the eighth segment; The remaining 0-1/2 is divided into two parts. The midpoint is 1/4, and between 1/4 and 1/2 is taken as the seventh paragraph. The remaining 0-1/4 is divided into two parts, and the midpoint is 1/8, between 1/8 and 1/4 is taken as the sixth paragraph. The 0 ~ 1 of the Y axis are evenly divided into eight segments, which correspond to the eight segments of the x axis. From the first paragraph to the eighth paragraph, 0 ~ 1/8, 1/8 — 2/8… 7/8 ~ L. In this way, a broken line consisting of eight straight lines can be made. Plus the eight sections of broken line in the third quadrant, there are l6 sections in total. Since the first and second sections in the positive direction have the same slope as the first and second sections in the negative direction, these four sections are actually a straight line. Therefore, the positive and negative bidirectional broken line is composed of L3 straight line segments in total, so it is called 13 broken line.

2.2 Hanmingcoder ()& Hanmingdecoder ()

Hamming code is a linear block code. Linear block code is to divide the information sequence into sequence segments of length K, and to attach r supervisory codes at the end of each segment, and a linear relationship is formed between supervisory codes and information codes, that is, they can be connected by linear equations. The anti-jamming codes thus constructed are called linear grouping.

Code.

Let the code length be N, the information bit length be K, and the supervisory bit length be r=n-k. If we need to correct one bit, because every bit of a sequence of length N can go wrong, there are n cases, and there are also cases that don’t go wrong, so we have to represent n+1 cases with a monitor code of length R. A monitor code of length R can represent a total of 2^r. The (7,4) hamming code is adopted, the original information code is grouped with 4 bits, and the supervision code with 3 bits is adopted.

Hamming code is a very strict verification coding method. Through 3 times combination detection of 3 bits of 4 data bits to achieve the purpose of verification and correction of specific code bits (but only 1 bit error is allowed, two errors can not be checked out). When checking each hamming code and their corresponding data value addition, if the result is even (error correction code 0) is correct, if it is an odd number of error correction code (1) shows the current hamming code corresponding to the three there are errors in the data bits, at this point again by two other hamming code their calculations to determine the specific which is out of the question.

First input 7-bit Hamming code A1A2A3A4A5A6A7 when decoding, then calculate the values of corrector S1,S2,S3 and S4 according to the 7-bit code A1A2A3A4A5A6a7, know the relationship between corrector S and (7,4) Hamming code bits, to determine the relationship between corrector and 0, if equal to 0, it means there is no error; If it is not 0, one of them is wrong. By correcting the relation between S and error pattern E, the error pattern and the decoded output are added modulo two to correct the error. Output the hamming code with no error or the hamming code with 1 error corrected to complete the decoding program.

2.3 QPSK Modulation and demodulation — QPSKcoder ()& QPSKdecoder ()





Fruit.

Ii. Source code

clc; clear all; %/ * * * * * * * * * * * * * * * * * * * * * * * * * read the audio file * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * /
long=input('Length of music you want to process (recommended value under 200 000, too long will be slow) :');
disp('********** please enjoy the music sent *********')
[x,fs]=audioread('High mountain and flowing water.wav'[1 long]);
sound(x,fs);
X=fft(x,long);
magX=abs(X); angX=angle(X); figure; % subplot drawing (321); plot(x); title('Original signal waveform');
subplot(322); plot(abs(X)); title('Raw signal spectrum');


%/ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * of the audio signal filtering * * * * * * * * * * * * * * * * * * * * * * * * * * /
N=5; wc=4000/6000; [b,a]=butter(N,wc); % Filter with butterworth filter X= FFT (X); subplot(323); plot(x); title('Waveform of signal before filtering');
subplot(324); plot(abs(X)); title('Spectrum of signal before filtering');
y=filter(b,a,x);
Y=fft(y);
subplot(325); plot(y); title('Waveform of IIR filtered signal');
subplot(326); plot(abs(Y)); title('Spectrum of IIR filtered signals');


%/ * * * * * * * * * * * * * * * * * * * * * * * * * for PCM audio signals encoding * * * * * * * * * * * * * * * * * * * * * * * * * /
L=length(y);
pcmy=pcmcoder(y,L,long);

%/ * * * * * * * * * * * * * * * * * * * * * * * * * the encoded signal channel coding - hamming coding * * * * * * * * * * * * /

s=pcmy;
L=length(s);
h=zeros(1,L+L/4*3); % produces the encoding sequence N=L+L/4*3;
h=hanmincoder(s,L);
 
 
%/ * * * * * * * * * * * * * * * * * * * * * * * * * to the encoded QPSK modulation signal is * * * * * * * * * * * * * * * * * * * * /
sig=qpskcoder(N,h);



%/ * * * * * * * * * * * * * * * * * * * * * * * * * send signal in AWGN channel * * * * * * * * * * * * * * * * * * * * * * * * * * /% add noise n=noise(n,L); r=sig+n; % detector input module %/ * * * * * * * * * * * * * * * * * * * * * * * * * received QPSK demodulation signal is * * * * * * * * * * * * * * * * * * * * /    
rr=qpskdecoder(N,r);
 
%/ * * * * * * * * * * * * * * * * * * * * * * * * * channel decoding - hamming error correction and decoding * * * * * * * * * * * * * * * * * * * * * * * /
y=hanmingdecoder(rr,L) ;

%/ * * * * * * * * * * * * * * * * * * * * * * * * * for PCM decoding audio signals * * * * * * * * * * * * * * * * * * * * * * * * /
pcmyout=pcmdecoder(y,long);
disp('********** please enjoy the music received *********')
sound(pcmyout,fs); 

disp('********** that's all, thank you *********'Y =hanmingdecoder(rr,Lfor i=1:length(rr)/7
        s01=xor(xor(xor(rr(7*i- 6),rr(7*i- 5)),rr(7*i4 -)),rr(7*i2 -));
        s02=xor(xor(xor(rr(7*i- 6),rr(7*i- 5)),rr(7*i- 3)),rr(7*i- 1));
        s03=xor(xor(xor(rr(7*i- 6),rr(7*i4 -)),rr(7*i- 3)),rr(7*i0));
         if s01==0&&s02==0&&s03==1;
             rr(7*i)=not(rr(7*i));
         elseif s01==0&&s02==1&&s03==0;
             rr(7*i- 1) =not(rr(7*i- 1));
         elseif s01==1&&s02==0&&s03==0;
             rr(7*i2 -) =not(rr(7*i2 -));    
         elseif s01==0&&s02==1&&s03==1;
             rr(7*i- 3) =not(rr(7*i- 3));
          elseif s01==1&&s02==0&&s03==1;
             rr(7*i4 -) =not(rr(7*i4 -));
          elseif s01==1&&s02==1&&s03==0;
             rr(7*i- 5) =not(rr(7*i- 5));
          elseif s01==1&&s02==1&&s03==1;
             rr(7*i- 6) =not(rr(7*i- 6));
         elseif s01==0&&s02==0&&s03==0;
             continue; Y =zeros(0) y=zeros(0)1,L); % Final sequence j=1;
for i=0:length(rr)/7- 1
    y(j)=rr(7*i+1);
    y(j+1)=rr(7*i+2);
    y(j+2)=rr(7*i+3);
    y(j+3)=rr(7*i+4); % Take the first four codes of each sequence unit j=j+4;
end
end
Copy the code

3. Operation results



Fourth, note

Version: 2014a complete code or write plus 1564658423