function loctimeseg = compute_smooth_loctimeseg( loctimeseg, par )

  if nargin < 2
    error( [ mfilename ' needs 2 input arguments.' ] );
  end

  check_param( { 'erosion_sec', 'dilation_sec', 'closure_sec', 'opening_sec' }, fieldnames( par ) );

  for a = 1:loctimeseg.nChannels
    
    a_seg = loctimeseg.seg{ a };

    % Temporarily, drop silence segments, keep speech segments only
    % ( for compatibility with erode_seg etc. )

    a_seg = a_seg( 1:2, find( a_seg( 3, : ) ) ) - loctimeseg.startTime;

    a_seg = erode_seg( a_seg, par.erosion_sec );
    
    a_seg = dilate_seg( a_seg, par.dilation_sec );

    a_seg = close_seg( a_seg, par.closure_sec );
    
    a_seg = open_seg( a_seg, par.opening_sec );
    
    % Merge consecutive segments

    a_seg = simplify_seg( a_seg );

    % Make silences explicit again, store the smoothed result

    tmp = define_silence_in_seg( a_seg, loctimeseg.endTime - loctimeseg.startTime );
    tmp( 1:2, : ) = tmp( 1:2, : ) + loctimeseg.startTime;

    loctimeseg.seg{ a } = tmp;
    
  end
  