function submit_lab2(group, type, signal, synth, opt1, opt2, opt3)
%SUBMIT_LAB2  Submits Lab 2 data into submission locker for grading
%   SUBMIT_LAB2('GROUP_NAME','VOCODER_TYPE',ORIG,SYNTH,OPT1,OPT2,OPT3) submits Lab 2 speech
%   data into the submission locker for grading. Inputs are as follows:
%      GROUP_NAME   - group name (e.g. 'joecool') or student name
%      VOCODER_TYPE - either 'ch' or 'lp'
%      ORIG         - original speech signal (8 kHz)
%      SYNTH        - synthesized speech signal (8 kHz)
%      OPT1         - optional transgender, whispered, or monotone speech
%      OPT2         - optional transgender, whispered, or monotone speech
%      OPT3         - optional transgender, whispered, or monotone speech
%
%   You may call this function as many times as you like. However, only the last
%   submission for each vocoder type will be saved for grading.

% Last Modified: 3/2/09, Julie Greenberg (multiple optional inputs)
% Last Modified: 4/4/06, Eric Weiss (optional input bug fixed)
% Previously Modified: 3/20/06, Eric Weiss (documentation cleaned up,
%                                     input argument checking added)


% Root directory (where the submissions are saved)
%-------------------------------------------------
root='/mit/6.555/data/submissions/';
Fs = 8000;

% Input argument checking
%------------------------
if nargin < 4
    error('Improper function call. Not enough input arguments.');
end;
if ~ischar(group) || ~ischar(type) || ~isnumeric(signal) || ~isnumeric(synth)
    error('Improper input argument specification.');
end;
if ~strncmpi(type,'ch',2) && ~strncmpi(type,'lp',2)
    error('Your vocoder type must be either ''ch'' or ''lp''.');
elseif strncmpi(type,'ch',2)   % standardization
    type = 'ch';
elseif strncmpi(type,'lp',2)
    type = 'lp';
end;

% Write original signal
%----------------------
maxval = max(abs(signal));
filename = fullfile(root, [group,'_',type,'_orig.au']);
auwrite(signal/maxval, Fs, filename);

% Write synthesized signal
%-------------------------
maxval = max(abs(synth));
filename = fullfile(root, [group,'_',type,'_synth.au']);
auwrite(synth/maxval, Fs, filename);

% Write opt1 signal
%----------------------
if nargin == 5  && isnumeric(opt1)
    maxval = max(abs(opt1));
    filename = fullfile(root, [group,'_',type,'_opt1.au']);
    auwrite(opt1/maxval, Fs, filename);
end;

% Write opt2 signal
%----------------------
if nargin == 6  && isnumeric(opt2)
    maxval = max(abs(opt2));
    filename = fullfile(root, [group,'_',type,'_opt2.au']);
    auwrite(opt2/maxval, Fs, filename);
end;

% Write opt3 signal
%----------------------
if nargin == 7  && isnumeric(opt3)
    maxval = max(abs(opt3));
    filename = fullfile(root, [group,'_',type,'_opt3.au']);
    auwrite(opt3/maxval, Fs, filename);
end;


