classdef GOOD < matlab.apps.AppBase
% Properties that correspond to app components
properties (Access = public)
UIFigure matlab.ui.Figure
GridLayout matlab.ui.container.GridLayout
LeftPanel matlab.ui.container.Panel
PLAYButton matlab.ui.control.Button
STOPButton matlab.ui.control.Button
RightPanel matlab.ui.container.Panel
frequencySliderLabel matlab.ui.control.Label
frequencySlider matlab.ui.control.Slider
UIAxes matlab.ui.control.UIAxes
Label_5 matlab.ui.control.Label
Label matlab.ui.control.Label
Label_2 matlab.ui.control.Label
Label_3 matlab.ui.control.Label
Label_4 matlab.ui.control.Label
volumeSliderLabel matlab.ui.control.Label
volumeSlider matlab.ui.control.Slider
UIAxes2 matlab.ui.control.UIAxes
end
% Properties that correspond to apps with auto-reflow
properties (Access = private)
onePanelWidth = 576;
end
% Callbacks that handle component events
methods (Access = private)
% Button pushed function: PLAYButton
function PLAYButtonPushed(app, event)
global fs;
global gg;
y=audioread("good3.mp3");
y=gg*y;
sound(y,fs);
plot(app.UIAxes,y);
plot(app.UIAxes2,abs(fft(y)));
end
% Button pushed function: STOPButton
function STOPButtonPushed(app, event)
clear sound;
cla(app.UIAxes);
cla(app.UIAxes2);
end
% Callback function
function X15ButtonPushed(app, event)
end
% Value changed function: frequencySlider
function frequencySliderValueChanged(app, event)
global fs;
fs = app.frequencySlider.Value;
end
% Value changing function: frequencySlider
function frequencySliderValueChanging(app, event)
changingValue = event.Value;
end
% Value changed function: volumeSlider
function volumeSliderValueChanged(app, event)
global gg;
gg = app.volumeSlider.Value;
end
% Changes arrangement of the app based on UIFigure width
function updateAppLayout(app, event)
currentFigureWidth = app.UIFigure.Position(3);
if(currentFigureWidth <= app.onePanelWidth)
% Change to a 2x1 grid
app.GridLayout.RowHeight = {480, 480};
app.GridLayout.ColumnWidth = {'1x'};
app.RightPanel.Layout.Row = 2;
app.RightPanel.Layout.Column = 1;
else
% Change to a 1x2 grid
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnWidth = {112, '1x'};
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
end
end
end
% Component initialization
methods (Access = private)
% Create UIFigure and components
function createComponents(app)
% Create UIFigure and hide until all components are created
app.UIFigure = uifigure('Visible', 'off');
app.UIFigure.AutoResizeChildren = 'off';
app.UIFigure.Position = [100 100 640 480];
app.UIFigure.Name = 'UI Figure';
app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);
% Create GridLayout
app.GridLayout = uigridlayout(app.UIFigure);
app.GridLayout.ColumnWidth = {112, '1x'};
app.GridLayout.RowHeight = {'1x'};
app.GridLayout.ColumnSpacing = 0;
app.GridLayout.RowSpacing = 0;
app.GridLayout.Padding = [0 0 0 0];
app.GridLayout.Scrollable = 'on';
% Create LeftPanel
app.LeftPanel = uipanel(app.GridLayout);
app.LeftPanel.Layout.Row = 1;
app.LeftPanel.Layout.Column = 1;
% Create PLAYButton
app.PLAYButton = uibutton(app.LeftPanel, 'push');
app.PLAYButton.ButtonPushedFcn = createCallbackFcn(app, @PLAYButtonPushed, true);
app.PLAYButton.Position = [6 332 100 61];
app.PLAYButton.Text = 'PLAY';
% Create STOPButton
app.STOPButton = uibutton(app.LeftPanel, 'push');
app.STOPButton.ButtonPushedFcn = createCallbackFcn(app, @STOPButtonPushed, true);
app.STOPButton.Position = [7 268 100 65];
app.STOPButton.Text = 'STOP';
% Create RightPanel
app.RightPanel = uipanel(app.GridLayout);
app.RightPanel.Layout.Row = 1;
app.RightPanel.Layout.Column = 2;
% Create frequencySliderLabel
app.frequencySliderLabel = uilabel(app.RightPanel);
app.frequencySliderLabel.HorizontalAlignment = 'right';
app.frequencySliderLabel.Position = [9 441 58 22];
app.frequencySliderLabel.Text = 'frequency';
% Create frequencySlider
app.frequencySlider = uislider(app.RightPanel);
app.frequencySlider.Limits = [44100 88200];
app.frequencySlider.MajorTicks = [1 2 3 4 5];
app.frequencySlider.MajorTickLabels = {'1', '2', '3', '4', '5'};
app.frequencySlider.ValueChangedFcn = createCallbackFcn(app, @frequencySliderValueChanged, true);
app.frequencySlider.ValueChangingFcn = createCallbackFcn(app, @frequencySliderValueChanging, true);
app.frequencySlider.MinorTicks = [44100 55125 66150 77175 88200];
app.frequencySlider.Position = [79 451 177 3];
app.frequencySlider.Value = 44100;
% Create UIAxes
app.UIAxes = uiaxes(app.RightPanel);
title(app.UIAxes, {'1'; ''; ''})
xlabel(app.UIAxes, 'X')
ylabel(app.UIAxes, 'Y')
app.UIAxes.Position = [25 214 429 196];
% Create Label_5
app.Label_5 = uilabel(app.RightPanel);
app.Label_5.Position = [66 418 25 22];
app.Label_5.Text = ' 1';
% Create Label
app.Label = uilabel(app.RightPanel);
app.Label.Position = [106 418 35 22];
app.Label.Text = ' 1.25';
% Create Label_2
app.Label_2 = uilabel(app.RightPanel);
app.Label_2.Position = [154 418 28 22];
app.Label_2.Text = ' 1.5';
% Create Label_3
app.Label_3 = uilabel(app.RightPanel);
app.Label_3.Position = [197 418 29 22];
app.Label_3.Text = '1.75';
% Create Label_4
app.Label_4 = uilabel(app.RightPanel);
app.Label_4.Position = [238 418 27 22];
app.Label_4.Text = ' 2';
% Create volumeSliderLabel
app.volumeSliderLabel = uilabel(app.RightPanel);
app.volumeSliderLabel.HorizontalAlignment = 'right';
app.volumeSliderLabel.Position = [265 441 45 22];
app.volumeSliderLabel.Text = 'volume';
% Create volumeSlider
app.volumeSlider = uislider(app.RightPanel);
app.volumeSlider.Limits = [0 1];
app.volumeSlider.MajorTicks = [0.2 0.4 0.6 0.8 1];
app.volumeSlider.ValueChangedFcn = createCallbackFcn(app, @volumeSliderValueChanged, true);
app.volumeSlider.MinorTicks = [];
app.volumeSlider.Position = [331 450 150 3];
% Create UIAxes2
app.UIAxes2 = uiaxes(app.RightPanel);
title(app.UIAxes2, {'Fourier'; ''})
xlabel(app.UIAxes2, 'X')
ylabel(app.UIAxes2, 'Y')
app.UIAxes2.Position = [32 10 422 185];
% Show the figure after all components are created
app.UIFigure.Visible = 'on';
end
end
% App creation and deletion
methods (Access = public)
% Construct app
function app = GOOD
% Create UIFigure and components
createComponents(app)
% Register the app with App Designer
registerApp(app, app.UIFigure)
if nargout == 0
clear app
end
end
% Code that executes before app deletion
function delete(app)
% Delete UIFigure when app is deleted
delete(app.UIFigure)
end
end
end
1倍速
1.25倍速 聲音0.5
1.6倍速 聲音0.7
2倍速 聲音0.8