classdef app < 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
        ListBox                 matlab.ui.control.ListBox
        ListBoxLabel            matlab.ui.control.Label
        CeilingSpinner          matlab.ui.control.Spinner
        CeilingSpinnerLabel     matlab.ui.control.Label
        FloorSpinner            matlab.ui.control.Spinner
        FloorSpinnerLabel       matlab.ui.control.Label
        BandPassFilterLabel     matlab.ui.control.Label
        RelSlider               matlab.ui.control.Slider
        RelSliderLabel          matlab.ui.control.Label
        AmplitudeEnvelopeLabel  matlab.ui.control.Label
        SusSlider               matlab.ui.control.Slider
        SusSliderLabel          matlab.ui.control.Label
        DecaySlider             matlab.ui.control.Slider
        DecaySliderLabel        matlab.ui.control.Label
        AttackSlider            matlab.ui.control.Slider
        AttackSliderLabel       matlab.ui.control.Label
        CenterPanel             matlab.ui.container.Panel
        RecordButton            matlab.ui.control.Button
        PauseButton             matlab.ui.control.Button
        PlayButton              matlab.ui.control.Button
        UIAxes_4                matlab.ui.control.UIAxes
        UIAxes_3                matlab.ui.control.UIAxes
        UIAxes_2                matlab.ui.control.UIAxes
        UIAxes2                 matlab.ui.control.UIAxes
        UIAxes                  matlab.ui.control.UIAxes
        RightPanel              matlab.ui.container.Panel
        RelSlider_2             matlab.ui.control.Slider
        RelSlider_2Label        matlab.ui.control.Label
        SusSlider_2             matlab.ui.control.Slider
        SusSlider_2Label        matlab.ui.control.Label
        DecaySlider_2           matlab.ui.control.Slider
        DecaySlider_2Label      matlab.ui.control.Label
        AttackSlider_2          matlab.ui.control.Slider
        AttackSlider_2Label     matlab.ui.control.Label
        PitchEnvelopeLabel      matlab.ui.control.Label
        ModulationLabel         matlab.ui.control.Label
        LFOLabel                matlab.ui.control.Label
        OscFreqSpinner          matlab.ui.control.Spinner
        OscFreqSpinnerLabel     matlab.ui.control.Label
    end

    % Properties that correspond to apps with auto-reflow
    properties (Access = private)
        onePanelWidth = 576;
        twoPanelWidth = 768;
    end

    
    methods (Access = public)
        
        function results = func(app)
            
        end
    end
    

    % Callbacks that handle component events
    methods (Access = private)

        % Value changed function: ListBox
        function ListBoxValueChanged(app, event)
            value = app.ListBox.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 3x1 grid
                app.GridLayout.RowHeight = {480, 480, 480};
                app.GridLayout.ColumnWidth = {'1x'};
                app.CenterPanel.Layout.Row = 1;
                app.CenterPanel.Layout.Column = 1;
                app.LeftPanel.Layout.Row = 2;
                app.LeftPanel.Layout.Column = 1;
                app.RightPanel.Layout.Row = 3;
                app.RightPanel.Layout.Column = 1;
            elseif (currentFigureWidth > app.onePanelWidth && currentFigureWidth <= app.twoPanelWidth)
                % Change to a 2x2 grid
                app.GridLayout.RowHeight = {480, 480};
                app.GridLayout.ColumnWidth = {'1x', '1x'};
                app.CenterPanel.Layout.Row = 1;
                app.CenterPanel.Layout.Column = [1,2];
                app.LeftPanel.Layout.Row = 2;
                app.LeftPanel.Layout.Column = 1;
                app.RightPanel.Layout.Row = 2;
                app.RightPanel.Layout.Column = 2;
            else
                % Change to a 1x3 grid
                app.GridLayout.RowHeight = {'1x'};
                app.GridLayout.ColumnWidth = {220, '1x', 220};
                app.LeftPanel.Layout.Row = 1;
                app.LeftPanel.Layout.Column = 1;
                app.CenterPanel.Layout.Row = 1;
                app.CenterPanel.Layout.Column = 2;
                app.RightPanel.Layout.Row = 1;
                app.RightPanel.Layout.Column = 3;
            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 860 480];
            app.UIFigure.Name = 'MATLAB App';
            app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);

            % Create GridLayout
            app.GridLayout = uigridlayout(app.UIFigure);
            app.GridLayout.ColumnWidth = {220, '1x', 220};
            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 AttackSliderLabel
            app.AttackSliderLabel = uilabel(app.LeftPanel);
            app.AttackSliderLabel.HorizontalAlignment = 'right';
            app.AttackSliderLabel.Position = [2 429 40 22];
            app.AttackSliderLabel.Text = 'Attack';

            % Create AttackSlider
            app.AttackSlider = uislider(app.LeftPanel);
            app.AttackSlider.Limits = [0 1];
            app.AttackSlider.Position = [63 438 135 3];

            % Create DecaySliderLabel
            app.DecaySliderLabel = uilabel(app.LeftPanel);
            app.DecaySliderLabel.HorizontalAlignment = 'right';
            app.DecaySliderLabel.Position = [3 387 39 22];
            app.DecaySliderLabel.Text = 'Decay';

            % Create DecaySlider
            app.DecaySlider = uislider(app.LeftPanel);
            app.DecaySlider.Limits = [0 1];
            app.DecaySlider.Position = [63 396 135 3];

            % Create SusSliderLabel
            app.SusSliderLabel = uilabel(app.LeftPanel);
            app.SusSliderLabel.HorizontalAlignment = 'right';
            app.SusSliderLabel.Position = [16 345 26 22];
            app.SusSliderLabel.Text = 'Sus';

            % Create SusSlider
            app.SusSlider = uislider(app.LeftPanel);
            app.SusSlider.Position = [63 354 135 3];

            % Create AmplitudeEnvelopeLabel
            app.AmplitudeEnvelopeLabel = uilabel(app.LeftPanel);
            app.AmplitudeEnvelopeLabel.FontWeight = 'bold';
            app.AmplitudeEnvelopeLabel.Position = [8 450 120 22];
            app.AmplitudeEnvelopeLabel.Text = 'Amplitude Envelope';

            % Create RelSliderLabel
            app.RelSliderLabel = uilabel(app.LeftPanel);
            app.RelSliderLabel.HorizontalAlignment = 'right';
            app.RelSliderLabel.Position = [17 304 25 22];
            app.RelSliderLabel.Text = 'Rel';

            % Create RelSlider
            app.RelSlider = uislider(app.LeftPanel);
            app.RelSlider.Limits = [0 1];
            app.RelSlider.Position = [63 313 135 3];

            % Create BandPassFilterLabel
            app.BandPassFilterLabel = uilabel(app.LeftPanel);
            app.BandPassFilterLabel.FontWeight = 'bold';
            app.BandPassFilterLabel.Position = [8 257 100 22];
            app.BandPassFilterLabel.Text = 'Band-Pass Filter';

            % Create FloorSpinnerLabel
            app.FloorSpinnerLabel = uilabel(app.LeftPanel);
            app.FloorSpinnerLabel.HorizontalAlignment = 'right';
            app.FloorSpinnerLabel.Position = [34 232 33 22];
            app.FloorSpinnerLabel.Text = 'Floor';

            % Create FloorSpinner
            app.FloorSpinner = uispinner(app.LeftPanel);
            app.FloorSpinner.Position = [82 232 100 22];

            % Create CeilingSpinnerLabel
            app.CeilingSpinnerLabel = uilabel(app.LeftPanel);
            app.CeilingSpinnerLabel.HorizontalAlignment = 'right';
            app.CeilingSpinnerLabel.Position = [25 211 42 22];
            app.CeilingSpinnerLabel.Text = 'Ceiling';

            % Create CeilingSpinner
            app.CeilingSpinner = uispinner(app.LeftPanel);
            app.CeilingSpinner.Position = [82 211 100 22];

            % Create ListBoxLabel
            app.ListBoxLabel = uilabel(app.LeftPanel);
            app.ListBoxLabel.HorizontalAlignment = 'right';
            app.ListBoxLabel.Position = [22 131 49 22];
            app.ListBoxLabel.Text = 'List Box';

            % Create ListBox
            app.ListBox = uilistbox(app.LeftPanel);
            app.ListBox.ValueChangedFcn = createCallbackFcn(app, @ListBoxValueChanged, true);
            app.ListBox.Position = [86 81 100 74];

            % Create CenterPanel
            app.CenterPanel = uipanel(app.GridLayout);
            app.CenterPanel.Layout.Row = 1;
            app.CenterPanel.Layout.Column = 2;

            % Create UIAxes
            app.UIAxes = uiaxes(app.CenterPanel);
            title(app.UIAxes, 'Time Domain')
            xlabel(app.UIAxes, 'X')
            ylabel(app.UIAxes, 'Y')
            zlabel(app.UIAxes, 'Z')
            app.UIAxes.Position = [203 296 211 176];

            % Create UIAxes2
            app.UIAxes2 = uiaxes(app.CenterPanel);
            title(app.UIAxes2, 'Frequency Domain')
            xlabel(app.UIAxes2, 'X')
            ylabel(app.UIAxes2, 'Y')
            zlabel(app.UIAxes2, 'Z')
            app.UIAxes2.Position = [203 58 211 239];

            % Create UIAxes_2
            app.UIAxes_2 = uiaxes(app.CenterPanel);
            title(app.UIAxes_2, 'Amplitude Envelope')
            xlabel(app.UIAxes_2, 'X')
            ylabel(app.UIAxes_2, 'Y')
            zlabel(app.UIAxes_2, 'Z')
            app.UIAxes_2.Position = [6 324 189 148];

            % Create UIAxes_3
            app.UIAxes_3 = uiaxes(app.CenterPanel);
            title(app.UIAxes_3, 'Filter')
            xlabel(app.UIAxes_3, 'X')
            ylabel(app.UIAxes_3, 'Y')
            zlabel(app.UIAxes_3, 'Z')
            app.UIAxes_3.Position = [6 195 189 119];

            % Create UIAxes_4
            app.UIAxes_4 = uiaxes(app.CenterPanel);
            title(app.UIAxes_4, 'Pitch Envelope')
            xlabel(app.UIAxes_4, 'X')
            ylabel(app.UIAxes_4, 'Y')
            zlabel(app.UIAxes_4, 'Z')
            app.UIAxes_4.Position = [6 58 189 138];

            % Create PlayButton
            app.PlayButton = uibutton(app.CenterPanel, 'push');
            app.PlayButton.Position = [51 21 100 22];
            app.PlayButton.Text = 'Play';

            % Create PauseButton
            app.PauseButton = uibutton(app.CenterPanel, 'push');
            app.PauseButton.Position = [175 21 100 22];
            app.PauseButton.Text = 'Pause';

            % Create RecordButton
            app.RecordButton = uibutton(app.CenterPanel, 'push');
            app.RecordButton.Position = [305 21 100 22];
            app.RecordButton.Text = 'Record';

            % Create RightPanel
            app.RightPanel = uipanel(app.GridLayout);
            app.RightPanel.Layout.Row = 1;
            app.RightPanel.Layout.Column = 3;

            % Create OscFreqSpinnerLabel
            app.OscFreqSpinnerLabel = uilabel(app.RightPanel);
            app.OscFreqSpinnerLabel.HorizontalAlignment = 'right';
            app.OscFreqSpinnerLabel.Position = [25 408 55 22];
            app.OscFreqSpinnerLabel.Text = 'Osc Freq';

            % Create OscFreqSpinner
            app.OscFreqSpinner = uispinner(app.RightPanel);
            app.OscFreqSpinner.Position = [95 408 100 22];

            % Create LFOLabel
            app.LFOLabel = uilabel(app.RightPanel);
            app.LFOLabel.FontWeight = 'bold';
            app.LFOLabel.Position = [10 429 29 22];
            app.LFOLabel.Text = 'LFO';

            % Create ModulationLabel
            app.ModulationLabel = uilabel(app.RightPanel);
            app.ModulationLabel.FontSize = 14;
            app.ModulationLabel.FontWeight = 'bold';
            app.ModulationLabel.Position = [69 450 81 22];
            app.ModulationLabel.Text = 'Modulation';

            % Create PitchEnvelopeLabel
            app.PitchEnvelopeLabel = uilabel(app.RightPanel);
            app.PitchEnvelopeLabel.FontWeight = 'bold';
            app.PitchEnvelopeLabel.Position = [7 378 91 22];
            app.PitchEnvelopeLabel.Text = 'Pitch Envelope';

            % Create AttackSlider_2Label
            app.AttackSlider_2Label = uilabel(app.RightPanel);
            app.AttackSlider_2Label.HorizontalAlignment = 'right';
            app.AttackSlider_2Label.Position = [1 357 40 22];
            app.AttackSlider_2Label.Text = 'Attack';

            % Create AttackSlider_2
            app.AttackSlider_2 = uislider(app.RightPanel);
            app.AttackSlider_2.Limits = [0 1];
            app.AttackSlider_2.Position = [62 366 135 3];

            % Create DecaySlider_2Label
            app.DecaySlider_2Label = uilabel(app.RightPanel);
            app.DecaySlider_2Label.HorizontalAlignment = 'right';
            app.DecaySlider_2Label.Position = [2 315 39 22];
            app.DecaySlider_2Label.Text = 'Decay';

            % Create DecaySlider_2
            app.DecaySlider_2 = uislider(app.RightPanel);
            app.DecaySlider_2.Limits = [0 1];
            app.DecaySlider_2.Position = [62 324 135 3];

            % Create SusSlider_2Label
            app.SusSlider_2Label = uilabel(app.RightPanel);
            app.SusSlider_2Label.HorizontalAlignment = 'right';
            app.SusSlider_2Label.Position = [15 273 26 22];
            app.SusSlider_2Label.Text = 'Sus';

            % Create SusSlider_2
            app.SusSlider_2 = uislider(app.RightPanel);
            app.SusSlider_2.Position = [62 282 135 3];

            % Create RelSlider_2Label
            app.RelSlider_2Label = uilabel(app.RightPanel);
            app.RelSlider_2Label.HorizontalAlignment = 'right';
            app.RelSlider_2Label.Position = [16 232 25 22];
            app.RelSlider_2Label.Text = 'Rel';

            % Create RelSlider_2
            app.RelSlider_2 = uislider(app.RightPanel);
            app.RelSlider_2.Limits = [0 1];
            app.RelSlider_2.Position = [62 241 135 3];

            % 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 = app

            % 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