function show_crosscorr_result( crosscorr_result_filename, do_pause, loc_ind, mic_ind )

% Show the result of "crosscorr_analysis_wrapper.m"
% in a graphical way:
% 
%   one picture per speaker location: GCC-PHAT narrowband correlogram
%   with the location of the peak marked in black.
%
% Refer to "crosscorr_analysis_wrapper.m" and "crosscorr_analysis.m"
% for more details.
%
% By Guillaume Lathoud, 2006  (email address in "my_email_address.jpg")

  if nargin < 1
    error( [ mfilename ' needs 1 input argument.' ] );
  end
  
  if ~exist( 'do_pause', 'var' )
    do_pause = 1;
  end

  if ~exist( 'loc_ind', 'var' )
    loc_ind = [];
  end

  if ~exist( 'mic_ind', 'var' )
    mic_ind = [];
  end

  % load the result
  disp( [ mfilename ' is loading "' crosscorr_result_filename '"...' ] );
  load( crosscorr_result_filename, 'out' );
  
  % Display one picture per speaker location: GCC-PHAT narrowband
  % correlogram with the location of the peak marked in black.
  
  n_loc = numel( out.loc );
  
  disp( sprintf( [ mfilename ': iterating through the %d speaker locations...' ], n_loc ) );
  
  if isempty( loc_ind )
    i_loc_list = 1:n_loc;
  else
    i_loc_list = intersect( 1:n_loc, loc_ind );
  end

  for i_loc = i_loc_list

    n_mic = numel( out.loc( i_loc ).distantmic );

    if isempty( mic_ind )
      i_mic_list = 1:n_mic;
    else
      i_mic_list = intersect( 1:n_mic, mic_ind );
    end

    for i_mic = i_mic_list

      hfig = figure( i_mic ); clf

      ref_delay = out.loc( i_loc ).distantmic( i_mic ).fullband_delaymax;

      xmark = out.p.narrowbandcenter;
      ymark = ( out.loc( i_loc ).distantmic( i_mic ).delay ) - ref_delay; 

      imagesc( xmark, ymark, out.loc( i_loc ).distantmic( i_mic ).narrowband_gcc );
      hold on; plot( xmark, out.loc( i_loc ).distantmic( i_mic ).narrowband_delaymax - ref_delay, 'k', 'linewidth', 2 );
      set( gca, 'FontSize', 20 );
      axis tight;
      axis xy
      
      title_i_loc = i_loc;
      title_i_mic = out.loc( i_loc ).distantmic( i_mic ).i_mic;
      title_d_diff = out.p.d_diff( title_i_mic, title_i_loc );
      a_title = sprintf( [ out.recording_name  ', loc. #%d, mic. #%d (%.3f m)' ], title_i_loc, title_i_mic, title_d_diff );
      title( strrep( a_title, '_', '\_' ) );

      xlabel( 'narrowband center frequency (Hz)' );
      ylabel( 'normalized narrowband Time Of Flight (samples)' );

      % Graphical output to files
      [ p, n, e ] = fileparts( crosscorr_result_filename );
      
      % Dump eps to file (b/w)
      figure( hfig ); colormap( 0.1 + 0.9 * ( colormap( 'gray' ) .^ 3 ) );
      out_filename = fullfile( p, [ n sprintf( '-loc_%02d-mic_%02d-bw.eps', title_i_loc, title_i_mic ) ] );
      print( hfig, '-depsc2', out_filename );
      disp( [ mfilename ': wrote out "' out_filename '".' ] );
      
      % Dump eps to file (color)
      figure( hfig ); colormap( jet );
      out_filename = fullfile( p, [ n sprintf( '-loc_%02d-mic_%02d-color.eps', title_i_loc, title_i_mic ) ] );
      print( hfig, '-depsc2', out_filename );
      disp( [ mfilename ': wrote out "' out_filename '".' ] );
      
    end

    if do_pause
      disp( [ mfilename ': press a key to move to the next speaker location.' ] );
      pause
    end

  end
  
  