// file: window/win_create_0.cc
//

// isip include files
//
#include "window.h"
#include "window_constants.h"

// method: create_cc
//
// arguments: none
//
// return: a logical_1 indicating status
//
logical_1 Window::create_cc() {

  if (width_d < 2) {
    error_handler_cc((char_1*)"create_cc",
		     (char_1*)"invalid window width");
    return ISIP_FALSE;
  }

  if (type_d == WIN_TYPE_HAMMING) {

    for (int_4 samp = 0; samp < width_d; samp++) {
      data_d[samp] = (float_8)(WIN_HAMMING_COEFF -
			       (((float_8)1.0 - WIN_HAMMING_COEFF) *
				cos(ISIP_TWOPI * (float_8)samp /
				    (float_8)(width_d - 1))));
    }
  }
  else if (type_d == WIN_TYPE_HANNING) {

    for (int_4 samp = 0; samp < width_d; samp++) {
      data_d[samp] = (float_8)(WIN_HANNING_COEFF -
			       (((float_8)1.0 - WIN_HANNING_COEFF) *
				cos(ISIP_TWOPI * (float_8)samp /
				    (float_8)(width_d - 1))));
    }
  }
  else if (type_d == WIN_TYPE_RECTANGLE) {
    for (int_4 samp = 0; samp < width_d; samp++) {
      data_d[samp] = (float_8)1.0;
    }
  }
  else {
    error_handler_cc((char_1*)"create_cc",
		     (char_1*)"unknown window type");
    return ISIP_FALSE;
  }

  // exit gracefully
  //
  return ISIP_TRUE;
}
