How to deal with audio signal by Matlab
This article mainly introduces how Matlab processes audio signals, which has certain reference value. Interested friends can refer to it. I hope you will gain a lot after reading this article. Let Xiaobian take you to understand it together.
Basic Processing and Analysis of Matlab Audio Signal
1 Audio signal reading and time domain analysis
close allclear allclc % read audio file info =audioinfo ('sample_origin.mp3');% Get information about audio files [audio,Fs] = audioread ('sample_origin.mp3');% read audio file sound (audio,Fs);% Play audio file audiolength = length(audio);% Get data length of audio file t = 1:1:audiolength; figure(1),plot (t,audio(1:audiolength));xlabel ('Time ');ylabel ('Audio Signal');title ('Original Audio File Signal Amplitude Map');
The details of this audio include data bit width, sampling rate, etc.
2 Frequency domain analysis of audio
% Audio frequency domain y =fft(audio);y=20*log(abs(y))/log(10); % converted to dBW unit f=[0:(Fs/audiolength):Fs/2]; y=y(1:length(f)); figure(2),plot(f,y);xlabel ('frequency (Hz)',' fontsize', 8,'position',[180,-34.38,0]);ylabel ('power (dBW)');title ('original audio file signal spectrogram ');legend ('Audio');
This shows that the main frequency of this audio is concentrated in the low frequency band.
3 Superposition and writing of audio
% superposition of audio signals [audio1,Fs1] = audioread ('test.wav ');% reading audio files audio2 = audio1 (1: audio length); audio3 = audio2 +0.1*audio;sound(audio3,Fs);% playing audio files audiowrite ('test1.wav', audio3,Fs)% writing new audio files
4 Splicing of audio signals
% splice audio4 = [audio;audio1];sound(audio4,Fs);% play audio file audiowrite ('test2.wav', audio3,Fs)% write new audio file
Thank you for reading this article carefully. I hope that the article "How does Matlab process audio signals" shared by Xiaobian will help everyone. At the same time, I hope that everyone will support you a lot and pay attention to the industry information channel. More relevant knowledge is waiting for you to learn!