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
        DurationSpinner                matlab.ui.control.Spinner
        DurationSpinnerLabel           matlab.ui.control.Label
        SamplingFsSpinner              matlab.ui.control.Spinner
        SamplingFsSpinnerLabel         matlab.ui.control.Label
        MidiPanel                      matlab.ui.container.Panel
        RecordingLamp                  matlab.ui.control.Lamp
        RecordingLampLabel             matlab.ui.control.Label
        StartButton                    matlab.ui.control.Button
        MIDILabel                      matlab.ui.control.Label
        MediumSpinner                  matlab.ui.control.Spinner
        MediumSpinnerLabel             matlab.ui.control.Label
        AdditionalFilterDropDown       matlab.ui.control.DropDown
        AdditionalFilterDropDownLabel  matlab.ui.control.Label
        HighSpinner                    matlab.ui.control.Spinner
        HighSpinnerLabel               matlab.ui.control.Label
        LowSpinner                     matlab.ui.control.Spinner
        LowSpinnerLabel                matlab.ui.control.Label
        CeilingSpinner                 matlab.ui.control.Spinner
        CeilingSpinnerLabel            matlab.ui.control.Label
        FloorSpinner                   matlab.ui.control.Spinner
        FloorSpinnerLabel              matlab.ui.control.Label
        FrequencyFiltersLabel          matlab.ui.control.Label
        SoundBytePanel                 matlab.ui.container.Panel
        FileLocationEditField          matlab.ui.control.EditField
        FileLocationEditFieldLabel     matlab.ui.control.Label
        SoundByteFileLabel             matlab.ui.control.Label
        SoundGeneratorPanel            matlab.ui.container.Panel
        PhaseSpinner_3                 matlab.ui.control.Spinner
        PhaseSpinner_3Label            matlab.ui.control.Label
        FrequencySpinner_3             matlab.ui.control.Spinner
        FrequencySpinner_3Label        matlab.ui.control.Label
        AmplitudeSpinner_3             matlab.ui.control.Spinner
        AmplitudeSpinner_3Label_2      matlab.ui.control.Label
        InstrumentDropDown             matlab.ui.control.DropDown
        InstrumentDropDownLabel        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
        Wave2DropDown                  matlab.ui.control.DropDown
        Wave2DropDownLabel             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
        Wave1DropDown                  matlab.ui.control.DropDown
        Wave1DropDownLabel             matlab.ui.control.Label
        SoundGeneratorsLabel           matlab.ui.control.Label
        SoundButtonGroup               matlab.ui.container.ButtonGroup
        SampleTuneButton               matlab.ui.control.RadioButton
        MIDIButton                     matlab.ui.control.RadioButton
        SoundGeneratorButton           matlab.ui.control.RadioButton
        SoundByteButton                matlab.ui.control.RadioButton
        SRClocationEditField           matlab.ui.control.EditField
        SRClocationEditFieldLabel      matlab.ui.control.Label
        BandPassFilterLabel            matlab.ui.control.Label
        CenterPanel                    matlab.ui.container.Panel
        ECE45SynthesizerProjectLabel   matlab.ui.control.Label
        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
        ConvoluteWave12InsteadofAddCheckBox  matlab.ui.control.CheckBox
        FlangerTimeDelay               matlab.ui.control.Spinner
        OscFreqSpinner_2Label_3        matlab.ui.control.Label
        FlangerFreqSpinner             matlab.ui.control.Spinner
        OscFreqSpinner_2Label_2        matlab.ui.control.Label
        FlangerDropDown                matlab.ui.control.DropDown
        FlangerDropDownLabel           matlab.ui.control.Label
        FlangerAmplitudeSpinner        matlab.ui.control.Spinner
        AmplitudeSpinner_3Label_3      matlab.ui.control.Label
        LFOPanel                       matlab.ui.container.Panel
        LFOFreqSpinner                 matlab.ui.control.Spinner
        OscFreqSpinner_2Label          matlab.ui.control.Label
        LFODropDown                    matlab.ui.control.DropDown
        LFODropDownLabel               matlab.ui.control.Label
        LFOAmplitudeSpinner            matlab.ui.control.Spinner
        AmplitudeSpinner_3Label        matlab.ui.control.Label
        OffsetDropDown                 matlab.ui.control.DropDown
        OffsetDropDownLabel            matlab.ui.control.Label
        ValueSpinner                   matlab.ui.control.Spinner
        ValueSpinnerLabel              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
        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
        ModulationLabel                matlab.ui.control.Label
        P_AttackSlider                 matlab.ui.control.Slider
        AttackSlider_2Label            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, Edited by Arthur Lu
        play = 0;
        MIDIinput = 0;
        
        %filter_options = {'', 'IdealBandPass', 'AmplifyRange', 'EpicEffect', 'MuffledEffect', 'SeparatePrevalent', 'IdealBandReject'}
        amp_options = {'', 'Linear'};
        filter_options = {'', 'IdealBandPass', 'AmplifyRange', 'IdealBandReject', 'EnchanceTarget', 'DampenTarget', 'EpicEffect', 'MuffledEffect', 'SeparatePrevalent', 'Distortion'};
        generator_options = {'', 'Sine', 'Square', 'Triangle', 'Sawtooth', 'WhiteNoise', 'HalfCircle', 'Trapezoid', 'Pulse', 'Cosine', 'Heartbeat', 'Harmonics'};
            instrument_options = {'', 'ArcoStrings', 'Bassoon', 'Clarinet', 'Flute', 'Horn', 'Oboe', 'Organ', 'Saxophone', 'ShepardsCarillon', 'ShepardsOrgan', 'ShepardsStrings', 'Trumpet', 'TubularBells', 'Keyboard'};
        lfo_options = {'', 'AmplitudeSine', 'AmplitudeSquare', 'AmplitudeSawtooth', 'FrequencySine', 'FrequencySquare', 'FrequencySawtooth'};
        offset_options = {'', 'Echo', 'PitchOffset'};
        pitch_options = {'', 'Logarithmic', 'Linear'};
        flanger_options = {'', 'SingleOscillating'};

    end
    
    methods (Access = public)
        function [new_x, fs, lfophase] = func(app,lfophase)
            %Written by Darell, Edited by Arthur Lu

            location = string(app.SRClocationEditField.Value());
            %addpath(genpath(location));
           
            if(~app.SampleTuneButton.Value)
                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]);
            end
            
            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 Generators
                amplitude = app.AmplitudeSpinner.Value();
                frequency = app.FrequencySpinner.Value();
                phase = app.PhaseSpinner.Value();
                
                duty = app.DutySpinner.Value();
                number = app.Wave1DropDown.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.Wave2DropDown.Value();
                y = SoundGeneratorSelect(amplitude, frequency, phase, fs, duration, duty, number);

                if(app.ConvoluteWave12InsteadofAddCheckBox.Value)
                    x = Daniel_Doan_convolution(x, y);
                    %x = x(1:fs*duration);
                else
                    x = x + y;
                end

                amplitude = app.AmplitudeSpinner_3.Value();
                frequency = app.FrequencySpinner_3.Value();
                phase = app.PhaseSpinner_3.Value();
                duty = 0;
                number = app.InstrumentDropDown.Value();
                x = x + SoundGeneratorSelect(amplitude, frequency, phase, fs, duration, duty, number);
            elseif (app.MIDIButton.Value)
                %Midi Output
                 x = app.MIDIinput;
            elseif (app.SampleTuneButton.Value)
                %base_freq = app.DurationSpinner.Value();
                x = generate_lullaby(1, 262, 0, 44810, 0, 0);

                fs = 44810;
                duration = length(x) / fs;
                
                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]);
            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.LowSpinner.Value();
            MED = app.MediumSpinner.Value();
            HIGH = app.HighSpinner.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.LFOFreqSpinner.Value();
            amplitude = app.LFOAmplitudeSpinner.Value();
            if frequency > 0
                x = new_x;
                number = app.LFODropDown.Value;
                new_x = x + LFOSelect(amplitude, frequency, lfophase, fs, duration, new_x,number);
                lfophase = 1/(frequency*duration);
            end

            %flanger
            number = app.FlangerDropDown.Value();
            if(number == "SingleOscillating")
                amplitude = app.FlangerAmplitudeSpinner.Value();
                frequency = app.FlangerFreqSpinner.Value();
                delay = app.FlangerTimeDelay.Value();
    
                new_x = flanger(new_x, delay, frequency, amplitude, fs);

            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);
            app.FileLocationEditField.Value = pwd;
            %cd(string(app.SRClocationEditField.Value()));
            
            %location = string(app.SRClocationEditField.Value());
            %addpath(genpath(location));
            
            app.play = 0;
            app.PlayingLamp.Color = [0.00,0.00,0.00];
            app.RecordingLamp.Color = [0.00,0.00,0.00];
            app.PlayingLampLabel.Text = "";

            %app.SoundBytePanel.Visible = false;
            %app.MidiPanel.Visible = false;
        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 = {1005, 1005, 1005};
                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 = {1005, 1005};
                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 = {301, '1x', 236};
                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: Wave1DropDown
        function Wave1DropDownOpening(app, event)
            app.Wave1DropDown.Items = app.generator_options;
        end

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

        % Value changed function: Wave1DropDown
        function Wave1DropDownValueChanged(app, event)
            value = app.Wave1DropDown.Value;
            if(value == "Sine")
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = true;
                app.PhaseSpinner.Visible = true;
                app.DutySpinner.Visible = false;
                app.AmplitudeSpinnerLabel.Text = 'Amplitude';
                app.FrequencySpinnerLabel.Text = 'Frequency';
                app.PhaseSpinnerLabel.Text = 'Phase';
                app.DutySpinnerLabel.Text = 'Duty';
            elseif(value == "WhiteNoise")
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = false;
                app.PhaseSpinner.Visible = false;
                app.DutySpinner.Visible = false;
                app.AmplitudeSpinnerLabel.Text = 'Amplitude';
                app.FrequencySpinnerLabel.Text = 'Frequency';
                app.PhaseSpinnerLabel.Text = 'Phase';
                app.DutySpinnerLabel.Text = 'Duty';
            elseif(value == "Pulse")
                app.AmplitudeSpinner.Visible = false;
                app.FrequencySpinner.Visible = false;
                app.PhaseSpinner.Visible = false;
                app.DutySpinner.Visible = false;
                app.AmplitudeSpinnerLabel.Text = 'Amplitude';
                app.FrequencySpinnerLabel.Text = 'Frequency';
                app.PhaseSpinnerLabel.Text = 'Phase';
                app.DutySpinnerLabel.Text = 'Duty';
            elseif(value == "Cosine")
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = true;
                app.PhaseSpinner.Visible = true;
                app.DutySpinner.Visible = false;
                app.AmplitudeSpinnerLabel.Text = 'Amplitude';
                app.FrequencySpinnerLabel.Text = 'Frequency';
                app.PhaseSpinnerLabel.Text = 'Phase';
                app.DutySpinnerLabel.Text = 'Duty';
            elseif(value == "Harmonics")
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = true;
                app.PhaseSpinner.Visible = true;
                app.DutySpinner.Visible = true;
                app.AmplitudeSpinnerLabel.Text = 'Amplitude';
                app.FrequencySpinnerLabel.Text = 'Frequency';
                app.PhaseSpinnerLabel.Text = 'Undertones';
                app.DutySpinnerLabel.Text = 'Overtones';
            else
                app.AmplitudeSpinner.Visible = true;
                app.FrequencySpinner.Visible = true;
                app.PhaseSpinner.Visible = true;
                app.DutySpinner.Visible = true;
                app.AmplitudeSpinnerLabel.Text = 'Amplitude';
                app.FrequencySpinnerLabel.Text = 'Frequency';
                app.PhaseSpinnerLabel.Text = 'Phase';
                app.DutySpinnerLabel.Text = 'Duty';
            end
        end

        % Value changed function: Wave2DropDown
        function Wave2DropDownValueChanged(app, event)
            value = app.Wave2DropDown.Value;
            if(value == "Sine")
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = true;
                app.PhaseSpinner_2.Visible = true;
                app.DutySpinner_2.Visible = false;
                app.AmplitudeSpinner_2Label.Text = 'Amplitude';
                app.FrequencySpinner_2Label.Text = 'Frequency';
                app.PhaseSpinner_2Label.Text = 'Phase';
                app.DutySpinner_2Label.Text = 'Duty';
            elseif(value == "WhiteNoise")
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = false;
                app.PhaseSpinner_2.Visible = false;
                app.DutySpinner_2.Visible = false;
                app.AmplitudeSpinner_2Label.Text = 'Amplitude';
                app.FrequencySpinner_2Label.Text = 'Frequency';
                app.PhaseSpinner_2Label.Text = 'Phase';
                app.DutySpinner_2Label.Text = 'Duty';
            elseif(value == "Pulse")
                app.AmplitudeSpinner_2.Visible = false;
                app.FrequencySpinner_2.Visible = false;
                app.PhaseSpinner_2.Visible = false;
                app.DutySpinner_2.Visible = false;
                app.AmplitudeSpinner_2Label.Text = 'Amplitude';
                app.FrequencySpinner_2Label.Text = 'Frequency';
                app.PhaseSpinner_2Label.Text = 'Phase';
                app.DutySpinner_2Label.Text = 'Duty';
            elseif(value == "Cosine")
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = true;
                app.PhaseSpinner_2.Visible = true;
                app.DutySpinner_2.Visible = false;
                app.AmplitudeSpinner_2Label.Text = 'Amplitude';
                app.FrequencySpinner_2Label.Text = 'Frequency';
                app.PhaseSpinner_2Label.Text = 'Phase';
                app.DutySpinner_2Label.Text = 'Duty';
            elseif(value == "Harmonics")
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = true;
                app.PhaseSpinner_2.Visible = true;
                app.DutySpinner_2.Visible = true;
                app.AmplitudeSpinner_2Label.Text = 'Amplitude';
                app.FrequencySpinner_2Label.Text = 'Frequency';
                app.PhaseSpinner_2Label.Text = 'Undertones';
                app.DutySpinner_2Label.Text = 'Overtones';
            else
                app.AmplitudeSpinner_2.Visible = true;
                app.FrequencySpinner_2.Visible = true;
                app.PhaseSpinner_2.Visible = true;
                app.DutySpinner_2.Visible = true;
                app.AmplitudeSpinner_2Label.Text = 'Amplitude';
                app.FrequencySpinner_2Label.Text = 'Frequency';
                app.PhaseSpinner_2Label.Text = 'Phase';
                app.DutySpinner_2Label.Text = 'Duty';
            end
        end

        % Drop down opening function: AdditionalFilterDropDown
        function AdditionalFilterDropDownOpening(app, event)
            app.AdditionalFilterDropDown.Items = app.filter_options;
        end

        % Value changed function: AdditionalFilterDropDown
        function AdditionalFilterDropDownValueChanged(app, event)
            value = app.AdditionalFilterDropDown.Value;
            if(value == "IdealBandPass")
                app.LowSpinner.Visible = true;
                app.MediumSpinner.Visible = false;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = 'Low';
                app.MediumSpinnerLabel.Text = '';
                app.HighSpinnerLabel.Text = 'High';
            elseif(value == "AmplifyRange")
                app.LowSpinner.Visible = true;
                app.MediumSpinner.Visible = true;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = 'Low';
                app.MediumSpinnerLabel.Text = 'High';
                app.HighSpinnerLabel.Text = 'Multiplier';
            elseif(value == "IdealBandReject")
                app.LowSpinner.Visible = true;
                app.MediumSpinner.Visible = false;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = 'Low';
                app.MediumSpinnerLabel.Text = '';
                app.HighSpinnerLabel.Text = 'High';
            elseif(value == "EnchanceTarget")
                app.LowSpinner.Visible = false;
                app.MediumSpinner.Visible = true;
                app.HighSpinner.Visible = false;
                app.LowSpinnerLabel.Text = '';
                app.MediumSpinnerLabel.Text = 'Target';
                app.HighSpinnerLabel.Text = '';
            elseif(value == "DampenTarget")
                app.LowSpinner.Visible = false;
                app.MediumSpinner.Visible = true;
                app.HighSpinner.Visible = false;
                app.LowSpinnerLabel.Text = '';
                app.MediumSpinnerLabel.Text = 'Target';
                app.HighSpinnerLabel.Text = '';
            elseif(value == "EpicEffect")
                app.LowSpinner.Visible = false;
                app.MediumSpinner.Visible = false;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = '';
                app.MediumSpinnerLabel.Text = '';
                app.HighSpinnerLabel.Text = 'Maximum';
            elseif(value == "MuffledEffect")
                app.LowSpinner.Visible = false;
                app.MediumSpinner.Visible = false;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = '';
                app.MediumSpinnerLabel.Text = '';
                app.HighSpinnerLabel.Text = 'Maximum';
           elseif(value == "SeparatePrevalent")
                app.LowSpinner.Visible = false;
                app.MediumSpinner.Visible = false;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = '';
                app.MediumSpinnerLabel.Text = '';
                app.HighSpinnerLabel.Text = 'Distance';
            elseif(value == "Distortion")
                app.LowSpinner.Visible = true;
                app.MediumSpinner.Visible = false;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = 'Low';
                app.MediumSpinnerLabel.Text = '';
                app.HighSpinnerLabel.Text = 'High';
            else
                app.LowSpinner.Visible = true;
                app.MediumSpinner.Visible = true;
                app.HighSpinner.Visible = true;
                app.LowSpinnerLabel.Text = 'Low';
                app.MediumSpinnerLabel.Text = 'Medium';
                app.HighSpinnerLabel.Text = 'High';
            end
        end

        % Drop down opening function: LFODropDown
        function LFODropDownOpening(app, event)
            app.LFODropDown.Items = app.lfo_options;
        end

        % Value changed function: LFODropDown
        function LFODropDownValueChanged(app, event)
            value = app.LFODropDown.Value;
            % no special functions yet
        end

        % Drop down opening function: OffsetDropDown
        function OffsetDropDownOpening(app, event)
            app.OffsetDropDown.Items = app.offset_options;
        end

        % Value changed function: OffsetDropDown
        function OffsetDropDownValueChanged(app, event)
            value = app.OffsetDropDown.Value;
            % no special functions yet
        end

        % Drop down opening function: PitchEnvelopeDropDown
        function PitchEnvelopeDropDownOpening(app, event)
            app.PitchEnvelopeDropDown.Items = app.pitch_options;
        end

        % Value changed function: PitchEnvelopeDropDown
        function PitchEnvelopeDropDownValueChanged(app, event)
            value = app.PitchEnvelopeDropDown.Value;
            % no special functions yet
        end

        % Drop down opening function: AmpEnvelopeDropDown
        function AmpEnvelopeDropDownOpening(app, event)
            app.AmpEnvelopeDropDown.Items = app.amp_options;
        end

        % Value changed function: AmpEnvelopeDropDown
        function AmpEnvelopeDropDownValueChanged(app, event)
            value = app.AmpEnvelopeDropDown.Value;
            % no special functions yet
        end

        % Drop down opening function: InstrumentDropDown
        function InstrumentDropDownOpening(app, event)
            app.InstrumentDropDown.Items = app.instrument_options;
        end

        % Value changed function: InstrumentDropDown
        function InstrumentDropDownValueChanged(app, event)
            value = app.InstrumentDropDown.Value;
            if(value == "Keyboard")
                app.AmplitudeSpinner_3.Visible = false;
                app.FrequencySpinner_3.Visible = true;
                app.PhaseSpinner_3.Visible = false;
            else
                app.AmplitudeSpinner_3.Visible = true;
                app.FrequencySpinner_3.Visible = true;
                app.PhaseSpinner_3.Visible = true;
            end
            % no special functions yet
        end

        % Selection changed function: SoundButtonGroup
        function SoundButtonGroupSelectionChanged(app, event)
            selectedButton = app.SoundButtonGroup.SelectedObject;
            %{
            if(selectedButton == app.SoundByteButton)
                app.DurationSpinnerLabel.Text = 'Duration';
                app.SoundBytePanel.Visible = true;
                app.SoundGeneratorPanel.Visible = false;
                app.MidiPanel.Visible = false;
                app.LFOPanel.Visible = true;
            elseif(selectedButton == app.SoundGeneratorButton)
                app.DurationSpinnerLabel.Text = 'Duration';
                app.SoundBytePanel.Visible = false;
                app.SoundGeneratorPanel.Visible = true;
                app.MidiPanel.Visible = false;
                app.LFOPanel.Visible = true;
            elseif(selectedButton == app.MIDIButton)
                app.DurationSpinnerLabel.Text = 'Duration';
                app.SoundBytePanel.Visible = false;
                app.SoundGeneratorPanel.Visible = false;
                app.MidiPanel.Visible = true;
                app.LFOPanel.Visible = true;
            elseif(selectedButton == app.SampleTuneButton)
                app.DurationSpinnerLabel.Text = 'Base Frequency';
                app.SoundBytePanel.Visible = false;
                app.SoundGeneratorPanel.Visible = false;
                app.MidiPanel.Visible = false;
                app.LFOPanel.Visible = false;
            else
                selectedButton
            end
            %}
            if(selectedButton == app.SampleTuneButton)
                %app.DurationSpinnerLabel.Text = 'Base Frequency';
                app.LFOPanel.Visible = false;
            else
                %app.DurationSpinnerLabel.Text = 'Duration';
                app.LFOPanel.Visible = true;
            end
        end

        % Drop down opening function: FlangerDropDown
        function FlangerDropDownOpening(app, event)
            app.FlangerDropDown.Items = app.flanger_options;
        end

        % Value changed function: FlangerDropDown
        function FlangerDropDownValueChanged(app, event)
            value = app.FlangerDropDown.Value;
            % no special functions yet
        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 1045 1005];
            app.UIFigure.Name = 'MATLAB App';
            app.UIFigure.SizeChangedFcn = createCallbackFcn(app, @updateAppLayout, true);

            % Create GridLayout
            app.GridLayout = uigridlayout(app.UIFigure);
            app.GridLayout.ColumnWidth = {301, '1x', 236};
            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 = [23 159 163 22];
            app.BandPassFilterLabel.Text = 'Band-Pass Filter';

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

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

            % Create SoundButtonGroup
            app.SoundButtonGroup = uibuttongroup(app.LeftPanel);
            app.SoundButtonGroup.SelectionChangedFcn = createCallbackFcn(app, @SoundButtonGroupSelectionChanged, true);
            app.SoundButtonGroup.Title = 'Sound';
            app.SoundButtonGroup.Position = [30 832 233 113];

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

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

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

            % Create SampleTuneButton
            app.SampleTuneButton = uiradiobutton(app.SoundButtonGroup);
            app.SampleTuneButton.Text = 'Sample Tune';
            app.SampleTuneButton.Position = [11 2 93 22];

            % Create SoundGeneratorPanel
            app.SoundGeneratorPanel = uipanel(app.LeftPanel);
            app.SoundGeneratorPanel.ForegroundColor = [1 1 1];
            app.SoundGeneratorPanel.BorderType = 'none';
            app.SoundGeneratorPanel.Position = [10 314 280 381];

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

            % Create Wave1DropDownLabel
            app.Wave1DropDownLabel = uilabel(app.SoundGeneratorPanel);
            app.Wave1DropDownLabel.HorizontalAlignment = 'right';
            app.Wave1DropDownLabel.FontWeight = 'bold';
            app.Wave1DropDownLabel.Position = [14 334 73 22];
            app.Wave1DropDownLabel.Text = 'Wave 1';

            % Create Wave1DropDown
            app.Wave1DropDown = uidropdown(app.SoundGeneratorPanel);
            app.Wave1DropDown.Items = {};
            app.Wave1DropDown.DropDownOpeningFcn = createCallbackFcn(app, @Wave1DropDownOpening, true);
            app.Wave1DropDown.ValueChangedFcn = createCallbackFcn(app, @Wave1DropDownValueChanged, true);
            app.Wave1DropDown.Position = [101 334 150 22];
            app.Wave1DropDown.Value = {};

            % Create AmplitudeSpinnerLabel
            app.AmplitudeSpinnerLabel = uilabel(app.SoundGeneratorPanel);
            app.AmplitudeSpinnerLabel.HorizontalAlignment = 'right';
            app.AmplitudeSpinnerLabel.Position = [15 302 135 22];
            app.AmplitudeSpinnerLabel.Text = 'Amplitude';

            % Create AmplitudeSpinner
            app.AmplitudeSpinner = uispinner(app.SoundGeneratorPanel);
            app.AmplitudeSpinner.Step = 0.01;
            app.AmplitudeSpinner.Limits = [0 Inf];
            app.AmplitudeSpinner.Position = [165 302 75 22];
            app.AmplitudeSpinner.Value = 0.25;

            % Create FrequencySpinnerLabel
            app.FrequencySpinnerLabel = uilabel(app.SoundGeneratorPanel);
            app.FrequencySpinnerLabel.HorizontalAlignment = 'right';
            app.FrequencySpinnerLabel.Position = [13 281 137 22];
            app.FrequencySpinnerLabel.Text = 'Frequency';

            % Create FrequencySpinner
            app.FrequencySpinner = uispinner(app.SoundGeneratorPanel);
            app.FrequencySpinner.Step = 0.01;
            app.FrequencySpinner.Limits = [0 Inf];
            app.FrequencySpinner.Position = [165 281 75 22];
            app.FrequencySpinner.Value = 200;

            % Create PhaseSpinnerLabel
            app.PhaseSpinnerLabel = uilabel(app.SoundGeneratorPanel);
            app.PhaseSpinnerLabel.HorizontalAlignment = 'right';
            app.PhaseSpinnerLabel.Position = [36 259 114 22];
            app.PhaseSpinnerLabel.Text = 'Phase';

            % Create PhaseSpinner
            app.PhaseSpinner = uispinner(app.SoundGeneratorPanel);
            app.PhaseSpinner.Step = 0.01;
            app.PhaseSpinner.Limits = [0 Inf];
            app.PhaseSpinner.Position = [165 259 75 22];

            % Create DutySpinnerLabel
            app.DutySpinnerLabel = uilabel(app.SoundGeneratorPanel);
            app.DutySpinnerLabel.HorizontalAlignment = 'right';
            app.DutySpinnerLabel.Position = [45 238 105 22];
            app.DutySpinnerLabel.Text = 'Duty';

            % Create DutySpinner
            app.DutySpinner = uispinner(app.SoundGeneratorPanel);
            app.DutySpinner.Step = 0.01;
            app.DutySpinner.Limits = [0 Inf];
            app.DutySpinner.Position = [165 238 75 22];
            app.DutySpinner.Value = 0.5;

            % Create Wave2DropDownLabel
            app.Wave2DropDownLabel = uilabel(app.SoundGeneratorPanel);
            app.Wave2DropDownLabel.HorizontalAlignment = 'right';
            app.Wave2DropDownLabel.FontWeight = 'bold';
            app.Wave2DropDownLabel.Position = [14 208 73 22];
            app.Wave2DropDownLabel.Text = 'Wave 2';

            % Create Wave2DropDown
            app.Wave2DropDown = uidropdown(app.SoundGeneratorPanel);
            app.Wave2DropDown.Items = {};
            app.Wave2DropDown.DropDownOpeningFcn = createCallbackFcn(app, @Wave2DropDownOpening, true);
            app.Wave2DropDown.ValueChangedFcn = createCallbackFcn(app, @Wave2DropDownValueChanged, true);
            app.Wave2DropDown.Position = [101 208 150 22];
            app.Wave2DropDown.Value = {};

            % Create AmplitudeSpinner_2Label
            app.AmplitudeSpinner_2Label = uilabel(app.SoundGeneratorPanel);
            app.AmplitudeSpinner_2Label.HorizontalAlignment = 'right';
            app.AmplitudeSpinner_2Label.Position = [16 177 134 22];
            app.AmplitudeSpinner_2Label.Text = 'Amplitude';

            % Create AmplitudeSpinner_2
            app.AmplitudeSpinner_2 = uispinner(app.SoundGeneratorPanel);
            app.AmplitudeSpinner_2.Step = 0.01;
            app.AmplitudeSpinner_2.Limits = [0 Inf];
            app.AmplitudeSpinner_2.Position = [165 177 76 22];
            app.AmplitudeSpinner_2.Value = 0.25;

            % Create FrequencySpinner_2Label
            app.FrequencySpinner_2Label = uilabel(app.SoundGeneratorPanel);
            app.FrequencySpinner_2Label.HorizontalAlignment = 'right';
            app.FrequencySpinner_2Label.Position = [14 156 136 22];
            app.FrequencySpinner_2Label.Text = 'Frequency';

            % Create FrequencySpinner_2
            app.FrequencySpinner_2 = uispinner(app.SoundGeneratorPanel);
            app.FrequencySpinner_2.Step = 0.01;
            app.FrequencySpinner_2.Limits = [0 Inf];
            app.FrequencySpinner_2.Position = [165 156 76 22];
            app.FrequencySpinner_2.Value = 202;

            % Create PhaseSpinner_2Label
            app.PhaseSpinner_2Label = uilabel(app.SoundGeneratorPanel);
            app.PhaseSpinner_2Label.HorizontalAlignment = 'right';
            app.PhaseSpinner_2Label.Position = [37 135 113 22];
            app.PhaseSpinner_2Label.Text = 'Phase';

            % Create PhaseSpinner_2
            app.PhaseSpinner_2 = uispinner(app.SoundGeneratorPanel);
            app.PhaseSpinner_2.Step = 0.01;
            app.PhaseSpinner_2.Limits = [0 Inf];
            app.PhaseSpinner_2.Position = [165 135 76 22];

            % Create DutySpinner_2Label
            app.DutySpinner_2Label = uilabel(app.SoundGeneratorPanel);
            app.DutySpinner_2Label.HorizontalAlignment = 'right';
            app.DutySpinner_2Label.Position = [46 114 104 22];
            app.DutySpinner_2Label.Text = 'Duty';

            % Create DutySpinner_2
            app.DutySpinner_2 = uispinner(app.SoundGeneratorPanel);
            app.DutySpinner_2.Step = 0.01;
            app.DutySpinner_2.Limits = [0 Inf];
            app.DutySpinner_2.Position = [165 114 76 22];
            app.DutySpinner_2.Value = 0.5;

            % Create InstrumentDropDownLabel
            app.InstrumentDropDownLabel = uilabel(app.SoundGeneratorPanel);
            app.InstrumentDropDownLabel.HorizontalAlignment = 'right';
            app.InstrumentDropDownLabel.FontWeight = 'bold';
            app.InstrumentDropDownLabel.Position = [15 76 73 22];
            app.InstrumentDropDownLabel.Text = 'Instrument';

            % Create InstrumentDropDown
            app.InstrumentDropDown = uidropdown(app.SoundGeneratorPanel);
            app.InstrumentDropDown.Items = {};
            app.InstrumentDropDown.DropDownOpeningFcn = createCallbackFcn(app, @InstrumentDropDownOpening, true);
            app.InstrumentDropDown.ValueChangedFcn = createCallbackFcn(app, @InstrumentDropDownValueChanged, true);
            app.InstrumentDropDown.Position = [102 76 150 22];
            app.InstrumentDropDown.Value = {};

            % Create AmplitudeSpinner_3Label_2
            app.AmplitudeSpinner_3Label_2 = uilabel(app.SoundGeneratorPanel);
            app.AmplitudeSpinner_3Label_2.HorizontalAlignment = 'right';
            app.AmplitudeSpinner_3Label_2.Position = [91 45 60 22];
            app.AmplitudeSpinner_3Label_2.Text = 'Amplitude';

            % Create AmplitudeSpinner_3
            app.AmplitudeSpinner_3 = uispinner(app.SoundGeneratorPanel);
            app.AmplitudeSpinner_3.Step = 0.01;
            app.AmplitudeSpinner_3.Limits = [0 Inf];
            app.AmplitudeSpinner_3.Position = [165 45 77 22];
            app.AmplitudeSpinner_3.Value = 0.25;

            % Create FrequencySpinner_3Label
            app.FrequencySpinner_3Label = uilabel(app.SoundGeneratorPanel);
            app.FrequencySpinner_3Label.HorizontalAlignment = 'right';
            app.FrequencySpinner_3Label.Position = [89 24 62 22];
            app.FrequencySpinner_3Label.Text = 'Frequency';

            % Create FrequencySpinner_3
            app.FrequencySpinner_3 = uispinner(app.SoundGeneratorPanel);
            app.FrequencySpinner_3.Step = 0.01;
            app.FrequencySpinner_3.Limits = [0 Inf];
            app.FrequencySpinner_3.Position = [165 24 77 22];
            app.FrequencySpinner_3.Value = 262;

            % Create PhaseSpinner_3Label
            app.PhaseSpinner_3Label = uilabel(app.SoundGeneratorPanel);
            app.PhaseSpinner_3Label.HorizontalAlignment = 'right';
            app.PhaseSpinner_3Label.Position = [112 3 39 22];
            app.PhaseSpinner_3Label.Text = 'Phase';

            % Create PhaseSpinner_3
            app.PhaseSpinner_3 = uispinner(app.SoundGeneratorPanel);
            app.PhaseSpinner_3.Step = 0.01;
            app.PhaseSpinner_3.Limits = [0 Inf];
            app.PhaseSpinner_3.Position = [165 3 77 22];

            % Create SoundBytePanel
            app.SoundBytePanel = uipanel(app.LeftPanel);
            app.SoundBytePanel.AutoResizeChildren = 'off';
            app.SoundBytePanel.BorderType = 'none';
            app.SoundBytePanel.Position = [9 703 280 65];

            % Create SoundByteFileLabel
            app.SoundByteFileLabel = uilabel(app.SoundBytePanel);
            app.SoundByteFileLabel.FontSize = 14;
            app.SoundByteFileLabel.FontWeight = 'bold';
            app.SoundByteFileLabel.Position = [15 44 111 22];
            app.SoundByteFileLabel.Text = 'Sound Byte File:';

            % Create FileLocationEditFieldLabel
            app.FileLocationEditFieldLabel = uilabel(app.SoundBytePanel);
            app.FileLocationEditFieldLabel.HorizontalAlignment = 'right';
            app.FileLocationEditFieldLabel.Position = [9 14 74 22];
            app.FileLocationEditFieldLabel.Text = 'File Location';

            % Create FileLocationEditField
            app.FileLocationEditField = uieditfield(app.SoundBytePanel, 'text');
            app.FileLocationEditField.Position = [98 14 154 22];

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

            % Create FloorSpinnerLabel
            app.FloorSpinnerLabel = uilabel(app.LeftPanel);
            app.FloorSpinnerLabel.HorizontalAlignment = 'right';
            app.FloorSpinnerLabel.Position = [49 135 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 = [97 135 163 22];
            app.FloorSpinner.Value = 20;

            % Create CeilingSpinnerLabel
            app.CeilingSpinnerLabel = uilabel(app.LeftPanel);
            app.CeilingSpinnerLabel.HorizontalAlignment = 'right';
            app.CeilingSpinnerLabel.Position = [40 114 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 = [97 114 163 22];
            app.CeilingSpinner.Value = 20000;

            % Create LowSpinnerLabel
            app.LowSpinnerLabel = uilabel(app.LeftPanel);
            app.LowSpinnerLabel.HorizontalAlignment = 'right';
            app.LowSpinnerLabel.Position = [27 51 61 22];
            app.LowSpinnerLabel.Text = 'Low';

            % Create LowSpinner
            app.LowSpinner = uispinner(app.LeftPanel);
            app.LowSpinner.Step = 100;
            app.LowSpinner.Position = [103 51 163 22];

            % Create HighSpinnerLabel
            app.HighSpinnerLabel = uilabel(app.LeftPanel);
            app.HighSpinnerLabel.HorizontalAlignment = 'right';
            app.HighSpinnerLabel.Position = [27 10 61 22];
            app.HighSpinnerLabel.Text = 'High';

            % Create HighSpinner
            app.HighSpinner = uispinner(app.LeftPanel);
            app.HighSpinner.Step = 100;
            app.HighSpinner.Position = [103 10 163 22];

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

            % Create AdditionalFilterDropDown
            app.AdditionalFilterDropDown = uidropdown(app.LeftPanel);
            app.AdditionalFilterDropDown.Items = {};
            app.AdditionalFilterDropDown.DropDownOpeningFcn = createCallbackFcn(app, @AdditionalFilterDropDownOpening, true);
            app.AdditionalFilterDropDown.ValueChangedFcn = createCallbackFcn(app, @AdditionalFilterDropDownValueChanged, true);
            app.AdditionalFilterDropDown.Position = [127 82 157 22];
            app.AdditionalFilterDropDown.Value = {};

            % Create MediumSpinnerLabel
            app.MediumSpinnerLabel = uilabel(app.LeftPanel);
            app.MediumSpinnerLabel.HorizontalAlignment = 'right';
            app.MediumSpinnerLabel.Position = [27 30 61 22];
            app.MediumSpinnerLabel.Text = 'Medium';

            % Create MediumSpinner
            app.MediumSpinner = uispinner(app.LeftPanel);
            app.MediumSpinner.Step = 100;
            app.MediumSpinner.Position = [103 30 163 22];

            % Create MidiPanel
            app.MidiPanel = uipanel(app.LeftPanel);
            app.MidiPanel.AutoResizeChildren = 'off';
            app.MidiPanel.BorderType = 'none';
            app.MidiPanel.Position = [10 224 265 83];

            % Create MIDILabel
            app.MIDILabel = uilabel(app.MidiPanel);
            app.MIDILabel.FontSize = 14;
            app.MIDILabel.FontWeight = 'bold';
            app.MIDILabel.Position = [13 62 41 22];
            app.MIDILabel.Text = 'MIDI:';

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

            % Create RecordingLampLabel
            app.RecordingLampLabel = uilabel(app.MidiPanel);
            app.RecordingLampLabel.HorizontalAlignment = 'right';
            app.RecordingLampLabel.Position = [89 8 61 22];
            app.RecordingLampLabel.Text = 'Recording';

            % Create RecordingLamp
            app.RecordingLamp = uilamp(app.MidiPanel);
            app.RecordingLamp.Position = [165 8 20 20];

            % Create SamplingFsSpinnerLabel
            app.SamplingFsSpinnerLabel = uilabel(app.LeftPanel);
            app.SamplingFsSpinnerLabel.HorizontalAlignment = 'right';
            app.SamplingFsSpinnerLabel.Position = [17 801 129 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 = [154 801 113 22];
            app.SamplingFsSpinner.Value = 44800;

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

            % Create DurationSpinner
            app.DurationSpinner = uispinner(app.LeftPanel);
            app.DurationSpinner.Limits = [1 Inf];
            app.DurationSpinner.RoundFractionalValues = 'on';
            app.DurationSpinner.Position = [154 780 113 22];
            app.DurationSpinner.Value = 1;

            % 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 = [211 610 283 325];

            % 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 = [211 297 283 293];

            % 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 = [7 714 189 219];

            % 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 = [7 500 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 = [7 297 189 193];

            % Create Slider
            app.Slider = uislider(app.CenterPanel);
            app.Slider.Limits = [0 2];
            app.Slider.Orientation = 'vertical';
            app.Slider.Position = [13 51 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 = [70 51 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 = [112 51 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 = [167 51 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 = [213 51 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 = [256 51 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 = [305 51 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 = [357 51 3 150];
            app.Slider_8.Value = 1;

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

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

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

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

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

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

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

            % Create kLabel_3
            app.kLabel_3 = uilabel(app.CenterPanel);
            app.kLabel_3.Position = [307 213 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 = [412 51 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 = [454 51 3 150];
            app.Slider_10.Value = 1;

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

            % Create Label_5
            app.Label_5 = uilabel(app.CenterPanel);
            app.Label_5.Position = [167 213 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 = [216 9 67 22];
            app.EqualizerLabel.Text = 'Equalizer';

            % Create ECE45SynthesizerProjectLabel
            app.ECE45SynthesizerProjectLabel = uilabel(app.CenterPanel);
            app.ECE45SynthesizerProjectLabel.FontSize = 24;
            app.ECE45SynthesizerProjectLabel.Position = [99 967 302 30];
            app.ECE45SynthesizerProjectLabel.Text = 'ECE 45 Synthesizer Project';

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

            % Create AttackSlider_2Label
            app.AttackSlider_2Label = uilabel(app.RightPanel);
            app.AttackSlider_2Label.HorizontalAlignment = 'right';
            app.AttackSlider_2Label.Position = [14 767 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 = [75 776 135 3];
            app.P_AttackSlider.Value = 0.2;

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

            % Create DecaySlider_2Label
            app.DecaySlider_2Label = uilabel(app.RightPanel);
            app.DecaySlider_2Label.HorizontalAlignment = 'right';
            app.DecaySlider_2Label.Position = [15 725 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 = [75 734 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 = [28 683 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 = [75 692 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 = [29 642 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 = [75 651 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 = [17 515 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 = [77 524 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 = [30 473 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 = [77 482 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 = [31 432 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 = [77 441 135 3];
            app.A_RelSlider.Value = 0.2;

            % Create PitchEnvelopeDropDown
            app.PitchEnvelopeDropDown = uidropdown(app.RightPanel);
            app.PitchEnvelopeDropDown.Items = {};
            app.PitchEnvelopeDropDown.DropDownOpeningFcn = createCallbackFcn(app, @PitchEnvelopeDropDownOpening, true);
            app.PitchEnvelopeDropDown.ValueChangedFcn = createCallbackFcn(app, @PitchEnvelopeDropDownValueChanged, true);
            app.PitchEnvelopeDropDown.Position = [122 788 97 22];
            app.PitchEnvelopeDropDown.Value = {};

            % Create PitchEnvelopeDropDownLabel
            app.PitchEnvelopeDropDownLabel = uilabel(app.RightPanel);
            app.PitchEnvelopeDropDownLabel.HorizontalAlignment = 'right';
            app.PitchEnvelopeDropDownLabel.FontWeight = 'bold';
            app.PitchEnvelopeDropDownLabel.Position = [17 788 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 = [15 578 88 22];
            app.AmpEnvelopeDropDownLabel.Text = 'Amp Envelope';

            % Create AmpEnvelopeDropDown
            app.AmpEnvelopeDropDown = uidropdown(app.RightPanel);
            app.AmpEnvelopeDropDown.Items = {};
            app.AmpEnvelopeDropDown.DropDownOpeningFcn = createCallbackFcn(app, @AmpEnvelopeDropDownOpening, true);
            app.AmpEnvelopeDropDown.ValueChangedFcn = createCallbackFcn(app, @AmpEnvelopeDropDownValueChanged, true);
            app.AmpEnvelopeDropDown.Position = [117 578 100 22];
            app.AmpEnvelopeDropDown.Value = {};

            % Create AttackSlider_3Label
            app.AttackSlider_3Label = uilabel(app.RightPanel);
            app.AttackSlider_3Label.HorizontalAlignment = 'right';
            app.AttackSlider_3Label.Position = [16 557 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 = [77 566 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 = [13 103 94 22];
            app.PlayButton.Text = 'Play';

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

            % Create ControlsLabel
            app.ControlsLabel = uilabel(app.RightPanel);
            app.ControlsLabel.FontSize = 14;
            app.ControlsLabel.FontWeight = 'bold';
            app.ControlsLabel.Position = [86 213 65 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 = [131 68 60 22];

            % Create VolumeSliderLabel
            app.VolumeSliderLabel = uilabel(app.RightPanel);
            app.VolumeSliderLabel.HorizontalAlignment = 'right';
            app.VolumeSliderLabel.Position = [13 163 39 22];
            app.VolumeSliderLabel.Text = 'Volume';

            % Create VolumeSlider
            app.VolumeSlider = uislider(app.RightPanel);
            app.VolumeSlider.Limits = [0 1.25];
            app.VolumeSlider.Position = [77 162 134 3];
            app.VolumeSlider.Value = 1;

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

            % Create PlayingLamp
            app.PlayingLamp = uilamp(app.RightPanel);
            app.PlayingLamp.Position = [79 74 14 14];

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

            % Create ValueSpinner
            app.ValueSpinner = uispinner(app.RightPanel);
            app.ValueSpinner.Step = 0.01;
            app.ValueSpinner.Limits = [1 Inf];
            app.ValueSpinner.Position = [117 833 100 22];
            app.ValueSpinner.Value = 1;

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

            % Create OffsetDropDown
            app.OffsetDropDown = uidropdown(app.RightPanel);
            app.OffsetDropDown.Items = {};
            app.OffsetDropDown.DropDownOpeningFcn = createCallbackFcn(app, @OffsetDropDownOpening, true);
            app.OffsetDropDown.ValueChangedFcn = createCallbackFcn(app, @OffsetDropDownValueChanged, true);
            app.OffsetDropDown.Position = [69 858 149 22];
            app.OffsetDropDown.Value = {};

            % Create LFOPanel
            app.LFOPanel = uipanel(app.RightPanel);
            app.LFOPanel.AutoResizeChildren = 'off';
            app.LFOPanel.BorderType = 'none';
            app.LFOPanel.Position = [6 884 220 84];

            % Create AmplitudeSpinner_3Label
            app.AmplitudeSpinner_3Label = uilabel(app.LFOPanel);
            app.AmplitudeSpinner_3Label.HorizontalAlignment = 'right';
            app.AmplitudeSpinner_3Label.Position = [38 25 57 22];
            app.AmplitudeSpinner_3Label.Text = 'Amplitude';

            % Create LFOAmplitudeSpinner
            app.LFOAmplitudeSpinner = uispinner(app.LFOPanel);
            app.LFOAmplitudeSpinner.Step = 0.01;
            app.LFOAmplitudeSpinner.Limits = [0 Inf];
            app.LFOAmplitudeSpinner.Position = [110 25 100 22];
            app.LFOAmplitudeSpinner.Value = 1;

            % Create LFODropDownLabel
            app.LFODropDownLabel = uilabel(app.LFOPanel);
            app.LFODropDownLabel.HorizontalAlignment = 'right';
            app.LFODropDownLabel.FontWeight = 'bold';
            app.LFODropDownLabel.Position = [12 57 29 22];
            app.LFODropDownLabel.Text = 'LFO';

            % Create LFODropDown
            app.LFODropDown = uidropdown(app.LFOPanel);
            app.LFODropDown.Items = {};
            app.LFODropDown.DropDownOpeningFcn = createCallbackFcn(app, @LFODropDownOpening, true);
            app.LFODropDown.ValueChangedFcn = createCallbackFcn(app, @LFODropDownValueChanged, true);
            app.LFODropDown.Position = [55 57 159 22];
            app.LFODropDown.Value = {};

            % Create OscFreqSpinner_2Label
            app.OscFreqSpinner_2Label = uilabel(app.LFOPanel);
            app.OscFreqSpinner_2Label.HorizontalAlignment = 'right';
            app.OscFreqSpinner_2Label.Position = [40 1 55 22];
            app.OscFreqSpinner_2Label.Text = 'Osc Freq';

            % Create LFOFreqSpinner
            app.LFOFreqSpinner = uispinner(app.LFOPanel);
            app.LFOFreqSpinner.Step = 0.01;
            app.LFOFreqSpinner.Limits = [0 Inf];
            app.LFOFreqSpinner.Position = [110 1 100 22];

            % Create AmplitudeSpinner_3Label_3
            app.AmplitudeSpinner_3Label_3 = uilabel(app.RightPanel);
            app.AmplitudeSpinner_3Label_3.HorizontalAlignment = 'right';
            app.AmplitudeSpinner_3Label_3.Position = [47 337 57 22];
            app.AmplitudeSpinner_3Label_3.Text = {'Amplitude'; ''};

            % Create FlangerAmplitudeSpinner
            app.FlangerAmplitudeSpinner = uispinner(app.RightPanel);
            app.FlangerAmplitudeSpinner.Step = 0.01;
            app.FlangerAmplitudeSpinner.Limits = [0 Inf];
            app.FlangerAmplitudeSpinner.Position = [119 337 100 22];
            app.FlangerAmplitudeSpinner.Value = 1;

            % Create FlangerDropDownLabel
            app.FlangerDropDownLabel = uilabel(app.RightPanel);
            app.FlangerDropDownLabel.HorizontalAlignment = 'right';
            app.FlangerDropDownLabel.FontWeight = 'bold';
            app.FlangerDropDownLabel.Position = [16 368 49 22];
            app.FlangerDropDownLabel.Text = 'Flanger';

            % Create FlangerDropDown
            app.FlangerDropDown = uidropdown(app.RightPanel);
            app.FlangerDropDown.Items = {};
            app.FlangerDropDown.DropDownOpeningFcn = createCallbackFcn(app, @FlangerDropDownOpening, true);
            app.FlangerDropDown.ValueChangedFcn = createCallbackFcn(app, @FlangerDropDownValueChanged, true);
            app.FlangerDropDown.Position = [79 368 141 22];
            app.FlangerDropDown.Value = {};

            % Create OscFreqSpinner_2Label_2
            app.OscFreqSpinner_2Label_2 = uilabel(app.RightPanel);
            app.OscFreqSpinner_2Label_2.HorizontalAlignment = 'right';
            app.OscFreqSpinner_2Label_2.Position = [49 312 55 22];
            app.OscFreqSpinner_2Label_2.Text = 'Osc Freq';

            % Create FlangerFreqSpinner
            app.FlangerFreqSpinner = uispinner(app.RightPanel);
            app.FlangerFreqSpinner.Step = 0.01;
            app.FlangerFreqSpinner.Limits = [0 Inf];
            app.FlangerFreqSpinner.Position = [119 312 100 22];

            % Create OscFreqSpinner_2Label_3
            app.OscFreqSpinner_2Label_3 = uilabel(app.RightPanel);
            app.OscFreqSpinner_2Label_3.HorizontalAlignment = 'right';
            app.OscFreqSpinner_2Label_3.Position = [39 285 65 22];
            app.OscFreqSpinner_2Label_3.Text = 'Time Delay';

            % Create FlangerTimeDelay
            app.FlangerTimeDelay = uispinner(app.RightPanel);
            app.FlangerTimeDelay.Step = 0.01;
            app.FlangerTimeDelay.Limits = [0 Inf];
            app.FlangerTimeDelay.Position = [118 285 100 22];

            % Create ConvoluteWave12InsteadofAddCheckBox
            app.ConvoluteWave12InsteadofAddCheckBox = uicheckbox(app.RightPanel);
            app.ConvoluteWave12InsteadofAddCheckBox.Text = 'Convolute Wave 1 & 2 Instead of Add';
            app.ConvoluteWave12InsteadofAddCheckBox.Position = [14 192 221 22];

            % 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