% truth = process_label(label_file,t)
%
%  Reads a label file and reformats the information into
%  an array.
%
%  Inputs:
%    label_file - string with the location of the label file
%    t - the time array (in seconds)
%
%  Outputs:
%    truth - an array exactly the same length as t.  Ones indicate
%      solo and zeros indicate non-solo.  So, if truth(10) is 1,
%      that means the .wav has solo music at time t(10).
%
% Dec-14-2006 ces2130@columbia.edu
function truth = process_label(label_file,t)

% read the stuff out of a file
[start finish label] = textread(label_file, ...
    '%f %f %s', 'commentstyle','shell');

% covert labels into numbers - 0 for non-solo and 1 for solo
ll = zeros(length(label),1);
ll(strmatch('solo',label)) = 1;

% classify each time interval as either non-solo (0) or solo (1)
truth = zeros(length(t),1);

% now set the solo bits to 1
for i=1:length(ll)
    if ll(i) == 1
        inds = logical(t>= start(i) & t < finish(i));
        truth(inds) = 1;
    end
end
