GEN20
Prev | Score Statements and GEN Routines | Next

## GEN20

GEN20 — Generates functions of different windows.

## Description

This subroutine generates functions of different windows. These windows are usually used for spectrum analysis or for grain envelopes.

## Syntax

    f # time size 20 window max [opt]

## Initialization

size -- number of points in the table. Must be a power of 2 ( + 1).

window -- Type of window to generate:

- 1 = Hamming

- 2 = Hanning

- 3 = Bartlett ( triangle)

- 4 = Blackman ( 3-term)

- 5 = Blackman - Harris ( 4-term)

- 6 = Gaussian

- 7 = Kaiser

- 8 = Rectangle

- 9 = Sync

max -- For negative p4 this will be the absolute value at window peak point. If p4 is positive or p4 is negative and p6 is missing the table will be post-rescaled to a maximum value of 1.

opt -- Optional argument required by the Gaussian window and the Kaiser window.

## Examples

    f       1       0       1024    20      5

This creates a function which contains a 4 - term Blackman - Harris window with maximum value of 1.

    f       1       0       1024    -20     2       456

This creates a function that contains a Hanning window with a maximum value of 456.

    f       1       0       1024    -20     1

This creates a function that contains a Hamming window with a maximum value of 1.

    f       1       0       1024    20      7       1       2

This creates a function that contains a Kaiser window with a maximum value of 1. The extra argument specifies how "open" the window is, for example a value of 0 results in a rectangular window and a value of 10 in a Hamming like window.

    f       1       0       1024    20      6       1       2

This creates a function that contains a Gaussian window with a maximum value of 1. The extra argument specifies how broad the window is, as the standard deviation of the curve; in this example the s.d. is 2. The default value is 1.

For all diagrams, see Window Functions

Here is an example of the GEN20 routine. It uses the file gen20.csd.

Example 997. Example of the GEN20 routine.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

    <CsoundSynthesizer>
    <CsOptions>

    ; Select audio/midi flags here according to platform
    -odac     ;;;realtime audio out
    ;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o gen20.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    instr 1

    insnd   = 10 				;"fox.wav"
    ibasfrq = 44100 / ftlen(insnd)		;use original sample rate of insnd file

    kamp   expseg .001, p3/2, .7, p3/2, .8	;envelope
    kpitch line ibasfrq, p3, ibasfrq * .8
    kdens  line 600, p3, 10
    kaoff  line 0, p3, .1
    kpoff  line 0, p3, ibasfrq * .5
    kgdur  line .04, p3, .001		;shorten duration of grain during note
    imaxgdur =  .5
    igfn = p4 				;different windows
    asigL  grain kamp, kpitch, kdens, kaoff, kpoff, kgdur, insnd, igfn, imaxgdur, 0.0
    asigR  grain kamp, kpitch, kdens, kaoff, kpoff, kgdur, insnd, igfn, imaxgdur, 0.0
           outs asigL, asigR

    endin
    </CsInstruments>
    <CsScore>

    f1  0 512  20 2		;Hanning window
    f2  0 512  20 6 1	;Gaussian window
    f10 0 16384 1 "fox.wav" 0 0 0

    i1 0 5 1		;use Hanning window
    i1 + 5 2		;use Gaussian window
    e
    </CsScore>
    </CsoundSynthesizer>

These are the diagrams of the waveforms of the GEN20 routines, as used in the example:

f 1 0 512 20 2 - Hanning window

f 2 0 512 20 6 1 - Gaussian window

## Credits

Author: Paris Smaragdis
MIT, Cambridge
1995

Author: John ffitch
University of Bath/Codemist Ltd.
Bath, UK

New in Csound version 3.2

Optional argument to Gaussian added in 5.10

Prev | Up | Next
GEN19 | Home | GEN21