View Raw SPL
/*****************************************************************************
*                                                                            *
*   RECTWIN.SPL   Copyright (C) 2021 DSP Development Corporation             *
*                               All Rights Reserved                          *
*                                                                            *
*   Author:       Randy Race                                                 *
*                                                                            *
*   Synopsis:     Multiplies a series with a rectangular Window              *
*                                                                            *
*   Revisions:     1 Oct 2021  RRR  Creation                                 *
*                                                                            *
*****************************************************************************/


#if @HELP_RECTWIN

    RECTWIN

    Purpose: Multiplies a series with a rectangular window

    Syntax:  RECTWIN(s, ampflag, "sym")

                    s - A series or array

              ampflag - Optional, an integer, the correction factor.

                        0: do not correct amplitude (default)
                        1: correct amplitude
                        2: correct RMS 
                        3: correct mean squared amplitude

                "sym" - Optional. A string, the symmetry mode.

                        "symmetric" : Starting and ending points are equal
                                      (default).

                        "periodic"  : Periodically extended window. Conforms 
                                      to ISO standard.

   Alternate Syntax:  
             
             RECTWIN(N, ampflag, "sym")

                    N - An integer, the length of the window.

              ampflag - Optional, an integer, the correction factor.

                        0: do not correct amplitude (default)
                        1: correct amplitude
                        2: correct RMS 
                        3: correct mean squared amplitude

                "sym" - Optional. A string, the symmetry mode.

                        "symmetric" : Starting and ending points are equal
                                      (default).

                        "periodic"  : Periodically extended window. Conforms 
                                      to ISO standard.

    Returns: A series or array

    Example:
             W1: gsin(1000, .001, 45)
             W2: spectrum(rectwin(W1))
             W3: spectrum(W)

             W2 == W3. The rectangular window is the default and
             does not alter the input series.

    Remarks:
             The rectangular window does not alter the input series.

             If the input is an integer rather than a series, the N
             point rectangular window is returned.

    See Also:
             Hamming
             Hanning
             Kaiser
             Winfunc
#endif

/* undefine macro definition */
#undef RECTWIN


/* multiply a series with a rectwin window */
SERIES rectwin(s, ampflag, sym)
{
        return(winfunc(2, s, ampflag, sym));
}