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
        FileLocationEditField          matlab.ui.control.EditField
        FileLocationEditFieldLabel     matlab.ui.control.Label
        StartButton                    matlab.ui.control.Button
        DurationSpinner                matlab.ui.control.Spinner
        DurationSpinnerLabel           matlab.ui.control.Label
        SamplingFsSpinner              matlab.ui.control.Spinner
        SamplingFsSpinnerLabel         matlab.ui.control.Label
        RecordingLamp                  matlab.ui.control.Lamp
        RecordingLampLabel             matlab.ui.control.Label
        MIDILabel                      matlab.ui.control.Label
        SoundButtonGroup               matlab.ui.container.ButtonGroup
        MIDIButton                     matlab.ui.control.RadioButton
        SoundGeneratorButton           matlab.ui.control.RadioButton
        SoundByteButton                matlab.ui.control.RadioButton
        SoundByteFileLabel             matlab.ui.control.Label
        SoundGeneratorsLabel           matlab.ui.control.Label
        FrequencyFiltersLabel          matlab.ui.control.Label
        SRClocationEditField           matlab.ui.control.EditField
        SRClocationEditFieldLabel      matlab.ui.control.Label
        DutySpinner_2                  matlab.ui.control.Spinner
        DutySpinner_2Label             matlab.ui.control.Label
        PhaseSpinner_2                 matlab.ui.control.Spinner
        PhaseSpinner_2Label            matlab.ui.control.Label
        FrequencySpinner_2             matlab.ui.control.Spinner
        FrequencySpinner_2Label        matlab.ui.control.Label
        AmplitudeSpinner_2             matlab.ui.control.Spinner
        AmplitudeSpinner_2Label        matlab.ui.control.Label
        DutySpinner                    matlab.ui.control.Spinner
        DutySpinnerLabel               matlab.ui.control.Label
        PhaseSpinner                   matlab.ui.control.Spinner
        PhaseSpinnerLabel              matlab.ui.control.Label
        FrequencySpinner               matlab.ui.control.Spinner
        FrequencySpinnerLabel          matlab.ui.control.Label
        AmplitudeSpinner               matlab.ui.control.Spinner
        AmplitudeSpinnerLabel          matlab.ui.control.Label
        BSpinner                       matlab.ui.control.Spinner
        BSpinnerLabel                  matlab.ui.control.Label
        AdditionalFilterDropDown       matlab.ui.control.DropDown
        AdditionalFilterDropDownLabel  matlab.ui.control.Label
        CSpinner                       matlab.ui.control.Spinner
        CSpinnerLabel                  matlab.ui.control.Label
        ASpinner                       matlab.ui.control.Spinner
        ASpinnerLabel                  matlab.ui.control.Label
        Generator2DropDown             matlab.ui.control.DropDown
        Generator2DropDownLabel        matlab.ui.control.Label
        Generator1DropDown             matlab.ui.control.DropDown
        Generator1DropDownLabel        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
        CenterPanel                    matlab.ui.container.Panel
        EqualizerLabel                 matlab.ui.control.Label
        Label_5                        matlab.ui.control.Label
        kLabel_5                       matlab.ui.control.Label
        Slider_10                      matlab.ui.control.Slider
        Slider_9                       matlab.ui.control.Slider
        kLabel_3                       matlab.ui.control.Label
        kLabel                         matlab.ui.control.Label
        kLabel_2                       matlab.ui.control.Label
        kLabel_4                       matlab.ui.control.Label
        Label_4                        matlab.ui.control.Label
        Label_3                        matlab.ui.control.Label
        Label_2                        matlab.ui.control.Label
        Label                          matlab.ui.control.Label
        Slider_8                       matlab.ui.control.Slider
        Slider_7                       matlab.ui.control.Slider
        Slider_6                       matlab.ui.control.Slider
        Slider_5                       matlab.ui.control.Slider
        Slider_4                       matlab.ui.control.Slider
        Slider_3                       matlab.ui.control.Slider
        Slider_2                       matlab.ui.control.Slider
        Slider                         matlab.ui.control.Slider
        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
        OffsetDropDown                 matlab.ui.control.DropDown
        OffsetDropDownLabel            matlab.ui.control.Label
        LFODropDown                    matlab.ui.control.DropDown
        LFODropDownLabel               matlab.ui.control.Label
        PlayingLamp                    matlab.ui.control.Lamp
        PlayingLampLabel               matlab.ui.control.Label
        VolumeSlider                   matlab.ui.control.Slider
        VolumeSliderLabel              matlab.ui.control.Label
        ReverseCheckBox                matlab.ui.control.CheckBox
        ControlsLabel                  matlab.ui.control.Label
        PauseButton                    matlab.ui.control.Button
        PlayButton                     matlab.ui.control.Button
        A_AttackSlider                 matlab.ui.control.Slider
        AttackSlider_3Label            matlab.ui.control.Label
        Label_6                        matlab.ui.control.Label
        ValueSpinner                   matlab.ui.control.Spinner
        ValueSpinnerLabel              matlab.ui.control.Label
        AmpEnvelopeDropDown            matlab.ui.control.DropDown
        AmpEnvelopeDropDownLabel       matlab.ui.control.Label
        PitchEnvelopeDropDownLabel     matlab.ui.control.Label
        PitchEnvelopeDropDown          matlab.ui.control.DropDown
        A_RelSlider                    matlab.ui.control.Slider
        RelSlider_3Label               matlab.ui.control.Label
        A_SusSlider                    matlab.ui.control.Slider
        SusSlider_3Label               matlab.ui.control.Label
        A_DecaySlider                  matlab.ui.control.Slider
        DecaySlider_3Label             matlab.ui.control.Label
        P_RelSlider                    matlab.ui.control.Slider
        RelSlider_2Label               matlab.ui.control.Label
        P_SusSlider                    matlab.ui.control.Slider
        SusSlider_2Label               matlab.ui.control.Label
        P_DecaySlider                  matlab.ui.control.Slider
        DecaySlider_2Label             matlab.ui.control.Label
        P_AttackSlider                 matlab.ui.control.Slider
        AttackSlider_2Label            matlab.ui.control.Label
        ModulationLabel                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

    
    properties (Access = public)
        Property % App Written by Darell Chua Yun Da
        play = 0;
        MIDIinput = 0;

        generator_options = {'', 'Sine', 'Square', 'Triangle', 'Sawtooth', 'WhiteNoise', 'HalfCircle'};
        
    end
    
    methods (Access = public)
        function [new_x, fs, lfophase] = func(app,lfophase)
            %Basic Example test 
            %Written by Darell
            
            location = string(app.SRClocationEditField.Value());
            
            
            addpath (location + '/Helper')
            addpath (location + '/Filter')
            addpath (location + '/Select')
            addpath (location + '/AmpEnvelope')
            addpath (location + '/PitchEnvelope')
            addpath (location + '/Generators')
            addpath (location + '/LFO')
            addpath (location + '/Offset')
            
            fs = app.SamplingFsSpinner.Value();
            duration = app.DurationSpinner.Value();
            
            tdomain = 0:1/fs:(duration - 1/fs); %to plot against t     
            Len = length(tdomain);
            Fdomain = fs * (-Len/2 : (Len/2 - 1))/Len ; %to plot against F
            FTtestinput = 100 * ones([1,Len]);
            
            if (app.SoundByteButton.Value)
                %Sound Byte Generator
                filename = app.FileLocationEditField.Value();
                
                [y,fs] = audioread(filename);
                [A,B] = size(y);
                app.SamplingFsSpinner.Value = fs;
                
                lengthy = length(y);
                if ((duration*fs) > lengthy)
                    duration = length(y)/fs;
                    app.DurationSpinner.Value = duration;
                end
                y = y((1:(duration*fs)),:);
                                
                
                new_y = zeros(1,duration*fs);
                
                for n = 1:B
                    new_y = new_y + y(:,n)';
                end
                x = new_y;
                
                plot(x)
                
                
                tdomain = 0:1/fs:(duration - 1/fs); %to plot against t     
                Len = length(tdomain);
                Fdomain = fs * (-Len/2 : (Len/2 - 1))/Len ; %to plot against F
                FTtestinput = 100 * ones([1,Len]);
                
                
            elseif (app.SoundGeneratorButton.Value)
                %Sound Generator 
                amplitude = app.AmplitudeSpinner.Value();
                frequency = app.FrequencySpinner.Value();
                phase = app.PhaseSpinner.Value();
                
                duty = app.DutySpinner.Value();
                number = app.Generator1DropDown.Value();
                x = SoundGeneratorSelect(amplitude, frequency, phase, fs, duration, duty,number);
                
                amplitude = app.AmplitudeSpinner_2.Value();
                frequency = app.FrequencySpinner_2.Value();
                phase = app.PhaseSpinner_2.Value();
                duty = app.DutySpinner_2.Value();
                number = app.Generator2DropDown.Value();
                x = x + SoundGeneratorSelect(amplitude, frequency, phase, fs, duration, duty,number);
            elseif (app.MIDIButton.Value)
                 x = app.MIDIinput;
            end
            
            %Band Pass Filter
            LOW = app.FloorSpinner.Value();
            HIGH = app.CeilingSpinner.Value();
            MED = "unused";

            new_x = DarellbandpassFilter(x,fs,LOW,MED,HIGH);
            
            x = new_x;
            
            %Harmonic Offset
            number = app.OffsetDropDown.Value();
            f_offset = app.ValueSpinner.Value();
            new_x = OffsetSelect(x, f_offset,number);
            x = new_x;
            
            %Additional Filter
            LOW = app.ASpinner.Value();
            MED = app.BSpinner.Value();
            HIGH = app.CSpinner.Value();

            number = app.AdditionalFilterDropDown.Value();
            new_x = FilterSelect(x,fs,LOW,MED,HIGH,number);
            
            fttestinput = ifft(FTtestinput);
            fttestoutput = FilterSelect(fttestinput,fs,LOW,MED,HIGH,number);
            FilterEnv = fftshift(fft(fttestoutput));
            plot(app.UIAxes_3,Fdomain,FilterEnv)
            
            x = new_x;
            
            %Pitch Envelope
            attack = app.P_AttackSlider.Value();
            decay = app.P_DecaySlider.Value();
            sustain = app.P_SusSlider.Value();
            release = app.P_RelSlider.Value();
            
            number = app.PitchEnvelopeDropDown.Value();
            new_x = PitchEnvelopeSelect(x, fs, attack,decay,sustain,release,number);
            
            PitchEnvelope = 0 .* tdomain;
            if number ~= "NIL"
                PitchEnvelope = app.EnvelopePlot(attack,decay,sustain,release,duration,fs); 
            end
            plot(app.UIAxes_4,tdomain,PitchEnvelope)
            
            x = new_x;
             
            %Amplitude Envelope
            attack = app.A_AttackSlider.Value();
            decay = app.A_DecaySlider.Value();
            sustain = app.A_SusSlider.Value();
            release = app.A_RelSlider.Value();
            
            number = app.AmpEnvelopeDropDown.Value();
            new_x = AmpEnvelopeSelect(x, fs, attack,decay,sustain,release,number); %output new sound in time domain
           
            AmplitudeEnv = new_x ./ x;
            plot(app.UIAxes_2,tdomain,AmplitudeEnv)
            plot(app.UIAxes,tdomain,new_x)
            
            after_freq = fftshift(fft(new_x));    
            plot(app.UIAxes2,Fdomain,after_freq)

            %Sound Reversal 
            if app.ReverseCheckBox.Value == true
                new_x = reverse(new_x);
            end
            
            %LFO
            frequency = app.OscFreqSpinner.Value();
            if frequency > 0
                x = new_x;
                number = app.LFODropDown.Value;
                new_x = x + LFOSelect(1, frequency, lfophase, fs, duration, new_x,number);
                lfophase = 1/(frequency*duration);
            end
            
            Equalizerplot = app.Eqplot(Len,Fdomain);
            
            new_x = Equalizer_Darell(new_x,Equalizerplot,fs);
            
            vol = app.VolumeSlider.Value();
            volume = ((log(0.001*vol+0.0001))/log(10) - log(0.0001)/log(10));
            new_x = amplify(new_x, volume);

        end
        
        function play_continuous_inapp(app, wave, fs)
            soundfile = audioplayer(wave,fs);
            playblocking(soundfile);
        end
        
        function output = EnvelopePlot(app,attack,decay,sustain,release,T,Fs) %percentages for attack, decay, sustain, release
            %CREATES A PLOT FOR ENVELOPE
            attacktime = attack * T * Fs;
            decaytime = attacktime + decay * T * Fs;
            sustaintime = (T - (release * T))* Fs;
            
            x = 0:1/Fs:(T-1/Fs);
            y = 0 .* x; %create zero array of y of len x
            
            tcounter = 1;
            %attack phase
            
            while tcounter <= attacktime
                y(tcounter) = (1/attacktime) * tcounter;
                tcounter = tcounter+1;
            end
            istart = tcounter;
            while tcounter<= decaytime
                y(tcounter) = 1 - (((1-sustain)/(decay * T * Fs)) * (tcounter - istart));
                tcounter = tcounter+1;
            end
        
            while tcounter<= sustaintime
                y(tcounter) = sustain;
                tcounter = tcounter+1;
            end
            istart = tcounter;
            while tcounter < (T * Fs)
                y(tcounter) = sustain - ((sustain/(release * T * Fs)) * (tcounter - istart));
                tcounter = tcounter+1;
            end
            output = y;
        end
        
        function output = Eqplot(app,len,Fdomain) %percentages for attack, decay, sustain, release
            %CREATES A PLOT FOR EQ
            
            F = Fdomain;
            y = 0 .* F; %create zero array of y of len F
        
            Flist = [0 32 64 125 250 500 1000 2000 4000 8000 16000 22000];
            EQlist = [0 app.Slider.Value app.Slider_2.Value app.Slider_3.Value app.Slider_4.Value app.Slider_5.Value app.Slider_6.Value app.Slider_7.Value app.Slider_8.Value app.Slider_9.Value app.Slider_10.Value 0];
            %attack phase
        
            mid = len/2;
            Flistlength = length(Flist)-1;
            n = 1;
            prevn = 0;
            for fn = 1:Flistlength
                while abs(F(mid + n)) <= Flist(fn + 1)
                    y(mid + n) = (((EQlist(fn + 1)-EQlist(fn))/(Flist(fn + 1) - Flist(fn)))*(n-prevn)) + EQlist(fn);
                    y(mid - n) = y(mid + n);
                    n = n + 1;
                end
                
                prevn = n;
        
            end
        
            output = y;
            %plot(Fdomain,y)
        end
        
    end
    

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

        % Code that executes after component creation
        function startupFcn(app)
            app.SRClocationEditField.Value = append(pwd, '\src');
            app.FileLocationEditField.Value = pwd;
            cd(string(app.SRClocationEditField.Value()));
            app.play = 0;
            app.PlayingLamp.Color = [0.00,0.00,0.00];
            app.RecordingLamp.Color = [0.00,0.00,0.00];
            app.PlayingLampLabel.Text = "";
        end

        % Callback function
        function PitchEnvelopeListBoxValueChanged(app, event)
            value = app.PitchEnvelopeListBox.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 = {875, 875, 875};
                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 = {875, 875};
                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 = {226, '1x', 231};
                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

        % Button pushed function: PlayButton
        function PlayButtonPushed(app, event)
            app.play = 1;
            lfophase = 0;
            app.PlayingLamp.Color = [1.00,0.00,0.00];
            app.PlayingLampLabel.Text = "Playing";
            drawnow()
            while app.play > 0 %change to counts/while play button active
                [new_x, fs,lfophase] = app.func(lfophase);
                app.play_continuous_inapp(new_x, fs)
            end
            app.PlayingLamp.Color = [0.00,0.00,0.00];
            app.PlayingLampLabel.Text = "Paused";
            drawnow()
      
        end

        % Button pushed function: PauseButton
        function PauseButtonPushed(app, event)
            app.play = 0;
        end

        % Value changed function: ReverseCheckBox
        function ReverseCheckBoxValueChanged(app, event)
            value = app.ReverseCheckBox.Value;
            
        end

        % Button pushed function: StartButton
        function StartButtonPushed(app, event)
            fs = app.SamplingFsSpinner.Value();
            dur = app.DurationSpinner.Value();
            app.RecordingLamp.Color = [1.00,0.00,0.00];
            app.MIDIinput = MIDIDarell(dur,fs);
            app.RecordingLamp.Color = [0.00,0.00,0.00];
        end

        % Drop down opening function: Generator1DropDown
        function Generator1DropDownOpening(app, event)

            app.Generator1DropDown.Items = app.generator_options;
        end

        % Drop down opening function: Generator2DropDown
        function Generator2DropDownOpening(app, event)
            
            app.Generator2DropDown.Items = app.generator_options;
        end

        % Value changed function: Generator1DropDown
        function Generator1DropDownValueChanged(app, event)
            value = app.Generator1DropDown.Value;
            if(value == "Sine")
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = true;
                app.PhaseSpinner.Visible = true;
                app.DutySpinner.Visible = false;
            elseif(value == "WhiteNoise")
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = false;
                app.PhaseSpinner.Visible = false;
                app.DutySpinner.Visible = false;
            else
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = true;
                app.PhaseSpinner.Visible = true;
                app.DutySpinner.Visible = true;
            end
        end

        % Value changed function: Generator2DropDown
        function Generator2DropDownValueChanged(app, event)
            value = app.Generator2DropDown.Value;
            if(value == "Sine")
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = true;
                app.PhaseSpinner_2.Visible = true;
                app.DutySpinner_2.Visible = false;
            elseif(value == "WhiteNoise")
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = false;
                app.PhaseSpinner_2.Visible = false;
                app.DutySpinner_2.Visible = false;
            else
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = true;
                app.PhaseSpinner_2.Visible = true;
                app.DutySpinner_2.Visible = true;
            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 984 875];
            app.UIFigure.Name = 'MATLAB App';
            app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);

            % Create GridLayout
            app.GridLayout = uigridlayout(app.UIFigure);
            app.GridLayout.ColumnWidth = {226, '1x', 231};
            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 BandPassFilterLabel
            app.BandPassFilterLabel = uilabel(app.LeftPanel);
            app.BandPassFilterLabel.FontWeight = 'bold';
            app.BandPassFilterLabel.Position = [12 184 100 22];
            app.BandPassFilterLabel.Text = 'Band-Pass Filter';

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

            % Create FloorSpinner
            app.FloorSpinner = uispinner(app.LeftPanel);
            app.FloorSpinner.Step = 100;
            app.FloorSpinner.Limits = [0 Inf];
            app.FloorSpinner.Position = [86 160 100 22];
            app.FloorSpinner.Value = 20;

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

            % Create CeilingSpinner
            app.CeilingSpinner = uispinner(app.LeftPanel);
            app.CeilingSpinner.Step = 100;
            app.CeilingSpinner.Limits = [0 Inf];
            app.CeilingSpinner.Position = [86 139 100 22];
            app.CeilingSpinner.Value = 20000;

            % Create Generator1DropDownLabel
            app.Generator1DropDownLabel = uilabel(app.LeftPanel);
            app.Generator1DropDownLabel.HorizontalAlignment = 'right';
            app.Generator1DropDownLabel.FontWeight = 'bold';
            app.Generator1DropDownLabel.Position = [12 552 73 22];
            app.Generator1DropDownLabel.Text = 'Generator 1';

            % Create Generator1DropDown
            app.Generator1DropDown = uidropdown(app.LeftPanel);
            app.Generator1DropDown.Items = {};
            app.Generator1DropDown.DropDownOpeningFcn = createCallbackFcn(app, @Generator1DropDownOpening, true);
            app.Generator1DropDown.ValueChangedFcn = createCallbackFcn(app, @Generator1DropDownValueChanged, true);
            app.Generator1DropDown.Position = [99 552 100 22];
            app.Generator1DropDown.Value = {};

            % Create Generator2DropDownLabel
            app.Generator2DropDownLabel = uilabel(app.LeftPanel);
            app.Generator2DropDownLabel.HorizontalAlignment = 'right';
            app.Generator2DropDownLabel.FontWeight = 'bold';
            app.Generator2DropDownLabel.Position = [12 426 73 22];
            app.Generator2DropDownLabel.Text = 'Generator 2';

            % Create Generator2DropDown
            app.Generator2DropDown = uidropdown(app.LeftPanel);
            app.Generator2DropDown.Items = {};
            app.Generator2DropDown.DropDownOpeningFcn = createCallbackFcn(app, @Generator2DropDownOpening, true);
            app.Generator2DropDown.ValueChangedFcn = createCallbackFcn(app, @Generator2DropDownValueChanged, true);
            app.Generator2DropDown.Position = [99 426 100 22];
            app.Generator2DropDown.Value = {};

            % Create ASpinnerLabel
            app.ASpinnerLabel = uilabel(app.LeftPanel);
            app.ASpinnerLabel.HorizontalAlignment = 'right';
            app.ASpinnerLabel.Position = [52 76 25 22];
            app.ASpinnerLabel.Text = 'A';

            % Create ASpinner
            app.ASpinner = uispinner(app.LeftPanel);
            app.ASpinner.Step = 100;
            app.ASpinner.Position = [92 76 100 22];

            % Create CSpinnerLabel
            app.CSpinnerLabel = uilabel(app.LeftPanel);
            app.CSpinnerLabel.HorizontalAlignment = 'right';
            app.CSpinnerLabel.Position = [52 35 25 22];
            app.CSpinnerLabel.Text = 'C';

            % Create CSpinner
            app.CSpinner = uispinner(app.LeftPanel);
            app.CSpinner.Step = 100;
            app.CSpinner.Position = [92 35 100 22];
            app.CSpinner.Value = 3;

            % Create AdditionalFilterDropDownLabel
            app.AdditionalFilterDropDownLabel = uilabel(app.LeftPanel);
            app.AdditionalFilterDropDownLabel.HorizontalAlignment = 'right';
            app.AdditionalFilterDropDownLabel.FontWeight = 'bold';
            app.AdditionalFilterDropDownLabel.Position = [12 107 96 22];
            app.AdditionalFilterDropDownLabel.Text = 'Additional Filter';

            % Create AdditionalFilterDropDown
            app.AdditionalFilterDropDown = uidropdown(app.LeftPanel);
            app.AdditionalFilterDropDown.Items = {'Option 1', 'Option 2', 'Option 3', 'Option 4', 'NIL'};
            app.AdditionalFilterDropDown.Position = [122 107 94 22];
            app.AdditionalFilterDropDown.Value = 'NIL';

            % Create BSpinnerLabel
            app.BSpinnerLabel = uilabel(app.LeftPanel);
            app.BSpinnerLabel.HorizontalAlignment = 'right';
            app.BSpinnerLabel.Position = [52 55 25 22];
            app.BSpinnerLabel.Text = 'B';

            % Create BSpinner
            app.BSpinner = uispinner(app.LeftPanel);
            app.BSpinner.Step = 100;
            app.BSpinner.Position = [92 55 100 22];
            app.BSpinner.Value = 300;

            % Create AmplitudeSpinnerLabel
            app.AmplitudeSpinnerLabel = uilabel(app.LeftPanel);
            app.AmplitudeSpinnerLabel.HorizontalAlignment = 'right';
            app.AmplitudeSpinnerLabel.Position = [13 520 60 22];
            app.AmplitudeSpinnerLabel.Text = 'Amplitude';

            % Create AmplitudeSpinner
            app.AmplitudeSpinner = uispinner(app.LeftPanel);
            app.AmplitudeSpinner.Limits = [0 Inf];
            app.AmplitudeSpinner.Position = [88 520 100 22];
            app.AmplitudeSpinner.Value = 0.25;

            % Create FrequencySpinnerLabel
            app.FrequencySpinnerLabel = uilabel(app.LeftPanel);
            app.FrequencySpinnerLabel.HorizontalAlignment = 'right';
            app.FrequencySpinnerLabel.Position = [11 499 62 22];
            app.FrequencySpinnerLabel.Text = 'Frequency';

            % Create FrequencySpinner
            app.FrequencySpinner = uispinner(app.LeftPanel);
            app.FrequencySpinner.Limits = [0 Inf];
            app.FrequencySpinner.Position = [88 499 100 22];
            app.FrequencySpinner.Value = 200;

            % Create PhaseSpinnerLabel
            app.PhaseSpinnerLabel = uilabel(app.LeftPanel);
            app.PhaseSpinnerLabel.HorizontalAlignment = 'right';
            app.PhaseSpinnerLabel.Position = [34 477 39 22];
            app.PhaseSpinnerLabel.Text = 'Phase';

            % Create PhaseSpinner
            app.PhaseSpinner = uispinner(app.LeftPanel);
            app.PhaseSpinner.Step = 0.1;
            app.PhaseSpinner.Limits = [0 Inf];
            app.PhaseSpinner.Position = [88 477 100 22];

            % Create DutySpinnerLabel
            app.DutySpinnerLabel = uilabel(app.LeftPanel);
            app.DutySpinnerLabel.HorizontalAlignment = 'right';
            app.DutySpinnerLabel.Position = [43 456 30 22];
            app.DutySpinnerLabel.Text = 'Duty';

            % Create DutySpinner
            app.DutySpinner = uispinner(app.LeftPanel);
            app.DutySpinner.Step = 0.01;
            app.DutySpinner.Limits = [0 Inf];
            app.DutySpinner.Position = [88 456 100 22];
            app.DutySpinner.Value = 0.5;

            % Create AmplitudeSpinner_2Label
            app.AmplitudeSpinner_2Label = uilabel(app.LeftPanel);
            app.AmplitudeSpinner_2Label.HorizontalAlignment = 'right';
            app.AmplitudeSpinner_2Label.Position = [14 395 60 22];
            app.AmplitudeSpinner_2Label.Text = 'Amplitude';

            % Create AmplitudeSpinner_2
            app.AmplitudeSpinner_2 = uispinner(app.LeftPanel);
            app.AmplitudeSpinner_2.Limits = [0 Inf];
            app.AmplitudeSpinner_2.Position = [89 395 100 22];
            app.AmplitudeSpinner_2.Value = 0.25;

            % Create FrequencySpinner_2Label
            app.FrequencySpinner_2Label = uilabel(app.LeftPanel);
            app.FrequencySpinner_2Label.HorizontalAlignment = 'right';
            app.FrequencySpinner_2Label.Position = [12 374 62 22];
            app.FrequencySpinner_2Label.Text = 'Frequency';

            % Create FrequencySpinner_2
            app.FrequencySpinner_2 = uispinner(app.LeftPanel);
            app.FrequencySpinner_2.Limits = [0 Inf];
            app.FrequencySpinner_2.Position = [89 374 100 22];
            app.FrequencySpinner_2.Value = 202;

            % Create PhaseSpinner_2Label
            app.PhaseSpinner_2Label = uilabel(app.LeftPanel);
            app.PhaseSpinner_2Label.HorizontalAlignment = 'right';
            app.PhaseSpinner_2Label.Position = [35 353 39 22];
            app.PhaseSpinner_2Label.Text = 'Phase';

            % Create PhaseSpinner_2
            app.PhaseSpinner_2 = uispinner(app.LeftPanel);
            app.PhaseSpinner_2.Step = 0.1;
            app.PhaseSpinner_2.Limits = [0 Inf];
            app.PhaseSpinner_2.Position = [89 353 100 22];

            % Create DutySpinner_2Label
            app.DutySpinner_2Label = uilabel(app.LeftPanel);
            app.DutySpinner_2Label.HorizontalAlignment = 'right';
            app.DutySpinner_2Label.Position = [44 332 30 22];
            app.DutySpinner_2Label.Text = 'Duty';

            % Create DutySpinner_2
            app.DutySpinner_2 = uispinner(app.LeftPanel);
            app.DutySpinner_2.Step = 0.01;
            app.DutySpinner_2.Limits = [0 Inf];
            app.DutySpinner_2.Position = [89 332 100 22];
            app.DutySpinner_2.Value = 0.5;

            % Create SRClocationEditFieldLabel
            app.SRClocationEditFieldLabel = uilabel(app.LeftPanel);
            app.SRClocationEditFieldLabel.HorizontalAlignment = 'right';
            app.SRClocationEditFieldLabel.FontWeight = 'bold';
            app.SRClocationEditFieldLabel.Position = [10 845 83 22];
            app.SRClocationEditFieldLabel.Text = 'SRC location:';

            % Create SRClocationEditField
            app.SRClocationEditField = uieditfield(app.LeftPanel, 'text');
            app.SRClocationEditField.Position = [16 824 196 22];

            % Create FrequencyFiltersLabel
            app.FrequencyFiltersLabel = uilabel(app.LeftPanel);
            app.FrequencyFiltersLabel.FontSize = 14;
            app.FrequencyFiltersLabel.FontWeight = 'bold';
            app.FrequencyFiltersLabel.Position = [38 209 125 22];
            app.FrequencyFiltersLabel.Text = 'Frequency Filters:';

            % Create SoundGeneratorsLabel
            app.SoundGeneratorsLabel = uilabel(app.LeftPanel);
            app.SoundGeneratorsLabel.FontSize = 14;
            app.SoundGeneratorsLabel.FontWeight = 'bold';
            app.SoundGeneratorsLabel.Position = [43 580 131 22];
            app.SoundGeneratorsLabel.Text = 'Sound Generators:';

            % Create SoundByteFileLabel
            app.SoundByteFileLabel = uilabel(app.LeftPanel);
            app.SoundByteFileLabel.FontSize = 14;
            app.SoundByteFileLabel.FontWeight = 'bold';
            app.SoundByteFileLabel.Position = [49 698 114 22];
            app.SoundByteFileLabel.Text = 'Sound Byte File:';

            % Create SoundButtonGroup
            app.SoundButtonGroup = uibuttongroup(app.LeftPanel);
            app.SoundButtonGroup.Title = 'Sound';
            app.SoundButtonGroup.Position = [30 724 170 91];

            % Create SoundByteButton
            app.SoundByteButton = uiradiobutton(app.SoundButtonGroup);
            app.SoundByteButton.Text = 'Sound Byte';
            app.SoundByteButton.Position = [11 45 85 22];

            % Create SoundGeneratorButton
            app.SoundGeneratorButton = uiradiobutton(app.SoundButtonGroup);
            app.SoundGeneratorButton.Text = 'Sound Generator';
            app.SoundGeneratorButton.Position = [11 23 114 22];
            app.SoundGeneratorButton.Value = true;

            % Create MIDIButton
            app.MIDIButton = uiradiobutton(app.SoundButtonGroup);
            app.MIDIButton.Text = 'MIDI';
            app.MIDIButton.Position = [11 0 47 22];

            % Create MIDILabel
            app.MIDILabel = uilabel(app.LeftPanel);
            app.MIDILabel.FontSize = 14;
            app.MIDILabel.FontWeight = 'bold';
            app.MIDILabel.Position = [84 290 41 22];
            app.MIDILabel.Text = 'MIDI:';

            % Create RecordingLampLabel
            app.RecordingLampLabel = uilabel(app.LeftPanel);
            app.RecordingLampLabel.HorizontalAlignment = 'right';
            app.RecordingLampLabel.Position = [51 240 61 22];
            app.RecordingLampLabel.Text = 'Recording';

            % Create RecordingLamp
            app.RecordingLamp = uilamp(app.LeftPanel);
            app.RecordingLamp.Position = [127 240 20 20];

            % Create SamplingFsSpinnerLabel
            app.SamplingFsSpinnerLabel = uilabel(app.LeftPanel);
            app.SamplingFsSpinnerLabel.HorizontalAlignment = 'right';
            app.SamplingFsSpinnerLabel.Position = [10 625 72 22];
            app.SamplingFsSpinnerLabel.Text = 'Sampling Fs';

            % Create SamplingFsSpinner
            app.SamplingFsSpinner = uispinner(app.LeftPanel);
            app.SamplingFsSpinner.Step = 100;
            app.SamplingFsSpinner.Limits = [0 Inf];
            app.SamplingFsSpinner.Position = [97 625 100 22];
            app.SamplingFsSpinner.Value = 44800;

            % Create DurationSpinnerLabel
            app.DurationSpinnerLabel = uilabel(app.LeftPanel);
            app.DurationSpinnerLabel.HorizontalAlignment = 'right';
            app.DurationSpinnerLabel.Position = [31 604 51 22];
            app.DurationSpinnerLabel.Text = 'Duration';

            % Create DurationSpinner
            app.DurationSpinner = uispinner(app.LeftPanel);
            app.DurationSpinner.Limits = [1 Inf];
            app.DurationSpinner.RoundFractionalValues = 'on';
            app.DurationSpinner.Position = [97 604 100 22];
            app.DurationSpinner.Value = 1;

            % Create StartButton
            app.StartButton = uibutton(app.LeftPanel, 'push');
            app.StartButton.ButtonPushedFcn = createCallbackFcn(app, @StartButtonPushed, true);
            app.StartButton.Position = [49 263 100 22];
            app.StartButton.Text = 'Start';

            % Create FileLocationEditFieldLabel
            app.FileLocationEditFieldLabel = uilabel(app.LeftPanel);
            app.FileLocationEditFieldLabel.HorizontalAlignment = 'right';
            app.FileLocationEditFieldLabel.Position = [5 668 74 22];
            app.FileLocationEditFieldLabel.Text = 'File Location';

            % Create FileLocationEditField
            app.FileLocationEditField = uieditfield(app.LeftPanel, 'text');
            app.FileLocationEditField.Position = [94 668 100 22];

            % 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 = [220 585 276 282];

            % 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 = [213 330 283 251];

            % 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 = [16 719 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 = [16 520 189 200];

            % 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 = [16 328 189 193];

            % Create Slider
            app.Slider = uislider(app.CenterPanel);
            app.Slider.Limits = [0 2];
            app.Slider.Orientation = 'vertical';
            app.Slider.Position = [22 96 3 150];
            app.Slider.Value = 1;

            % Create Slider_2
            app.Slider_2 = uislider(app.CenterPanel);
            app.Slider_2.Limits = [0 2];
            app.Slider_2.Orientation = 'vertical';
            app.Slider_2.Position = [79 96 3 150];
            app.Slider_2.Value = 1;

            % Create Slider_3
            app.Slider_3 = uislider(app.CenterPanel);
            app.Slider_3.Limits = [0 2];
            app.Slider_3.Orientation = 'vertical';
            app.Slider_3.Position = [121 96 3 150];
            app.Slider_3.Value = 1;

            % Create Slider_4
            app.Slider_4 = uislider(app.CenterPanel);
            app.Slider_4.Limits = [0 2];
            app.Slider_4.Orientation = 'vertical';
            app.Slider_4.Position = [176 96 3 150];
            app.Slider_4.Value = 1;

            % Create Slider_5
            app.Slider_5 = uislider(app.CenterPanel);
            app.Slider_5.Limits = [0 2];
            app.Slider_5.Orientation = 'vertical';
            app.Slider_5.Position = [222 96 3 150];
            app.Slider_5.Value = 1;

            % Create Slider_6
            app.Slider_6 = uislider(app.CenterPanel);
            app.Slider_6.Limits = [0 2];
            app.Slider_6.Orientation = 'vertical';
            app.Slider_6.Position = [265 96 3 150];
            app.Slider_6.Value = 1;

            % Create Slider_7
            app.Slider_7 = uislider(app.CenterPanel);
            app.Slider_7.Limits = [0 2];
            app.Slider_7.Orientation = 'vertical';
            app.Slider_7.Position = [314 96 3 150];
            app.Slider_7.Value = 1;

            % Create Slider_8
            app.Slider_8 = uislider(app.CenterPanel);
            app.Slider_8.Limits = [0 2];
            app.Slider_8.Orientation = 'vertical';
            app.Slider_8.Position = [366 96 3 150];
            app.Slider_8.Value = 1;

            % Create Label
            app.Label = uilabel(app.CenterPanel);
            app.Label.Position = [22 258 25 22];
            app.Label.Text = '32';

            % Create Label_2
            app.Label_2 = uilabel(app.CenterPanel);
            app.Label_2.Position = [79 258 25 22];
            app.Label_2.Text = '64';

            % Create Label_3
            app.Label_3 = uilabel(app.CenterPanel);
            app.Label_3.Position = [124 258 26 22];
            app.Label_3.Text = '125';

            % Create Label_4
            app.Label_4 = uilabel(app.CenterPanel);
            app.Label_4.Position = [224 258 26 22];
            app.Label_4.Text = '500';

            % Create kLabel_4
            app.kLabel_4 = uilabel(app.CenterPanel);
            app.kLabel_4.Position = [274 258 25 22];
            app.kLabel_4.Text = '1k';

            % Create kLabel_2
            app.kLabel_2 = uilabel(app.CenterPanel);
            app.kLabel_2.Position = [468 258 25 22];
            app.kLabel_2.Text = '16k';

            % Create kLabel
            app.kLabel = uilabel(app.CenterPanel);
            app.kLabel.Position = [423 258 25 22];
            app.kLabel.Text = '8k';

            % Create kLabel_3
            app.kLabel_3 = uilabel(app.CenterPanel);
            app.kLabel_3.Position = [316 258 25 22];
            app.kLabel_3.Text = '2k';

            % Create Slider_9
            app.Slider_9 = uislider(app.CenterPanel);
            app.Slider_9.Limits = [0 2];
            app.Slider_9.Orientation = 'vertical';
            app.Slider_9.Position = [421 96 3 150];
            app.Slider_9.Value = 1;

            % Create Slider_10
            app.Slider_10 = uislider(app.CenterPanel);
            app.Slider_10.Limits = [0 2];
            app.Slider_10.Orientation = 'vertical';
            app.Slider_10.Position = [463 96 3 150];
            app.Slider_10.Value = 1;

            % Create kLabel_5
            app.kLabel_5 = uilabel(app.CenterPanel);
            app.kLabel_5.Position = [368 258 25 22];
            app.kLabel_5.Text = '4k';

            % Create Label_5
            app.Label_5 = uilabel(app.CenterPanel);
            app.Label_5.Position = [176 258 26 22];
            app.Label_5.Text = '250';

            % Create EqualizerLabel
            app.EqualizerLabel = uilabel(app.CenterPanel);
            app.EqualizerLabel.FontSize = 14;
            app.EqualizerLabel.FontWeight = 'bold';
            app.EqualizerLabel.Position = [204 55 67 22];
            app.EqualizerLabel.Text = 'Equalizer';

            % 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 = [37 789 55 22];
            app.OscFreqSpinnerLabel.Text = 'Osc Freq';

            % Create OscFreqSpinner
            app.OscFreqSpinner = uispinner(app.RightPanel);
            app.OscFreqSpinner.Limits = [0 20];
            app.OscFreqSpinner.Position = [107 789 100 22];

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

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

            % Create P_AttackSlider
            app.P_AttackSlider = uislider(app.RightPanel);
            app.P_AttackSlider.Limits = [0 1];
            app.P_AttackSlider.Position = [73 688 135 3];
            app.P_AttackSlider.Value = 0.2;

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

            % Create P_DecaySlider
            app.P_DecaySlider = uislider(app.RightPanel);
            app.P_DecaySlider.Limits = [0 1];
            app.P_DecaySlider.Position = [73 646 135 3];
            app.P_DecaySlider.Value = 0.2;

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

            % Create P_SusSlider
            app.P_SusSlider = uislider(app.RightPanel);
            app.P_SusSlider.Limits = [0 1];
            app.P_SusSlider.Position = [73 604 135 3];
            app.P_SusSlider.Value = 0.8;

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

            % Create P_RelSlider
            app.P_RelSlider = uislider(app.RightPanel);
            app.P_RelSlider.Limits = [0 1];
            app.P_RelSlider.Position = [73 563 135 3];
            app.P_RelSlider.Value = 0.2;

            % Create DecaySlider_3Label
            app.DecaySlider_3Label = uilabel(app.RightPanel);
            app.DecaySlider_3Label.HorizontalAlignment = 'right';
            app.DecaySlider_3Label.Position = [15 427 39 22];
            app.DecaySlider_3Label.Text = 'Decay';

            % Create A_DecaySlider
            app.A_DecaySlider = uislider(app.RightPanel);
            app.A_DecaySlider.Limits = [0 1];
            app.A_DecaySlider.Position = [75 436 135 3];
            app.A_DecaySlider.Value = 0.2;

            % Create SusSlider_3Label
            app.SusSlider_3Label = uilabel(app.RightPanel);
            app.SusSlider_3Label.HorizontalAlignment = 'right';
            app.SusSlider_3Label.Position = [28 385 26 22];
            app.SusSlider_3Label.Text = 'Sus';

            % Create A_SusSlider
            app.A_SusSlider = uislider(app.RightPanel);
            app.A_SusSlider.Limits = [0 1];
            app.A_SusSlider.Position = [75 394 135 3];
            app.A_SusSlider.Value = 0.8;

            % Create RelSlider_3Label
            app.RelSlider_3Label = uilabel(app.RightPanel);
            app.RelSlider_3Label.HorizontalAlignment = 'right';
            app.RelSlider_3Label.Position = [29 344 25 22];
            app.RelSlider_3Label.Text = 'Rel';

            % Create A_RelSlider
            app.A_RelSlider = uislider(app.RightPanel);
            app.A_RelSlider.Limits = [0 1];
            app.A_RelSlider.Position = [75 353 135 3];
            app.A_RelSlider.Value = 0.2;

            % Create PitchEnvelopeDropDown
            app.PitchEnvelopeDropDown = uidropdown(app.RightPanel);
            app.PitchEnvelopeDropDown.Items = {'Option 1', 'Option 2', 'Option 3', 'Option 4', 'NIL'};
            app.PitchEnvelopeDropDown.Position = [117 700 100 22];
            app.PitchEnvelopeDropDown.Value = 'NIL';

            % Create PitchEnvelopeDropDownLabel
            app.PitchEnvelopeDropDownLabel = uilabel(app.RightPanel);
            app.PitchEnvelopeDropDownLabel.HorizontalAlignment = 'right';
            app.PitchEnvelopeDropDownLabel.FontWeight = 'bold';
            app.PitchEnvelopeDropDownLabel.Position = [12 700 91 22];
            app.PitchEnvelopeDropDownLabel.Text = 'Pitch Envelope';

            % Create AmpEnvelopeDropDownLabel
            app.AmpEnvelopeDropDownLabel = uilabel(app.RightPanel);
            app.AmpEnvelopeDropDownLabel.HorizontalAlignment = 'right';
            app.AmpEnvelopeDropDownLabel.FontWeight = 'bold';
            app.AmpEnvelopeDropDownLabel.Position = [13 490 88 22];
            app.AmpEnvelopeDropDownLabel.Text = 'Amp Envelope';

            % Create AmpEnvelopeDropDown
            app.AmpEnvelopeDropDown = uidropdown(app.RightPanel);
            app.AmpEnvelopeDropDown.Items = {'Option 1', 'Option 2', 'Option 3', 'Option 4', 'NIL'};
            app.AmpEnvelopeDropDown.Position = [115 490 100 22];
            app.AmpEnvelopeDropDown.Value = 'NIL';

            % Create ValueSpinnerLabel
            app.ValueSpinnerLabel = uilabel(app.RightPanel);
            app.ValueSpinnerLabel.HorizontalAlignment = 'right';
            app.ValueSpinnerLabel.Position = [59 735 34 22];
            app.ValueSpinnerLabel.Text = 'Value';

            % Create ValueSpinner
            app.ValueSpinner = uispinner(app.RightPanel);
            app.ValueSpinner.Limits = [1 20];
            app.ValueSpinner.Position = [108 736 100 22];
            app.ValueSpinner.Value = 1;

            % Create Label_6
            app.Label_6 = uilabel(app.RightPanel);
            app.Label_6.FontWeight = 'bold';
            app.Label_6.Position = [14 768 25 22];
            app.Label_6.Text = '';

            % Create AttackSlider_3Label
            app.AttackSlider_3Label = uilabel(app.RightPanel);
            app.AttackSlider_3Label.HorizontalAlignment = 'right';
            app.AttackSlider_3Label.Position = [14 469 40 22];
            app.AttackSlider_3Label.Text = 'Attack';

            % Create A_AttackSlider
            app.A_AttackSlider = uislider(app.RightPanel);
            app.A_AttackSlider.Limits = [0 1];
            app.A_AttackSlider.Position = [75 478 135 3];
            app.A_AttackSlider.Value = 0.2;

            % Create PlayButton
            app.PlayButton = uibutton(app.RightPanel, 'push');
            app.PlayButton.ButtonPushedFcn = createCallbackFcn(app, @PlayButtonPushed, true);
            app.PlayButton.Position = [7 151 100 22];
            app.PlayButton.Text = 'Play';

            % Create PauseButton
            app.PauseButton = uibutton(app.RightPanel, 'push');
            app.PauseButton.ButtonPushedFcn = createCallbackFcn(app, @PauseButtonPushed, true);
            app.PauseButton.Position = [118 151 100 22];
            app.PauseButton.Text = 'Pause';

            % Create ControlsLabel
            app.ControlsLabel = uilabel(app.RightPanel);
            app.ControlsLabel.FontSize = 14;
            app.ControlsLabel.FontWeight = 'bold';
            app.ControlsLabel.Position = [80 242 66 22];
            app.ControlsLabel.Text = 'Controls:';

            % Create ReverseCheckBox
            app.ReverseCheckBox = uicheckbox(app.RightPanel);
            app.ReverseCheckBox.ValueChangedFcn = createCallbackFcn(app, @ReverseCheckBoxValueChanged, true);
            app.ReverseCheckBox.Text = 'Reverse';
            app.ReverseCheckBox.Position = [125 116 66 22];

            % Create VolumeSliderLabel
            app.VolumeSliderLabel = uilabel(app.RightPanel);
            app.VolumeSliderLabel.HorizontalAlignment = 'right';
            app.VolumeSliderLabel.Position = [7 211 45 22];
            app.VolumeSliderLabel.Text = 'Volume';

            % Create VolumeSlider
            app.VolumeSlider = uislider(app.RightPanel);
            app.VolumeSlider.Limits = [0 1.25];
            app.VolumeSlider.Position = [71 210 140 3];
            app.VolumeSlider.Value = 1;

            % Create PlayingLampLabel
            app.PlayingLampLabel = uilabel(app.RightPanel);
            app.PlayingLampLabel.HorizontalAlignment = 'right';
            app.PlayingLampLabel.Position = [13 116 45 22];
            app.PlayingLampLabel.Text = 'Playing';

            % Create PlayingLamp
            app.PlayingLamp = uilamp(app.RightPanel);
            app.PlayingLamp.Position = [73 116 20 20];

            % Create LFODropDownLabel
            app.LFODropDownLabel = uilabel(app.RightPanel);
            app.LFODropDownLabel.HorizontalAlignment = 'right';
            app.LFODropDownLabel.FontWeight = 'bold';
            app.LFODropDownLabel.Position = [64 814 29 22];
            app.LFODropDownLabel.Text = 'LFO';

            % Create LFODropDown
            app.LFODropDown = uidropdown(app.RightPanel);
            app.LFODropDown.Items = {'Option 1', 'Option 2', 'Option 3', 'Option 4', 'Option 5', 'NIL'};
            app.LFODropDown.Position = [107 814 100 22];
            app.LFODropDown.Value = 'NIL';

            % Create OffsetDropDownLabel
            app.OffsetDropDownLabel = uilabel(app.RightPanel);
            app.OffsetDropDownLabel.HorizontalAlignment = 'right';
            app.OffsetDropDownLabel.FontWeight = 'bold';
            app.OffsetDropDownLabel.Position = [51 761 40 22];
            app.OffsetDropDownLabel.Text = 'Offset';

            % Create OffsetDropDown
            app.OffsetDropDown = uidropdown(app.RightPanel);
            app.OffsetDropDown.Items = {'Option 1', 'Option 2', 'Option 3', 'Option 4', 'Option 5', 'NIL'};
            app.OffsetDropDown.Position = [105 761 100 22];
            app.OffsetDropDown.Value = 'NIL';

            % 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)

            % Execute the startup function
            runStartupFcn(app, @startupFcn)

            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