This post was last edited by bqgup on 2020-9-18 14:31 # Exploration of the difference between left and right channel signals of audio## 1. Get audio#### Use a smart device to get a classic audio from the movie "Drug War" - "Duan Kun, I'm determined to eat it",
段坤我吃定了音频.mp3
(164.49 KB, downloads: 7)
``` [y,Fs] = audioread('E:\8,matlab\echo voice changer processing\Duan Kun, I'm determined to eat it audio.mp3'); ``` #### After running in MATLAB, the results are shown as follows:
#### Among them, Fs represents the sampling rate, which is 44100Hz. In the process of signal processing, in order to keep the signal undistorted, the Nyquist sampling theorem must be satisfied during sampling. To put it simply, the frequency range of human speech is 300Hz-3400Hz, the frequency range of audio signal color is 20Hz-20000Hz, and the frequency of our daily audio signal is also 20Hz-20000Hz, with a maximum frequency of 20000Hz. The Nyquist sampling theorem is that the sampling frequency must be at least twice the maximum frequency, that is, the sampling frequency is #### Fs=2*20000Hz=40000Hz, #### There will be a certain amount of redundancy in the actual sampling process, which is what the sampling theorem means. Now the result of Fs is clear at a glance; the resulting y is an array of 46425 rows and 2 columns, which represent the left and right channels respectively. The first column is the left channel, and the second column is the right channel. 46425 represents the number of data points of this audio at the sampling rate of FS. #### You can listen to the quality of the audio through the command and play it through the computer. ``` sound(y,Fs) ``` #### If you change the size of Fs, the sound will change. You can experiment yourself. #### In order to get rid of some unnecessary audio at the beginning and end of the audio, we can clip the audio through the command: ``` [y,Fs] = audioread('E:\8、matlab\回声变声处理\段坤我吃定了音频.mp3',[1000,420000]); ``` #### After clipping, you can see that the data length has indeed become smaller:
#### Next, save the clipped audio to a folder through the command: ``` audiowrite('E:\8、matlab\回声变声处理\段坤我吃定了接取.wav',y,Fs) ``` #### There is a newly named audio file in the folder:
## 2. Differences between left and right channel signals#### I listened to the sound of the left and right channels and felt that there was no difference. I could only look at the details of the left and right channel signals. We will directly process the intercepted audio. ### 2.1 Time Domain Exploration``` %%%% Audio signal left and right channel signal processing%%%% function Audio_LR_Pro() [y,Fs] = audioread('E:\8,matlab\echo voice changer processing\Duan Kun I am determined to intercept.wav'); Length = length(y); %% Signal length y_left = y(:,1); %% Left channel signal y_right = y(:,2); %% Right channel signal m = 1 : 1 : Length; subplot(211); plot(m/Fs,y_left); title('Left channel time domain changes'); xlabel('t'); ylabel('y_left') subplot(212); plot(m/Fs,y_right); title('Right channel time domain changes'); xlabel('t'); ylabel('y_right') ``` #### The time domain comparison results are as follows:
### 2.2 Frequency domain exploration``` %%%% Audio signal left and right channel signal processing%%%% function Audio_LR_Pro_Freq() [y,Fs] = audioread('E:\8、matlab\echo voice changer processing\Duan Kun I am determined to intercept.wav'); Length = length(y); %% Signal length y_left = y(:,1); %% Left channel signal y_right = y(:,2); %% Right channel signal m = 1 : 1 : Length; subplot(211); plot((m-1)*Fs/Length,abs(fft(y_left))); title('Left channel frequency domain change'); xlabel('f'); ylabel('A_y_left') subplot(212); plot((m-1)*Fs/Length,abs(fft(y_right))); title('Frequency domain changes of right channel'); xlabel('f'); ylabel('A_y_right') ``` #### The comparison of frequency domain results is as follows:
### 2.3 Delay Exploration``` %%%% Audio signal left and right channel signal processing%%%% function Audio_LR_Pro_Delay() [y,Fs] = audioread('E:\8、matlab\回声变声处理\段坤我吃定了接取.wav'); Length = length(y); %% Signal lengthy_left = y(:,1); %% Left channel signaly_right = y(:,2); %% Right channel signal[c,lags]=xcorr(y_left,y_right);%% Cross-correlationsubplot(211); plot(lags/Fs,c,'r'); title('Correlation function'); xlabel('Time(s)');ylabel('Correlation between left and right channels'); grid on [Am,Lm]=max(c); d = Lm - (length(c)+1)/2; phy=(2*10*d*180/Fs); phy = rem(phy,360) %% remainder 360 Delay=d/Fs ``` #### The relevant results are as follows:
#### The phase difference and delay results of the left and right channels are calculated as follows:
## 3. Conclusion#### 1. The amplitude and frequency of the left and right channels are almost the same; #### 2. The phase difference and delay of the left and right channels are different;