function main_loop( impl_list, rec_list )

  if nargin < 2
    error( [ mfilename ' needs 2 input arguments.' ] );
  end
  
  % For each implementation (FULL, FAST or FASTTDE)

  for i_impl = 1:numel( impl_list )

    impl_name = impl_list{ i_impl };

    % For each recording

    for i_rec = 1:numel( rec_list )
      
      rec_name = rec_list{ i_rec };

      % ( 1 ) Run the multisource detection-localization

      eval( [ impl_name '_detect_locate_wrapper( ''' rec_name ''' );' ] );

      % ( 2 ) Select a detection threshold from posteriors of wideband activity
      % Based on the theory in ICASSP 2006 / IDIAP RR 05-52.
      % Currently this is offline. This could also be implemented online, within 
      % step 1 (multisource detection-localization).
      
      par = [];
      par.in_filename = [ 'DATA/' impl_name '_detect_locate_wrapper-' rec_name '-result.mat' ];
      % To select the automatic threshold for the final decision,
      % based on IDIAP RR 05-52. This is a False Alarm Rate target, between 0 and 1.
      par.far_t       = 0.001;
      par.out_dir     = 'DATA';
      
      wa_sns_model( par );
      
      % ( 3 ) Apply the threshold in order to keep only clusters of location estimates
      % that are wideband AND non-stationary (this is how we select speech).
      
      classify_cluster_sns( [ 'DATA/wa_sns_model-' impl_name '_detect_locate_wrapper-' rec_name '-result.mat' ] );
      
      % ( 4 ) Evaluate the result

      eval_detloc( [ 'DATA/classify_cluster_sns-wa_sns_model-' impl_name '_detect_locate_wrapper-' rec_name '-result.mat' ] );
      
    end

  end
  