%%
%   Playback Function by Daniel Natoli 

%   Plays back an output audio signal and plots it, then prompts the user
%   to export the file to disc.  

%% 
    function playback(input, IR, output, fs)
%% Signal Playback
    sound(output, fs);
    
%% Plot the resulting output signal
    
    figure(1);
    
    subplot(3,1,1) 
    plot(input);
    title('Inplut')
    xlabel('Time')
    ylabel('Amplitude')
    
    subplot(3,1,2)
    plot(IR); 
    title('Original Impulse Response (IR)')
    xlabel('Time')
    ylabel('Amplitude')    
    
    subplot(3,1,3)
    plot(output); 
    title('Convolved/Distorted Audio Output')
    xlabel('Time')
    ylabel('Amplitude')
    
    disp('SUCCESS!'); 
    
%% Dialogue Box for Export 
    
        choice = questdlg('SUCCESS! Would you like to export the file to disk?','Yes','No');
        switch choice
            case 'Yes'
                audiowrite('distconv_audio.wav', output, fs); 
                disp('File written as "distconv_audio.wav"!')
            case 'No'
                disp('File not written')
        end
        
    end 