[Speech processing] based on matlab GUI voice time-domain frequency-domain spectrogram analysis [including Matlab source code 527]

1. Introduction

The time domain and frequency domain are the basic properties of the signal, so the signal can be analyzed in a variety of ways, each of which provides a different angle. The fastest way to solve the problem is not necessarily the most obvious way. The different angles used to analyze the signal are called domains. The time domain and frequency domain can clearly reflect the mutual influence between the signal and the interconnection line.
1 Time domain The
time domain is the real world and the only domain that actually exists. Because our experience is developed and verified in the time domain, we have become accustomed to events happening in chronological order. When evaluating the performance of digital products, analysis is usually performed in the time domain, because the performance of the product is ultimately measured in the time domain.

The two important parameters of the clock waveform are the clock period and rise time.
Insert picture description here
The clock cycle and 10-90 rise time of the 1GHz clock signal are indicated in the figure. The fall time is generally shorter than the rise time, and sometimes more noise occurs.

The clock period is the time interval at which the clock cycle repeats once, usually measured in ns. The clock frequency Fclock, that is, the number of clock cycles in 1 second, is the reciprocal of the clock period Tclock.

Fclock=1/Tclock

The rise time is related to the time it takes for a signal to transition from a low level to a high level, and there are usually two definitions. One is the 10-90 rise time, which refers to the time it takes for the signal to jump from 10% of the final value to 90%. This is usually a default expression and can be read directly from the time-domain diagram of the waveform. The second definition method is 20-80 rise time, which refers to the time it takes to jump from 20% of the final value to 80%.

The fall time of the time domain waveform also has a corresponding value. According to the logic series, the fall time is usually shorter than the rise time, which is caused by the design of a typical CMOS output driver. In a typical output driver, the p tube and the n tube are connected in series between the power rails Vcc and Vss, and the output is connected in the middle of the two tubes. At any time, only one transistor is turned on, so which tube is turned on depends on the high or low state of the output.

2 Frequency domain The
frequency domain, especially in radio frequency and communication systems, is often used, and it will also encounter the frequency domain in high-speed digital applications. The most important property of the frequency domain is: it is not real, but a mathematical construction. The time domain is the only domain that exists objectively, while the frequency domain is a mathematical category that follows specific rules. The frequency domain is also called the perspective of God by some scholars.

The sine wave is the only waveform that exists in the frequency domain. This is the most important rule in the frequency domain, that is, the sine wave is a description of the frequency domain, because any waveform in the frequency domain can be synthesized with a sine wave. This is a very important property of sine waves. However, it is not a unique characteristic of sine waves, and there are many other waveforms that also have this characteristic. The sine wave has four properties that make it effective to describe any other waveform:

(1) Any waveform in the frequency domain can be completely and uniquely described by a combination of sine waves.

(2) Any two sine waves with different frequencies are orthogonal. If two sine waves are multiplied and integrated over the entire time axis, the integrated value is zero. This shows that different frequency components can be separated from each other.

(3) Sine wave has precise mathematical definition.

(4) Sine waves and their differential values ​​exist everywhere, without upper and lower boundaries.

The use of a sine wave as a function in the frequency domain has its special place. If a sine wave is used, some problems related to the electrical effects of interconnecting lines will become easier to understand and solve. If you transform to the frequency domain and describe it with a sine wave, you can sometimes get the answer faster than just in the time domain.

In practice, first build a circuit including resistance, inductance and capacitance, and input arbitrary waveforms. Under normal circumstances, you will get a waveform similar to a sine wave. Moreover, the combination of several sine waves can easily describe these waveforms, as shown in Figure 2.2 below:
Insert picture description here
Figure 2.2 Time-domain behavior of the ideal RLC circuit interaction

3 The relationship between
time domain and frequency domain Time domain analysis and frequency domain analysis are two observation planes of analog signals. Time domain analysis uses the time axis as the coordinate to express the relationship of the dynamic signal; frequency domain analysis changes the signal to the frequency axis as the coordinate to express. Generally speaking, the time domain representation is more vivid and intuitive, while the frequency domain analysis is more concise, and the analysis of problems is more profound and convenient. The trend of signal analysis is to develop from the time domain to the frequency domain. However, they are interrelated, one is indispensable, and they complement each other.
4 Conversion of time domain and frequency domain The
dynamic signal is transformed from time domain to frequency domain mainly through Fourier series and Fourier transform. Periodic signals rely on Fourier series, and non-periodic signals rely on Fourier transform. The wider the time domain, the shorter the frequency domain.

