GEN32
Prev | Score Statements and GEN Routines | Next

## GEN32

GEN32 — Mixes any waveform, resampled with either FFT or linear interpolation.

## Description

This routine is similar to GEN31, but allows specifying source ftable for each partial. Tables can be resampled either with FFT, or linear interpolation.

## Syntax

    f # time size  32  srca  pna stra phsa  srcb pnb strb phsb  ...

## Performance

srca, srcb -- source table number. A negative value can be used to read the table with linear interpolation (by default, the source waveform is transposed and phase shifted using FFT); this is less accurate, but faster, and allows non-integer and negative partial numbers.

pna, pnb, ... -- partial number, must be a positive integer if source table number is positive (i.e. resample with FFT).

stra, strb, ... -- amplitude scale

phsa, phsb, ... -- start phase (0 to 1)

## Examples

Here is an example of the GEN32 routine. It uses the file gen32.csd.

Example 1212. Example of the gen32 generator.

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 gen32.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    itmp    ftgen 1, 0, 16384, 7, 1, 16384, -1		; sawtooth
    itmp    ftgen 2, 0, 8192, 10, 1				; sine
    itmp    ftgen 5, 0, 4096, -32, -2, 1.5, 1.0, 0.25, 1, 2, 0.5, 0, 1, 3, -0.25, 0.5	; mix tables
    itmp    ftgen 6, 0, 16384, 20, 3, 1			; window
    ; generate band-limited waveforms
    inote   =  0
    loop0:
    icps    =  440 * exp(log(2) * (inote - 69) / 12)        ; one table for
    inumh   =  sr / (2 * icps)                              ; each MIDI note number
    ift     =  int(inote + 256.5)
    itmp    ftgen ift, 0, 4096, -30, 5, 1, inumh
    inote   =  inote + 1
            if (inote < 127.5) igoto loop0

    instr 1

    kcps    expon 20, p3, 16000
    kft     =  int(256.5 + 69 + 12 * log(kcps / 440) / log(2))
    kft     =  (kft > 383 ? 383 : kft)
    a1      phasor kcps
    a1      tableikt a1, kft, 1, 0, 1
            outs a1*.5, a1*.5
    endin

    instr 2

    kcps    expon 20, p3, 16000
    kft     =  int(256.5 + 69 + 12 * log(kcps / 440) / log(2))
    kft     =  (kft > 383 ? 383 : kft)
    kgdur   limit 10 / kcps, 0.1, 1
    a1      grain2 kcps, 0.02, kgdur, 30, kft, 6, -0.5
            outs a1*.08, a1*.08

    endin
    </CsInstruments>
    <CsScore>
    t 0 60

    i 1 0 10
    i 2 12 10
    e
    </CsScore>
    </CsoundSynthesizer>

## Credits

Author: Rasmus Ekman

Programmer: Istvan Varga

New in version 4.17

Prev | Up | Next
GEN31 | Home | GEN33