GEN28 — Reads a text file which contains a time-tagged trajectory.


This function generator reads a text file which contains sets of three values representing the xy coordinates and a time-tag for when the signal should be placed at that location, allowing the user to define a time-tagged trajectory. The file format is in the form:

time1    X1      Y1
time2    X2      Y2
time3    X3      Y3

The configuration of the xy coordinates in space places the signal in the following way:

  • a1 is -1, 1

  • a2 is 1, 1

  • a3 is -1, -1

  • a4 is 1, -1

This assumes a loudspeaker set up as a1 is left front, a2 is right front, a3 is left back, a4 is right back. Values greater than 1 will result in sounds being attenuated as if in the distance. GEN28 creates values to 10 milliseconds of resolution.


f # time size 28 ifilcod


size -- number of points in the table. Must be 0. GEN28 takes 0 as the size and automatically allocates memory.

ifilcod -- character-string denoting the source file name. A character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the named file is sought in the current directory.


f1 0 0 28 "move"

The file "move" should look like:

0       -1       1
1        1       1
2        4       4
2.1     -4      -4
3        10     -10
5       -40      0

Since GEN28 creates values to 10 milliseconds of resolution, there will be 500 values created by interpolating X1 to X2 to X3 and so on, and Y1 to Y2 to Y3 and so on, over the appropriate number of values that are stored in the function table. The sound will begin in the left front, over 1 second it will move to the right front, over another second it move further into the distance but still in the right front, then in just 1/10th of a second it moves to the left rear, a bit distant. Finally over the last .9 seconds the sound will move to the right rear, moderately distant, and it comes to rest between the two left channels (due west!), quite distant.

Here is an example of the GEN28 routine. It uses the file gen28.csd.

Example 1120. Example of the gen28 generator.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

; 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 gen28.wav -W ;;; for file output any platform

sr = 44100 
ksmps = 32 
0dbfs  = 1 
nchnls = 4
ga1	init	0
ga2	init	0
ga3	init	0
ga4	init	0

instr 1	;uses GEN28 file "move", as found in /manual/examples

kx    init 0
ky    init 0
ktime line  0, 5, 5				;same time as in table 1 (="move")
asig  diskin2 "beats.wav", 1, 0, 1		;sound source is looped
a1, a2, a3, a4 space asig, 1, ktime, .1, kx, ky	;use table 1 = GEN28
ar1, ar2, ar3, ar4 spsend			;send to reverb

ga1  = ga1+ar1
ga2  = ga2+ar2
ga3  = ga3+ar3
ga4  = ga4+ar4
     outq a1, a2, a3, a4


instr 99 ; reverb instrument

a1 reverb2 ga1, 2.5, .5
a2 reverb2 ga2, 2.5, .5
a3 reverb2 ga3, 2.5, .5
a4 reverb2 ga4, 2.5, .5
   outq	a1, a2, a3, a4


f1 0 0 28 "move"

i1 0 5		;same time as ktime
i 99 0 10	;keep reverb active


Author: Richard Karpen
Seattle, Wash

New in Csound version 3.48