s(f) = ∫-∞ +∞ (s(t)·e)dt

sD(t)= dS(t)/dt

sD(f)= ∫-∞ (sD(t)·e-j2∏ft)dt=j·2∏f· s(f)

Second, the source code

function varargout = gui(varargin)
% GUI MATLAB code for gui.fig
%      GUI, by itself, creates a new GUI or raises the existing
%      singleton*.
%
%      H = GUI returns the handle to a new GUI or the handle to
%      the existing singleton*.
%
%      GUI('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GUI.M with the given input arguments.
%
%      GUI('Property','Value',...) creates a new GUI or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before gui_OpeningFcn gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to gui_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help gui

% Last Modified by GUIDE v2.5 23-Apr-2019 15:32:28

% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',       mfilename, ...
                   'gui_Singleton',  gui_Singleton, ...
                   'gui_OpeningFcn', @gui_OpeningFcn, ...
                   'gui_OutputFcn',  @gui_OutputFcn, ...
                   'gui_LayoutFcn',  [] , ...
                   'gui_Callback',   []);
if nargin && ischar(varargin{
    
    1})
    gui_State.gui_Callback = str2func(varargin{
    
    1});
end

if nargout
    [varargout{
    
    1:nargout}] = gui_mainfcn(gui_State, varargin{
    
    :});
else
    gui_mainfcn(gui_State, varargin{
    
    :});
end
% End initialization code - DO NOT EDIT


% --- Executes just before gui is made visible.
function gui_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin   command line arguments to gui (see VARARGIN)

% Choose default command line output for gui
handles.output = hObject;

% Update handles structure
guidata(hObject, handles);

% UIWAIT makes gui wait for user response (see UIRESUME)
% uiwait(handles.figure1);


% --- Outputs from this function are returned to the command line.
function varargout = gui_OutputFcn(hObject, eventdata, handles) 
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure
varargout{
    
    1} = handles.output;


% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBits
global mag idx_last recObj myRecording bit




record(recObj,RecordLength);
tic
while toc<.1
end
bit = 2;
while toc<RecordLength
    myRecording = getaudiodata(recObj);
    idx = round(toc*fs);
    while idx-idx_last<.1*fs
       idx=round(toc*fs);
    end
   axes(handles.axes1)
   plot((max(1,size(myRecording,1)-fs*ShowLength):(2^bit):size(myRecording,1))./fs,myRecording(max(1,size(myRecording,1)-fs*ShowLength):(2^bit):end))
   mag = max(abs(myRecording));
   ylim([-1.2 1.2]*mag)
   xlim([max(0,size(myRecording,1)/fs-ShowLength)
   max(size(myRecording,1)/fs,ShowLength)])
   title('声音信号的波形显示');
   ylabel('Signal level(volts)');
   xlabel('Samples');
   drawnow
   idx_last = idx;
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBits
global mag idx_last recObj myRecording
save data.mat aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBits mag idx_last recObj myRecording 

% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton4.
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
clc,clear,
close all force;

% --- Executes on button press in pushbutton5.
function pushbutton5_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBits
global mag idx_last recObj
aud = audiodevinfo;
RecordLength = 15;
ShowLength = 15;
FrequencyWindow1 = 0;
FrequencyWindow2 = 3000;
fs = 44100;
nBits = 16;
mag = 1.05;
idx_last = 1;
 recObj = audiorecorder(fs,nBits,1);
 if isempty(recObj);
     
 else
     msgbox('语音设备已检测到!!!');
 end

% --- Executes on button press in pushbutton6.
function pushbutton6_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)


% --- Executes on button press in pushbutton7.
function pushbutton7_Callback(hObject, eventdata, handles)
% hObject    handle to pushbutton7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global fs
load('data.mat')
sound(myRecording,fs);


