GEN18

GEN18 — Writes composite waveforms made up of pre-existing waveforms.

Description

Writes composite waveforms made up of pre-existing waveforms. Each contributing waveform requires 4 pfields and can overlap with other waveforms.

Syntax

f # time size 18 fna ampa starta finisha fnb ampb startb finishb ...

Initialization

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

fna, fnb, etc. -- pre-existing table number to be written into the table.

ampa, ampb, etc. -- strength of wavefoms. These are relative strengths, since the composite waveform may be rescaled later. Negative values are permitted and imply a 180 degree phase shift.

starta, startb, etc. -- where to start writing the fn into the table.

finisha, finishb, etc. -- where to stop writing the fn into the table. The last available location is the power of two - 1.

Examples

f 1  0  4096  10  1
f 2  0  1024  18  1  1  0  511  1  1  512  1023

f2 consists of two copies of f1 written in to locations 0-511 and 512-1023.

Here is an example of the GEN18 routine. It uses the files gen18.csd.

Example 1283. An example of the GEN18 routine.

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

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

instr 1

ifn   = p4  
ilen  = ftlen(ifn)
aphase  phasor 220 
asig    tablei aphase*ilen, ifn
        outs   asig, asig
      
endin
</CsInstruments>
<CsScore>

f 1 0 4096 10 1                                         ;sine
f 2 0 4096 10 1 0.5 0.3 0.25 0.2 0.167 0.14 0.125 .111  ;sawtooth
f 3 0 4096 11 10 5 2                                    ;cosine partials

f 11 0 8192  18 1 1 0 4095 2 1 4096 8191    ;sine+sawtooth
f 12 0 8192  18 1 1 0 4095 3 1 4096 8191    ;sine+cosine partials
f 13 0 1024  18 1 0.7 0 767 3 0.7 512 1023  ;sine+cosine partials overlapped, shorter table

i 1 0 2 2    ;play sawtooth 
i 1 + 2 3    ;then cosine partials
i 1 5 2 11   ;now sine+sawtooth
i 1 + 2 12   ;and sine+cosine partials
i 1 + 2 13   ;and sine+cosine partials overlapped, shorter table

e
</CsScore>
</CsoundSynthesizer>


These are the diagrams of the waveforms generated by GEN18, as used in the example:

f 11 0 8193 18 1 1 0 4096 2 1 4097 8192 - composite waveform made up of a sine wave and a sawtooth

f 12 0 8192 18 1 1 0 4096 3 1 4097 8192 - composite waveform made up of a sine wave and a wave of cosine partials

f 12 0 8192 18 1 1 0 4096 3 1 4097 8192 - composite waveform made up of a sine wave and a wave of cosine partials

f 13 0 1024 18 1 0.7 0 767 3 0.7 512 1023 - sine+cosine partials overlapped, also shorter table than f12

f 13 0 1024 18 1 0.7 0 767 3 0.7 512 1023 - sine+cosine partials overlapped, also shorter table than f12

Deprecated Names

GEN18 was called GEN22 in version 4.18. The name was changed due to a conflict with DirectCsound.

Credits

Author: William Pete Moss
University of Texas at Austin
Austin, Texas USA
January 2002

New in version 4.18, changed in version 4.19