Speech signal analysis and processing based on Matlab App Designer (3): App design

Continued from the above: https://blog.csdn.net/weixin_53877178/article/details/122475951

Table of contents

1. Tasks of the subject

2. Content, steps and requirements

(1) Acquisition of voice signals

(2) Analysis of speech signal

(3) Filtering of voice signals

(4) App design

1) Use of related components

2) Add your own global variables in the App

3) Error reporting and prompt function

Error reporting and prompt function code example

4) Exit function

exit function instance


1. Tasks of the subject

2. Content, steps and requirements

(1) Acquisition of voice signals

(2) Analysis of speech signal

(3) Filtering of voice signals

(4) App design

1) Use of related components

Just drag the component you want from the component library to the design view.

Double-click in the component browsing area on the right to modify the component name.

①Tags: Can be used to add titles, etc.

Double-click to edit the text content, and the inspector in the lower right corner can modify related properties (font size, color, alignment, etc.).

②Button: You can add a callback function, click to achieve the desired function.

Right-click to add a callback function to enter the code view for code design.

③Radio group button: It can realize multi-function selection, such as low-pass, high-pass, band-pass, and band-rejection.

Right-click to add the Filter_natureSelectionChanged callback function (Filter_nature is self-named), and the code view automatically generates function Filter_natureSelectionChanged(app, event) and selectedButton = app.Filter_nature.SelectedObject; Use the switch statement to realize the corresponding function of the corresponding option. In other callback functions, app.Filter_nature.SelectedObject can also be used to perform related operations (it can also be used without adding the Filter_natureSelectionChanged callback function).

④ Edit field (value): Realize the function of the input box, such as input the design index in the box to complete the design of the filter.

Double-click the prompt area to add a prompt. The format of the value is: FS = app.sample_frequency.Value; (app.sample_frequency is self-named), app.sample_frequency.Value is the same as above, and it is also a global variable.

⑤Spinner: Realize the adjustment function such as the volume of the music player.

The method of adding a callback function is the same as that of a button.

⑥Edit field (text): It can be used as input or output. Input and output are similar to "edit field (value)".

Output: add such as app.sample_frequency.Value = "Hanning window" in a callback function; 

⑦Coordinate area: Draw time-domain and frequency-domain waveforms, and even display pictures.

 Double-click the corresponding area to change the title, horizontal and vertical coordinates. Add such as plot(app.original_time,t,x); to a callback function to draw the waveform. app.original_time is the name of the axes.

2) Add your own global variables in the App

In the code browser on the left, select Properties, click the lower triangle next to ➕ to add private properties (global variables in this App).

 The code view will generate code accordingly, except that the internal content is an example, which can be deleted directly.

 Define the variable name as shown above. Use global variables in other functions, and write it like app.path to realize the assignment and application of global variables.

3) Error reporting and prompt function

Error:

f = errordlg(msg, title);

msg: the output content you want.

title: The title of the dialog.

hint:

msgbox(message)
%msgbox('显示内容')

msgbox(message,title)
%msgbox('显示内容','标题')

msgbox(message,title,icon)
%msgbox('显示内容','标题','系统图标')
%系统图标主要有none,error,help,warn

Error reporting and prompt function code example

[filename,pathname]=uigetfile({'*.wav;*.mp3','*.wav;*.mp3'},'选择声音文件');
if isequal([filename pathname],[0,0])
    errordlg("没有选中文件","错误")
else
    app.path = strcat(pathname, filename);%选择的声音文件路径
    msgbox("读取成功","提示")
end

This part of the code example also includes the acquisition of the file path.

4) Exit function

Add a button, right-click to add a callback function.

Use of questdlg:

answer = questdlg(quest);
answer = questdlg(quest,dlgtitle);
answer = questdlg(quest,dlgtitle,defbtn);
answer = questdlg(quest,dlgtitle,btn1,btn2,defbtn);

answer = questdlg(quest) ; Creates a modal dialog that asks a question and returns the user's answer - 'Yes', 'No', 'Cancel' or ''.

By default, the dialog has three standard buttons labeled Yes, No, and Cancel.

If the user clicks one of the buttons, the answer value is the same as the label of the pressed button.

If the user clicks the close button (X) on the dialog title bar or presses the Esc key, the value of answer is an empty character vector (' ').

If the user presses the Return key, the answer value is the same as the label of the default selected button.

answer = questdlg(quest,dlgtitle) ; Specifies the dialog title.

answer = questdlg(quest,dlgtitle,defbtn) ; Specifies which button is the default button when the user presses the Return key on the keyboard. The defbtn value must match one of the button labels.

answer = questdlg(quest,dlgtitle,btn1,btn2,defbtn) ; Customize two standard buttons by using the btn1 and btn2 values ​​as button labels. The third standard button is removed. The defbtn value must match the value of btn1 or btn2.

If the user presses the Return key on the keyboard, and the defbtn value does not match either button label, the dialog remains open.

exit function instance

choice = questdlg("是否退出《语音信号的处理》?","退出","是","否","否");
switch choice
    case "是"
        delete(app.UIFigure)
        return
    case "否"
        return
end

The final effect display:

Analysis and Processing of Speech Signal_哔哩哔哩_bilibili

Complete resource acquisition:

https://download.csdn.net/download/weixin_53877178/76116847

Guess you like

Origin blog.csdn.net/weixin_53877178/article/details/122486519