GEN52

GEN52 — Creates an interleaved multichannel table from the specified source tables, in the format expected by the ftconv opcode.

Description

GEN52 creates an interleaved multichannel table from the specified source tables, in the format expected by the ftconv opcode. It can also be used to extract a channel from a multichannel table and store it in a normal mono table, copy tables with skipping some samples, adding delay, or store in reverse order, etc.

Three parameters must be given for each channel to be processed. fsrc declares the source f-table number. The parameter offset specifies an offset for the source file. If different to 0, the source file is not read from the beginning, but the offset number of values are skipped. The offset is used to determine the channel number to be read from interleaved f-tables, e.g. for channel 2, offset must be 1. It can also be used to set a read offset on the source table. This parameter gives absolute values, so if a skip of 20 sample frames for a 2 channel f-table is desired, offset must be set to 40. The srcchnls parameter is used to declare the number of channels in the source f-table. This parameter sets the skip size when reading the source f-table.

When more than one channel (nchannels > 1) is given, source f-tables are interleaved in the newly created table.

If the source f-table is finished before the destination f-table is full, the remaining values are set to 0.

Syntax

f # time size 52 nchannels fsrc1 offset1 srcchnls1 [fsrc2 offset2 srcchnls2 ... fsrcN offsetN srcchnlsN]

Example

; source tables
f 1 0 16384 10 1
f 2 0 16384 10 0 1
; create 2 channel interleaved table
f 3 0 32768 -52 2 1 0 1 2 0 1
; extract first channel from table 3
f 4 0 16384 -52 1 3 0 2
; extract second channel from table 3
f 5 0 16384 -52 1 3 1 2

Here is a complete example of the GEN52 opcode. It uses the file gen52.csd.

Example 1095. Example of the GEN52 opcode.

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

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

garvb   init 0
gaW     init 0
gaX     init 0
gaY     init 0

itmp    ftgen  1, 0, 64, -2, 2, 40, -1, -1, -1, 123,           \
               1, 13.000, 0.05, 0.85, 20000.0, 0.0, 0.50, 2,   \
               1,  2.000, 0.05, 0.85, 20000.0, 0.0, 0.25, 2,   \
               1, 16.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2,   \
               1,  9.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2,   \
               1, 12.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2,   \
               1,  8.000, 0.05, 0.85, 20000.0, 0.0, 0.35, 2

itmp    ftgen 2, 0, 262144, -2, 0
        spat3dt 2, -0.2, 1, 0, 1, 1, 2, 0.005

itmp    ftgen 3, 0, 262144, -52, 3, 2, 0, 4, 2, 1, 4, 2, 2, 4

instr 1

a1      vco2 1, 440, 10
kfrq    port 100, 0.008, 20000
a1      butterlp a1, kfrq
a2      linseg 0, 0.003, 1, 0.01, 0.7, 0.005, 0, 1, 0
a1      =  a1 * a2 * 2
        denorm a1
        vincr garvb, a1
aw, ax, ay, az  spat3di a1, p4, p5, p6, 1, 1, 2
        vincr gaW, aw
        vincr gaX, ax
        vincr gaY, ay

endin

instr 2

       denorm garvb
; skip as many samples as possible without truncating the IR
arW, arX, arY   ftconv garvb, 3, 2048, 2048, (65536 - 2048)
aW      =  gaW + arW
aX      =  gaX + arX
aY      =  gaY + arY
garvb   =  0
gaW     =  0
gaX     =  0
gaY     =  0

aWre, aWim      hilbert aW
aXre, aXim      hilbert aX
aYre, aYim      hilbert aY
aWXr    =  0.0928*aXre + 0.4699*aWre
aWXiYr  =  0.2550*aXim - 0.1710*aWim + 0.3277*aYre
aL      =  aWXr + aWXiYr
aR      =  aWXr - aWXiYr

       outs aL, aR

endin

</CsInstruments>
<CsScore>

i 1 0 0.5  0.0  2.0 -0.8
i 1 1 0.5  1.4  1.4 -0.6
i 1 2 0.5  2.0  0.0 -0.4
i 1 3 0.5  1.4 -1.4 -0.2
i 1 4 0.5  0.0 -2.0  0.0
i 1 5 0.5 -1.4 -1.4  0.2
i 1 6 0.5 -2.0  0.0  0.4
i 1 7 0.5 -1.4  1.4  0.6
i 1 8 0.5  0.0  2.0  0.8
i 2 0 10
e

</CsScore>
</CsoundSynthesizer>


This is the diagram of the waveform of the GEN52 routine, as used in the example:

f 3 0 262144 -52 3 2 0 4 2 1 4 2 2 4

f 3 0 262144 -52 3 2 0 4 2 1 4 2 2 4

Credits

Author: Istvan Varga