GEN19
Prev | Score Statements and GEN Routines | Next

## GEN19

GEN19 — Generate composite waveforms made up of weighted sums of simple sinusoids.

## Description

These subroutines generate composite waveforms made up of weighted sums of simple sinusoids. The specification of each contributing partial requires 4 p-fields using GEN19.

## Syntax

    f # time size  19  pna   stra  phsa  dcoa  pnb strb  phsb  dcob  ...

## Initialization

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

pna, pnb, etc. -- partial no. (relative to a fundamental that would occupy size locations per cycle) of sinusoid a, sinusoid b, etc. Must be positive, but need not be a whole number, i.e., non-harmonic partials are permitted. Partials may be in any order.

stra, strb, etc. -- strength of partials pna, pnb, etc. These are relative strengths, since the composite waveform may be rescaled later. Negative values are permitted and imply a 180 degree phase shift.

phsa, phsb, etc. -- initial phase of partials pna, pnb, etc., expressed in degrees.

dcoa, dcob, etc. -- DC offset of partials pna, pnb, etc. This is applied after strength scaling, i.e. a value of 2 will lift a 2-strength sinusoid from range [-2,2] to range [0,4] (before later rescaling).

| Note

- These subroutines generate stored functions as sums of sinusoids of different frequencies. The two major restrictions on GEN10 that the partials be harmonic and in phase do not apply to GEN09 or GEN19.

  In each case the composite wave, once drawn, is then rescaled to unity if p4 was positive. A negative p4 will cause rescaling to be skipped.

## Examples

Here is a simple example of the GEN19 routine. It uses the file gen19.csd. It will generate a nice bell curve, here is its diagram:

Diagram of the waveform generated by GEN19.

Example 624. A simple example of the GEN19 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
    ; Audio out   Audio in
    -odac           -iadc    ;;;RT audio I/O
    ; For Non-realtime ouput leave only the line below:
    ; -o gen19.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

    ; Initialize the global variables.
    sr = 44100
    kr = 4410
    ksmps = 10
    nchnls = 1

    ; Instrument #1.
    instr 1
      ; Create an index over the length of our entire note.
      kcps init 1/p3
      kndx phasor kcps

      ; Read Table #1 with our index.
      ifn = 1
      ixmode = 1
      kval table kndx, ifn, ixmode

      ; Generate a sine waveform, use our Table #1 value to
      ; vary its frequency by 100 Hz from its base frequency.
      ibasefreq = 440
      kfreq = kval * 100
      a1 oscil 20000, ibasefreq + kfreq, 2
      out a1
    endin

    </CsInstruments>
    <CsScore>

    ; Table #1: a bell curve (using GEN19).
    f 1 0 16384 -19 1 1 260 1
    ; Table #2, a sine wave.
    f 2 0 16384 10 1

    ; Play Instrument #1 for 3 seconds.
    i 1 0 3
    e

    </CsScore>
    </CsoundSynthesizer>

## See Also

GEN09 and GEN10

## Credits

Example written by Kevin Conder

Prev | Up | Next
GEN18 | Home | GEN20