% --------------------------------------------------------------------
function Untitled_1_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
global aud RecordLength ShowLength FrequencyWindow1 FrequencyWindow2 fs nBits
global mag idx_last recObj myRecording bit x3
x1 = myRecording(max(1,size(myRecording,1)-fs*ShowLength):(2^bit):end);
N=length(x1);
x2 = x1-mean(x1);
x3 = smooth(x2);
axes(handles.axes1)
plot(x3,'b-','linewidth',2)
axis tight
title('零均值化——平滑滤波')

% --------------------------------------------------------------------
function Untitled_2_Callback(hObject, eventdata, handles)
% hObject    handle to Untitled_2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)

Three, running results

Insert picture description here
Insert picture description here

Four, remarks

Complete code or writing add QQ 1564658423 past review
>>>>>>
[Feature extraction] Audio watermark embedding and extraction based on matlab wavelet transform [Include Matlab source code 053]
[Speech processing] Voice signal processing based on matlab GUI [Include Matlab Source code issue 290]
[Voice acquisition] based on matlab GUI voice signal collection [including Matlab source code 291]
[Voice modulation] based on matlab GUI voice amplitude modulation [including Matlab source code 292]
[Speech synthesis] based on matlab GUI voice synthesis [including Matlab Source code issue 293]
[Voice encryption] Voice signal encryption and decryption based on matlab GUI [With Matlab source code 295]
[Speech enhancement] Matlab wavelet transform-based voice enhancement [Matlab source code 296]
[Voice recognition] Based on matlab GUI voice base frequency Recognition [Including Matlab source code 294]
[Speech enhancement] Matlab GUI Wiener filtering based voice enhancement [Including Matlab source code 298]
[Speech processing] Based on matlab GUI voice signal processing [Including Matlab source code 299]
[Signal processing] Based on Matlab speech signal spectrum analyzer [including Matlab source code 325]
[Modulation signal] Digital modulation signal simulation based on matlab GUI [including Matlab source code 336]
[Emotion recognition] Voice emotion recognition based on matlab BP neural network [including Matlab source code 349 Issue]
[Voice Steganography] Quantified Audio Digital Watermarking Based on Matlab Wavelet Transform [Include Matlab Source Code Issue 351]
[Feature extraction] based on matlab audio watermark embedding and extraction [including Matlab source code 350 period]
[speech denoising] based on matlab low pass and adaptive filter denoising [including Matlab source code 352 period]
[emotion recognition] based on matlab GUI voice emotion classification Recognition [Including Matlab source code 354 period]
[Basic processing] Matlab-based speech signal preprocessing [Including Matlab source code 364 period]
[Speech recognition] Matlab Fourier transform 0-9 digital speech recognition [Including Matlab source code 384 period]
[Speech Recognition] 0-9 digital speech recognition based on matlab GUI DTW [including Matlab source code 385]
[Voice playback] Matlab GUI MP3 design [including Matlab source code 425]
[Voice processing] Speech enhancement algorithm based on human ear masking effect Noise ratio calculation [Including Matlab source code 428]
[Speech denoising] Based on matlab spectral subtraction denoising [Including Matlab source code 429]
[Speech recognition] BP neural network speech recognition based on the momentum item of matlab [Including Matlab source code 430]
[Voice steganography] based on matlab LSB voice hiding [including Matlab source code 431]
[Voice recognition] based on matlab male and female voice recognition [including Matlab source code 452]
[Voice processing] based on matlab voice noise adding and noise reduction processing [including Matlab source code Issue 473]
[Speech denoising] based on matlab least squares (LMS) adaptive filter [including Matlab source code 481]
[Speech enhancement] based on matlab spectral subtraction, least mean square and Wiener filter speech enhancement [including Matlab source code 482 period】
[Communication] based on matlab GUI digital frequency band (ASK, PSK, QAM) modulation simulation [including Matlab source code 483]
[Signal processing] based on matlab ECG signal processing [including Matlab source code 484]
[Voice broadcast] based on matlab voice Broadcast [Including Matlab source code 507]
[Signal processing] Based on matlab wavelet transform EEG signal feature extraction [Including Matlab source code 511]
[Voice processing] Based on matlab GUI dual-tone multi-frequency (DTMF) signal detection [Including Matlab source code 512 ]
[] voice matlab the LSB steganographic digital watermark containing speech signal [513] based on Matlab source code
[] speech enhancement based on speech recognition matlab matched filter containing Matlab source [514]

Guess you like

Origin blog.csdn.net/TIQCmatlab/article/details/114870522