% extractRef.m This function adjust length of signal for video analysis

function [ refMicNumber, referenceName, referenceMic ] = extractRef( refRec, ref_01, ref_02 )

refMicNumber        = size( refRec, 2 );
referenceSignals    = char( ref_01, ref_02 );
longestChar         = max( size( referenceSignals, 2 ) );
emptyChar           = blanks( longestChar );

% check if at least one reference is selected
TF                  = isempty( referenceSignals );
if TF == 1
    error( 'At least one reference must be selected -> check parameters' )
end    
    
j = 1;
for i = 1 : refMicNumber
    tf = strcmp( referenceSignals( i, : ), emptyChar );
    if tf == 0
        referenceMic( :, j ) = refRec( :, i );
        referenceName( j, : ) = referenceSignals( i, : );
        j = j + 1;
    end
end

refMicNumber        = size( referenceMic, 2 );                              % update value
