fog

fog — Audio output is a succession of grains derived from data in a stored function table

Description

Audio output is a succession of grains derived from data in a stored function table ifna. The local envelope of these grains and their timing is based on the model of fof synthesis and permits detailed control of the granular synthesis.

Syntax

ares fog xamp, xdens, xtrans, aspd, koct, kband, kris, kdur, kdec, \
      iolaps, ifna, ifnb, itotdur [, iphs] [, itmode] [, iskip]

Initialization

iolaps -- number of pre-located spaces needed to hold overlapping grain data. Overlaps are density dependent, and the space required depends on the maximum value of xdens * kdur. Can be over-estimated at no computation cost. Uses less than 50 bytes of memory per iolap.

ifna, ifnb -- table numbers of two stored functions. The first is the data used for granulation, usually from a soundfile (GEN01). The second is a rise shape, used forwards and backwards to shape the grain rise and decay; this is normally a sigmoid (GEN19) but may be linear (GEN05).

itotdur -- total time during which this fog will be active. Normally set to p3. No new grain is created if it cannot complete its kdur within the remaining itotdur.

iphs (optional) -- initial phase of the fundamental, expressed as a fraction of a cycle (0 to 1). The default value is 0.

itmode (optional) -- transposition mode. If zero, each grain keeps the xtrans value it was launched with. If non-zero, each is influenced by xtrans continuously. The default value is 0.

iskip (optional, default=0) -- If non-zero, skip initialization (allows legato use).

Performance

xamp -- amplitude factor. Amplitude is also dependent on the number of overlapping grains, the interaction of the rise shape (ifnb) and the exponential decay (kband), and the scaling of the grain waveform (ifna). The actual amplitude may therefore exceed xamp.

xdens -- density. The frequency of grains per second.

xtrans -- transposition factor. The rate at which data from the stored function table ifna is read within each grain. This has the effect of transposing the original material. A value of 1 produces the original pitch. Higher values transpose upwards, lower values downwards. Negative values result in the function table being read backwards.

aspd -- Starting index pointer. aspd is the normalized index (0 to 1) to table ifna that determines the movement of a pointer used as the starting point for reading data within each grain. (xtrans determines the rate at which data is read starting from this pointer.)

koct -- octaviation index. The operation of this parameter is identical to that in fof.

kband, kris, kdur, kdec -- grain envelope shape. These parameters determine the exponential decay (kband), and the rise (kris), overall duration (kdur,) and decay (kdec ) times of the grain envelope. Their operation is identical to that of the local envelope parameters in fof.

Examples

Here is an example of the fog opcode. It uses the file fog.csd.

Example 367. Example of the fog 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 fog.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

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

instr 1

;p4 = transposition factor
;p5 = speed factor
;p6 = function table for grain data
i1    =	sr/ftlen(1) ;scaling to reflect sample rate and table length
a1    phasor i1*p5 ;index for speed
asigl fog    .5, 15, p4, a1, 1, 0, .01, .5, .01, 30, 1, 2, p3 		;left channel
asigr fog    .4, 25, p4+.2, a1, 1, 0, .01, .5, .01, 30, 1, 2, p3, .5	;right channel
      outs   asigl, asigr
endin

</CsInstruments>
<CsScore>
f 1 0 131072 1 "fox.wav" 0 0 0
f 2 0 1024 19 .5 .5 270 .5

i 1 0 10 .7  .1
i 1 + 4  1.2  2
e
</CsScore>
</CsoundSynthesizer>


See Also

Granular Synthesis

Credits

Author: Michael Clark
Huddersfield
May 1997

New in version 3.46

The Csound fog generator is by Michael Clarke, extending his earlier work based on IRCAM's FOF algorithm.

Added notes by Rasmus Ekman on September 2002.