GEN16
Prev | Score Statements and GEN Routines | Next

## GEN16

GEN16 — Creates a table from a starting value to an ending value.

## Description

Creates a table from beg value to end value of dur steps.

## Syntax

    f # time size 16 val1 dur1 type1 val2 [dur2 type2 val3 ... typeX valN]

## Initialization

size -- number of points in the table. Must be a power of 2 or a power-of-2 plus 1 (see f statement). The normal value is power-of-2 plus 1.

| Note
The end value is only reached when the table length is power-of-2 plus 1. (This length is crucial for use with the tab generator.)

beg -- starting value

dur -- number of segments

type -- if 0, a straight line is produced. If non-zero, then GEN16 creates the following curve, for dur steps:

beg + (end - beg) * (1 - exp( i*type/(dur-1) )) / (1 - exp(type))

end -- value after dur segments

Here are some examples of the curves generated for different values of type:

Tables generated by GEN16 for different values of type.

| Note
If type > 0, there is a slowly rising (concave) or slowly decaying (convex) curve, while if itype < 0, the curve is fast rising (convex) or fast decaying (concave). See also transeg.

Example 1296. A simple example of the GEN16 routine.

    <CsoundSynthesizer>
    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in
    -odac           -iadc    ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o gen16.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 128
    nchnls = 1

    instr 1
      kcps init 1/p3
      kndx phasor kcps

      ifn = p4
      ixmode = 1
      kval table kndx, ifn, ixmode

      ibasefreq = 440
      kfreq = kval * ibasefreq
      a1 oscil 20000, ibasefreq + kfreq, 1
      out a1
    endin

    </CsInstruments>
    <CsScore>

    f 1 0 16384 10 1

    f 2 0 1024 16 1 1024 1 0
    f 3 0 1024 16 1 1024 2 0
    f 4 0 1024 16 1 1024 10 0
    f 5 0 1024 16 1 1024 -1 0
    f 6 0 1024 16 1 1024 -2 0
    f 7 0 1024 16 1 1024 -10 0

    i 1 0 2 2
    i 1 + . 3
    i 1 + . 4
    i 1 + . 5
    i 1 + . 6
    i 1 + . 7

    e

    </CsScore>
    </CsoundSynthesizer>

## Credits

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

New in Csound version 4.09

Prev | Up | Next
GEN15 | Home | GEN17