Microtonal, just intonation, electronic music software Microtonal, just intonation, electronic music software
Login   |  Site Map

the pitch bend archive

2005-10-03 at 17:01

Csound GEN Routines

Csound is the leading open-source sound/music-synthesis software. This page is a quick-reference guide for the use of the GEN routines. For in-depth information, just refer to the Csound Canonical Reference Manual.


GEN01, GEN02, GEN03, GEN04, GEN05, GEN06, GEN07, GEN08, GEN09, GEN10, GEN11, GEN12, GEN13, GEN14, GEN15, GEN16, GEN17, GEN18, GEN19, GEN20, GEN21, GEN23, GEN24, GEN25, GEN27, GEN28, GEN30, GEN31, GEN32, GEN33, GEN34, GEN40, GEN41, GEN42, GEN51, GEN52

GEN01

Transfers data from a soundfile into a function table. The soundfile is in one of the supported formats -- wave, aiff, or au -- and is directly accessable by the local host. Once loaded into memory, the soundfile can be referenced using an ftable number.

usage

  • f# time size 1 filcod skiptime format channel

parameters

  • size -- number of points in the table. Ordinarily a power of 2 or a power-of-2 plus 1; the maximum tablesize is 16777216 (2^24) points. The allocation of table memory can be deferred by setting this parameter to 0; the size allocated is then the number of points in the file (probably not a power-of-2), and the table is not usable by normal oscillators, but it is usable by a loscil unit. The soundfile can also be mono or stereo.
  • filcod -- integer or character-string denoting the source soundfile name. An integer denotes the file soundin.filcod ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the file is sought first in the current directory, then in that given by the environment variable SSDIR (if defined) then by SFDIR.
  • skiptime -- time duration to skip at the beginning of the soundfile. The skiptime is denominate in seconds and will or course be converted into samples.
  • format -- specifies the audio-file-format of soundfile. This is a single integer as follows: 1 = 8-bit signed, 2 = 8-bit A-law, 3 = 8-bit U-law, 4 = 16-bit signed, 5 = 32-bit integers, 6 = 32-bit floating (IEEE).
  • channel -- channel number to read, which is a one-based index. A channel value of "0" specifies that all channels should be read.

GEN02

GEN02 interprets each of the input parameters, starting with parameter p5 as a single sample in the f-table. The number of parameters starting with p5 be less than or equal to the declared table size.

usage

  • f# time size 2 v1 v2 v3 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • v1, v2, v3, ... -- samples or table-values that are interpreted as successive f-table values. The number of values is limited by the compile-time variable PMAX, which controls the maximum pfields (currently 1000). The values copied may include the table guard point; any table locations not filled will contain zeros.

GEN03

GEN03 creates a stored function table by evaluating a polynomial in x over a fixed interval and with specified coefficients. The fixed-interval along the "X" axis is defined by parameters p5 and p6. The interval will be evenly spread over the resulting f-table's samples. The remaining parameters are the coefficients for the n-th power polynomials used for defining the function. The resulting function is c0 + c1 X + c2 X2 . . . + c3 X3.

GEN03 is useful in conjunction with table or tablei for audio waveshaping (sound modification by non-linear distortion). Coefficients to produce a particular formant from a sinusoidal lookup index of known amplitude can be determined at preprocessing time using algorithms such as Chebyshev formulae.

usage

  • f# time size 3 xval1 xval2 c0 c1 ... cn

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • xval1, xval2 -- left and right values of the x interval over which the polynomial is defined (xval1 < xval2). These will produce the 1st stored value and the (power-of-2 plus l)th stored value respectively in the generated function table.
  • c0, c1, c2 ... cn -- coefficients of the n-th order polynomial.

GEN04

GEN04 analyzes the specified f-table and creates a normalizing table. A signal that's modified with a waveshaping table may also have it's amplitude altered (if the waveshaping table is so scaled, see GEN03). GEN04 creates a table of samples that when multiplied with the original waveshaping table, will produce a normalized result. The result of the waveshaping and the GEN04 scaling will produce a signal whose amplitude has been shaped not scaled.

usage

  • f# time size 4 source sourcemode

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • source -- table number of stored function to be examined.
  • sourcemode -- a coded value, specifying how the source table is to be scanned to obtain the normalizing function. Zero indicates that the source is to be scanned from left to right. Non-zero indicates that the source has a bipolar structure; scanning will begin at the mid-point and progress outwards, looking at pairs of points equidistant from the center.

GEN05

GEN05 generates an f-table function from one or more exponential function segments. Each segment is defined with three parameters:

  • (a) the starting amplitude,
  • (b) the width of the segment in samples, and
  • (c) the ending amplitude.

For GEN05, the segment that's drawn between the starting and ending amplitudes uses an exponential function. For the next segment, the ending amplitude is used as the starting amplitude for the next segment. If a discontinuity is required, zero-width segments can be defined.

usage

  • f# time size 5 a n1 b n2 c ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • a, b, c, ... -- ordinate values, in odd-numbered pfields p5, p7, p9, . . . These must be nonzero and must be alike in sign.
  • n1, n2, ... -- length of segment (no. of storage locations), in even-numbered pfields. Cannot be negative, but a zero is meaningful for specifying discontinuous waveforms (e.g. in the example below). The sum n1 + n2 + .... will normally equal size for fully specified functions. If the sum is smaller, the function locations not included will be set to zero; if the sum is greater, only the first size locations will be stored.

GEN06

Generates a stored function from segments of cubic polynomial functions. Segments link ordinate values in groups of 3: point of inflexion, maximum/minimum, point of inflexion. The first complete segment encompasses b, c, d and has length n2 + n3, the next encompasses d, e, f and has length n4 + n5, etc. The first segment (a, b with length n1) is partial with only one inflexion; the last segment may be partial too. Although the inflexion points b, d, f ... each figure in two segments (to the left and right), the slope of the two segments remains independent at that common point (i.e. the 1st derivative will likely be discontinuous). When a, c, e... are alternately maximum and minimum, the inflexion joins will be relatively smooth; for successive maxima or successive minima the inflexions will be comb-like.

usage

  • f# time size 6 a n1 b n2 c n3 d ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • a, c, e, ... -- local maxima or minima of successive segments, depending on the reltion of these points to adjacent inflexions. May be iether positive or negative.
  • b, d, f, ... -- number of stored values between specified points. Cannot be negative, but a zero is meaningful for specifying discontinuities. The sum n1 + n2 + ... will normally equal size for fully specified functions.
  • n1, n2, n3, ... -- number of stored values between specified points. Cannot be negative, but a zero is meaningful for specifying discontinuities. The sum n1 + n2 + ... will normally equal size for fully specified functions.

GEN07

GEN07 generates an f-table function from one or more linear function segments. Each segment is defined with three parameters:

  • (a) the starting amplitude,
  • (b) the width of the segment in samples, and
  • (c) the ending amplitude.

For GEN07, the segment that's drawn between the starting and ending amplitudes uses a linear function. For the next segment, the ending amplitude is used as the starting amplitude for the next segment. If a discontinuity is required, zero-width segments can be defined.

usage

  • f# time size 7 a n1 b n2 c ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • a, b, c, ... -- ordinate values, in odd-numbered pfields p5, p7, p9, . . .
  • n1, n2, ... -- length of segment (no. of storage locations), in even-numbered pfields. Cannot be negative, but a zero is meaningful for specifying discontinuous waveforms. The sum n1 + n2 + .... will normally equal size for fully specified functions. If the sum is smaller, the function locations not included will be set to zero; if the sum is greater, only the first size locations will be stored.

GEN08

Generates a piecewise spline curve. Each segment of the generated f-table consisists of a single spline curve. Like GEN05 and GEN07, the input parameters are interpreted in groups of 3, where each group specifies the beginning level/ordinate, the segment length, and the ending level/ordinate. Moreover, the end of each group of 3 parameters is the first of the next group.

usage

  • f# time size 8 a n1 b n2 c ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • a, b, c, ... -- ordinate values, in odd-numbered pfields p5, p7, p9, . . .
  • n1, n2, ... -- length of segment (no. of storage locations), in even-numbered pfields. Cannot be negative, but a zero is meaningful for specifying discontinuous waveforms (e.g. in the example below). The sum n1 + n2 + .... will normally equal size for fully specified functions. If the sum is smaller, the function locations not included will be set to zero; if the sum is greater, only the first size locations will be stored.

GEN09

Generates a compositive waveform that's compriised of a weighted-sum of simple sinusoids. The input parameters are interpreted in groups of 3: (a) the partial number, which can be an integer or a fractional value, (b) the relative amplitude or strength of the partial, and (c) partial's initial phase. In each case the composite wave, once drawn, is then rescaled to unity if p4 was positive. A negative p4 will cause rescaling to be skipped.

usage

  • f# time size 9 pna stra phsa pnb strb phsb ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • pna, pnb, ... -- partial no. (relative to a fundamental that would occupy size locations per cycle) of sinusoid a, sinusoid b, etc. Must be positive, but need not be a whole number, i.e., non-harmonic partials are permitted. Partials may be in any order.
  • stra, strb, ... -- strength of partials pna, pnb, etc. These are relative strengths, since the composite waveform may be rescaled later. Negative values are permitted and imply a 180 degree phase shift.
  • phsa, phsb, ... -- initial phase of partials pna, pnb, etc., expressed in degrees (0-360).

GEN10

Generates a compositive waveform made up of weighted sums of simple sinusoids. Note that the primary frequency and the overtones can be generated using this GEN routine. Subharmonics cannot be generated with GEN10.

usage

  • f# time size 10 str1 str2 str3 str4 ... strN

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • str1, str2, ... strN -- relative strengths of the fixed harmonic partial numbers: 1, 2, 3, etc. For skipped partials, use a strN value of zero.

GEN11

GEN11 Generates an additive set of cosine partials. In essence, it's an efficient GEN routine for creating static pulse trains using an small number of arguments. GEN11 is designed to generate pulse-trains with a specified number of harmonics, the lowest specified harmonic, and an amplitude coefficient.

GEN11 produces a non-time-varying version of the CSound buzz and gbuzz generators, and is similarly useful as a complex sound source in subtractive synthesis. With lh and r present it parallels gbuzz; with both absent or equal to 1 it reduces to the simpler buzz (i.e. nh equal-strength harmonic partials beginning with the fundamental).

Sampling the stored waveform with an oscillator is more efficient than using the dynamic buzz units. However, the spectral content is invariant and care is necessary, lest the higher partials exceed the Nyquist during sampling to produce fold-over.

usage

  • f# time size 11 nh [lh] [r]

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • nh -- number of harmonics requested. Must be positive.
  • lh -- lowest harmonic partial present. Can be positive, zero or negative. The set of partials can begin at any partial number and proceeds upwards; if lh is negative, all partials below zero will reflect in zero to produce positive partials without phase change (since cosine is an even function), and will add constructively to any positive partials in the set. The default value is 1.
  • r -- multiplier in an amplitude coefficient series. This is a power series: if the lhth partial has a strength coefficient of A the (lh + n)th partial will have a coefficient of A * rn, i.e. strength values trace an exponential curve. r may be positive, zero or negative, and is not restricted to integers. The default value is 1.

GEN12

Generates the log of a modified Bessel function of the second kind, order 0, suitable for use in amplitude-modulated FM.

This subroutine draws the natural log of a modified Bessel function of the second kind, order 0 (commonly written as I subscript 0), over the x-interval requested. The call should have rescaling inhibited.

The function is useful as an amplitude scaling factor in cycle-synchronous amplitude-modulated FM. (See Palamin and Palamin, J. Audio Eng. Soc., 36/9, Sept. 1988, pp.671-684.) The algorithm is interesting because it permits the normally symmetric FM spectrum to be made asymmetric around a frequency other than the carrier, and is thereby useful for formant positioning. By using a table lookup index of I(r - 1/r), where I is the FM modulation index and r is an exponential parameter affecting partial strengths, the Palamin algorithm becomes relatively efficient, requiring only oscil's, table lookups, and a single exp call.

usage

  • f# time size 12 xint

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • xint -- specifies the x-interval, over which this function is defined. The interval starts at x == 0.

GEN13

Generates an f-table based on a polynomical whose coefficients derive from the Chebyshev polynomials of the first kind. GEN13 is the function generator normally employed in standard waveshaping. It stores a polynomial whose coefficients derive from the Chebyshev polynomials of the first kind, so that a driving sinusoid of strength xamp will exhibit the specified spectrum at output. Note that the evolution of this spectrum is generally not linear with varying xamp. However, it is bandlimited (the only partials to appear will be those specified at generation time); and the partials will tend to occur and to develop in ascending order (the lower partials dominating at low xamp, and the spectral richness increasing for higher values of xamp). A negative hn value implies a 180 degree phase shift of that partial; the requested full-amplitude spectrum will not be affected by this shift, although the evolution of several of its component partials may be. The pattern +,+,-,-,+,+,... for h0,h1,h2... will minimize the normalization problem for low xamp values (see above), but does not necessarily provide the smoothest pattern of evolution.

usage

  • f# time size 13 xint xamp h0 h1 h2 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • xint -- provides the left and right values [-xint, +xint] of the x interval over which the polynomial is to be drawn.
  • xamp -- amplitude scaling factor of the sinusoid input that is expected to produce the following spectrum.
  • h0, h1, h2 ... -- relative strength of partials 0 (DC), 1 (fundamental), 2 ... that will result when a sinusoid of amplitude xamp * int(size/2)/xint is waveshaped using this function table. These values thus describe a frequency spectrum associated with a particular factor xamp of the input signal. .

GEN14

Generates a polynomial whose coefficients derive from Chebyshevs of the second kind. Uses Chebyshev coefficients to generate stored polynomial functions which, under waveshaping, can be used to split a sinusoid into harmonic partials having a pre-definable spectrum.

usage

  • f# time size 14 xint xamp h0 h1 h2 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • xint -- provides the left and right values [-xint, +xint] of the x interval over which the polynomial is to be drawn.
  • xamp -- amplitude scaling factor of the sinusoid input that is expected to produce the following spectrum.
  • h0, h1, h2 ... -- relative strength of partials 0 (DC), 1 (fundamental), 2 ... that will result when a sinusoid of amplitude xamp * int(size/2)/xint is waveshaped using this function table. These values thus describe a frequency spectrum associated with a particular factor xamp of the input signal. .

GEN15

A GEN15 f-statement creates two f-tables with the identification number p1 and p1 + 1. Harmonic partials with phases between 0 and 179 are written into the first table while those with phases beteen 180 and 359 are written into the second table. Using these tables, a phase-quadrature instrument generates sounds containing individual harmonics with arbitrarily specified phases.

usage

  • f# time size 15 xint xamp h0 phs0 h1 phs1 h2 phs2 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • xint -- provides the left and right values [-xint, +xint] of the x interval over which the polynomial is to be drawn.
  • xamp -- amplitude scaling factor of the sinusoid input that is expected to produce the following spectrum.
  • h0, h1, h2 ... -- relative strength of partials 0 (DC), 1 (fundamental), 2 ... that will result when a sinusoid of amplitude xamp * int(size/2)/xint is waveshaped using this function table. These values thus describe a frequency spectrum associated with a particular factor xamp of the input signal.
  • phs0, phs1, phs2, ... -- phase in degrees of desired harmonics h0, h1, ... when the two functions of GEN15 are used with phase quadrature.

GEN16

GEN16 creates an f-table whose function extends from a starting value to the specified ending value. If type > 0, there is a slowly rising, fast decaying (convex) curve, while if type < 0, the curve is fast rising, slowly decaying (concave). If type is 0, a straight-line segment is drawn.

usage

  • f# time size 16 beg dur type end

parameters

  • beg -- the starting value.
  • dur -- number of segments.
  • type -- if 0, a straight line is produced. If non-zero, then GEN16 creates the following curve, for dur steps: beg + (end - beg) * (1 - exp( i*type/(dur-1) )) / (1 - exp(type)). .
  • end -- the ending value.

GEN17

GEN17 creates a step function for the specified x-y pairs. The individual step-segments start at the specified x-value and are held until the next x-value. The interleaving y-value determines the height of the function for each defined segment.

usage

  • f# time size 17 x1 a x2 b x3 c ...

parameters

  • x1, x2, x3, .. -- x-ordinate values, in ascending order, 0 first.
  • a, b, c, ... -- y-values at those x-ordinates, held until the next x-ordinate.

GEN18

GEN18 is used for mixing together data from pre-existing f-tables into a single new f-table. GEN18 enables one to select a portion of the existing wavetable and to determine at which point that table should be added to the next output table. Additionally, a scaling or relative-strength factor is used for specifying the relative-strengths of each of the existing f-tables when combined into the new table.

usage

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

parameters

  • fna, fnb, ... -- pre-existing table number to be written into the table.
  • ampa, ampb -- 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 -- where to start writing the fn into the table.
  • finisha, finishb -- where to stop writing the fn into the table.

GEN19

Generates a compositive waveform made up of weighted sums of simple sinusoid, which are comprised of the primary frequency and a specified number of partials. Each partial uses 4-parameters fields for defining the partial's number, strength, wave, and offset. Please note that the primary or fundamental frequency must also be declared in the parameter list if it is to be included.

usage

  • f# time size 19 pn1 str1 phs1 dco1 pn2 str2 phs2 dco2 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • pn1, pn2, ... -- partial no. (relative to a fundamental that would occupy size locations per cycle) of sinusoid 1, sinusoid 1, etc. Must be positive, but need not be a whole number, i.e., non-harmonic partials are permitted. Partials may be in any order.
  • str1, str2, ... -- strength of partials pn1, pnb2 etc. These are relative strengths, since the composite waveform may be rescaled later. Negative values are permitted and imply a 180 degree phase shift.
  • phs1, phs2, ... -- initial phase of partials pn1, pn2, etc., expressed in degrees.
  • dco1, dco2, ... -- DC offset of partials pn1, pn2, etc. This is applied after strength scaling, i.e. a value of 2 will lift a 2-strength sinusoid from range [-2,2] to range [0,4] .

GEN20

GEN20 generates functions of different windows. These windows are usually used for spectrum analysis or for grain envelopes.

usage

  • f# time size 20 window max [opt]

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • window -- Type of window to generate:

    1 = Hamming

    2 = Hanning

    3 = Bartlett ( triangle)

    4 = Blackman ( 3-term)

    5 = Blackman - Harris ( 4-term)

    6 = Gaussian

    7 = Kaiser

    8 = Rectangle

    9 = Sync

  • max -- For negative p4 this will be the absolute value at window peak point. If p4 is positive or p4 is negative and p6 is missing the table will be post-rescaled to a maximum value of 1.
  • opt -- Optional argument required by the Kaiser window.

GEN21

GEN21 generates f-tables based on random distributions. There are multiple distribution types to choose from. The distribution is specified by the first parameter to GEN21. Note that GEN21 is not self-normalizing as are most other GEN functions.

usage

  • f# time size 21 type level [arg1 [arg2]]

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • type -- random-number distribution type:

    1 = Uniform (positive numbers only)

    2 = Linear (positive numbers only)

    3 = Triangular (positive and negative numbers)

    4 = Exponential (positive numbers only)

    5 = Biexponential (positive and negative numbers)

    6 = Gaussian (positive and negative numbers)

    7 = Cauchy (positive and negative numbers)

    8 = Positive Cauchy (positive numbers only)

    9 = Beta (positive numbers only)

    10 = Weibull (positive numbers only)

    11 = Poisson (positive numbers only)

  • level -- amplitude.
  • arg1, arg2 -- both args must be passed to the Beta (9) and only a single argument (arg1) must be passed to Weilbull (10).

GEN23

GEN23 creates an f-table based on the contents of an ASCII-formatted file of numbers. Successive f-table values/levels are assigned to successive numeric values from the specified external file.

usage

  • f# time size -23 "filename.txt"

parameters

  • size -- number of points in the table. Must be a power of 2 , power of 2 + 1, or zero. If size = 0, table size is determined by the number of numeric values in filename.txt.
  • filename.txt -- numeric values contained in "filename.txt" (which indicates the complete pathname of the character file to be read), can be separated by spaces, tabs, newline characters or commas. Also, words that contains non-numeric characters can be used as comments since they are ignored.

GEN24

GEN24 creates a new f-table whose values are the scaled samples from an existing f-table. This GEN routine reads numeric values from another allocated function-table and rescales them according to the max and min values given by the user. This GEN is useful, for example, to eliminate the starting offset in exponential segments allowing a real starting from zero.

usage

  • f# time size -24 ftable min max

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • ftable -- the source f-table, which must be an already allocated table with the same size as this function.
  • min, max -- the rescaling range. The resulting f-table's minimum and maximum values will lie between these parameters.

GEN25

GEN25 creates an f-table from segments of exponential curves in breakpoint fashion. It is similar to GEN05 in that it produces segments of exponential curves, but instead of representing the lengths of segments and their endpoints, its arguments represent (x, y) coordinates in the table, and the subroutine produces curves between successive locations. The x-coordinates must be in increasing order.

usage

  • f# time size 25 x1 y1 x2 y2 x3 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • x1, x2, x3, ... -- locations in table at which to attain the following y value. Must be in increasing order. If the last value is less than size, then the rest will be set to zero. Should not be negative but can be ze.
  • y1, y2, y3, ... -- Breakpoint values attained at the location specified by the preceding x value. These must be non-zero and must be alike in sign.

GEN27

GEN27 creates an f-table from segments of linear segments in breakpoint fashion. It is similar to GEN07 in that it produces segments of exponential curves, but instead of representing the lengths of segments and their endpoints, its arguments represent (x, y) coordinates in the table, and the subroutine produces segments between successive locations. The x-coordinates must be in increasing order.

usage

  • f# time size 27 x1 y1 x2 y2 x3 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • x1, x2, x3, ... -- locations in table at which to attain the following y value. Must be in increasing order. If the last value is less than size, then the rest will be set to zero. Should not be negative but can be ze.
  • y1, y2, y3, ... -- Breakpoint values attained at the location specified by the preceding x value. These must be non-zero and must be alike in sign.

GEN28

This function generator reads a text file which contains sets of three values representing the x-y 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.

usage

  • f# time size 28 filecod

parameters

  • size -- number of points in the table. Must be 0. GEN28 takes 0 as the size and automatically allocates memory.
  • filecod -- character-string denoting the source soundfile 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.

GEN30

Extracts a range of harmonic partials from an existing waveform to generate a new f-table. GEN30 does not support tables with an extended guard point (ie. table size = power of two + 1). Although such tables will work both for input and output, when reading source table(s), the guard point is ignored, and when writing the output table, guard point is simply copied from the first sample (table index = 0). The reason of this limitation is that GEN30 uses FFT, which requires power of two table size. GEN32 allows using linear interpolation for resampling and phase shifting, which makes it possible to use any table size (however, for partials calculated with FFT, the power of two limitation still exists).

usage

  • f# time size 30 src minh maxh [ref_sr] [interp]

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • src -- the source f-table number.
  • minh, maxh -- the minimum and maximum harmonic numbers or partials.
  • ref_sr -- maxh is scaled by (sr / ref_sr). The default value of ref_sr is sr. If ref_sr is zero or negative, it is now ignored.
  • interp -- if non-zero, allows changing the amplitude of the lowest and highest harmonic partial depending on the fractional part of minh and maxh. For example, if maxh is 11.3 then the 12th harmonic partial is added with 0.3 amplitude. This parameter is zero by default.

GEN31

Creates a new f-table by adding partials of the specified source f-table. This GEN routine is similar to a sine-wave-with-partials-creator, but it produces the f-table with partials/harmonics of the source f-table rather than with a sine wave.

usage

  • f# time size 31 src pna stra phsa pnb strb phsb ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • src -- the source f-table number.
  • pna, pnb, ... -- the partial numbers relative to the base or primary frequency.
  • stra, strb, ... -- the relative strengths or amplitudes of the partials.
  • phsa, phsb, ... -- the starting phase of the partials.

GEN32

Creates a new f-table by adding partials of the specified source f-tables. This GEN routine extends GEN31 by allowing each partial of the destination f-table to be created from a different input or source f-table.

usage

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

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • 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, ... -- the partial numbers relative to the base or primary frequency.
  • stra, strb, ... -- the relative strengths or amplitudes of the partials.
  • phsa, phsb, ... -- the starting phase of the partials.

GEN33

GEN33 creates composite waveforms by mixing simple sinusoids, similarly to GEN09, but the parameters of the partials are specified in an already existing table, which makes it possible to calculate any number of partials in the orchestra.

The difference between GEN33 and GEN34 is that GEN33 uses inverse FFT to generate output, while GEN34 is based on the algorithm used in oscils opcode. GEN33 allows integer partials only, and does not support power of two plus 1 table size, but may be significantly faster with a large number of partials. On the other hand, with GEN34, it is possible to use non-integer partial numbers and extended guard point, and this routine may be faster if there is only a small number of partials (note that GEN34 is also several times faster than GEN09, although the latter may be more accurate).

usage

  • f# time size 33 src nh scl [fmode]

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • src -- source table number. This table contains the parameters of each partial in the following format: stra, pna, phsa, strb, pnb, phsb, ... the parameters are:
    • stra, strb, etc.: relative strength of partials. The actual amplitude depends on the value of scl, or normalization (if enabled).
    • pna, pnb, etc.: partial number, or frequency, depending on fmode (see below); zero and negative values are allowed, however, if the absolute value of the partial number exceeds (size / 2), the partial will not be rendered. With GEN33, partial number is rounded to the nearest integer.
    • phsa, phsb, etc.: initial phase, in the range 0 to 1.
    Table length (not including the guard point) should be at least 3 * nh. If the table is too short, the number of partials (nh) is reduced to (table length) / 3, rounded towards zero.
  • nh -- number of partials. Zero or negative values are allowed, and result in an empty table (silence). The actual number may be reduced if the source table (src) is too short, or some partials have too high frequency.
  • scl -- amplitude or scaling factor.
  • fmode -- (default == 0) a non-zero value can be used to set frequency in Hz instead of partial numbers in the source table. The sample rate is assumed to be fmode if it is positive, or -(sr * fmode) if any negative value is specified.

GEN34

GEN33 creates composite waveforms by mixing simple sinusoids, similarly to GEN09, but the parameters of the partials are specified in an already existing table, which makes it possible to calculate any number of partials in the orchestra.

The difference between GEN33 and GEN34 is that GEN33 uses inverse FFT to generate output, while GEN34 is based on the algorithm used in oscils opcode. GEN33 allows integer partials only, and does not support power of two plus 1 table size, but may be significantly faster with a large number of partials. On the other hand, with GEN34, it is possible to use non-integer partial numbers and extended guard point, and this routine may be faster if there is only a small number of partials (note that GEN34 is also several times faster than GEN09, although the latter may be more accurate).

usage

  • f# time size 34 src nh scl [fmode]

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • src -- source table number. This table contains the parameters of each partial in the following format: stra, pna, phsa, strb, pnb, phsb, ... the parameters are:
    • stra, strb, etc.: relative strength of partials. The actual amplitude depends on the value of scl, or normalization (if enabled).
    • pna, pnb, etc.: partial number, or frequency, depending on fmode (see below); zero and negative values are allowed, however, if the absolute value of the partial number exceeds (size / 2), the partial will not be rendered. With GEN33, partial number is rounded to the nearest integer.
    • phsa, phsb, etc.: initial phase, in the range 0 to 1.
    Table length (not including the guard point) should be at least 3 * nh. If the table is too short, the number of partials (nh) is reduced to (table length) / 3, rounded towards zero.
  • nh -- number of partials. Zero or negative values are allowed, and result in an empty table (silence). The actual number may be reduced if the source table (src) is too short, or some partials have too high frequency.
  • scl -- amplitude or scaling factor.
  • fmode -- (default == 0) a non-zero value can be used to set frequency in Hz instead of partial numbers in the source table. The sample rate is assumed to be fmode if it is positive, or -(sr * fmode) if any negative value is specified.

GEN40

Generates a continuous random distribution function starting from the shape of a user-defined distribution histogram. Histogram shape can be generated with any other GEN routines. Since no interpolation is used when GEN40 processes the translation, it is suggested that the size of the table containing the histogram shape to be reasonably big, in order to obtain more precision (however after the processing the shaping-table can be destroyed in order to re-gain memory).

usage

  • f# time size 40 shapetab

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • shapetab -- the identifier of the f-table that contains the distribution-shape or histogram data.

GEN41

Generates a discrete random distribution function by giving a list of numerical pairs. The first number of each pair is a value, and the second is the probability of that value to be chosen by a random algorithm. Even if any number can be assigned to the probability element of each pair, it is suggested to give it a percent value, in order to make it clearer for the user.

usage

  • f# time size 41 value1 prob1 value2 prob2 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • value1, value2, ... -- the values to be created on a random basis.
  • prob1, prob2, ... -- the relative probability coefficient for each of the values.

GEN42

Generates a random distribution function of discrete ranges of values by giving a list of groups of three numbers. The first number of each group is a the minimum value of the first range, the second is the maximum value and the third is the probability of that an element belonging to that range of values can be chosen by a random algorithm. Even if any number can be assigned to the probability element of each group, it is suggested to give it a percent value, in order to make it clearer to the user.

usage

  • f# time size 41 min1 max1 prob1 min2 max2 prob2 ...

parameters

  • size -- number of points in the table. This value must be a power-of-2 or a power-of-2 plus 1.
  • min1, min2, ... -- the minimum or floor for range n.
  • max1, max2, ... -- the maximum or ceiling for range n.
  • prob1, prob2, ... -- the relative probability coefficient for each of the ranges.

GEN51

GEN51 fills a table with a fully customized microtonal tuning in the manner of Csound opcodes cpstun, cpstuni, and cpstmid.

usage

  • f# time size 51 numgrades interval basefreq basekey tuningRatio1 tuningRatio2 ...

parameters

  • size -- number of points in the table.
  • numgrades -- the number of grades/pitches in the microtonal tuning.
  • interval -- the frequency range covered before repeating the grade ratios (i.e., the equivalence interval or the identity interval). This is real number. For octave equivalence, use 2.0. For Bohlen-Pierce tuning use 3.0.
  • basefreq -- the tuning's base frequency in Hz.
  • basekey -- the integer index of the scale, to which to assign basefreq unmodified.
  • tuningRatio1, tuningRatio2, ... -- the pitches or ratios in the tuning/scale. The number of tuning-ratio arguments must match the numgrades parameter.

GEN52

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.

usage

  • f# time size 52 nchannels channel_params_1 channel_params_2 ...

parameters

  • size -- number of points in the table.
  • nchannels -- the number of channel parameters passed.
  • channel_params_1, channel_params_2, ... -- the channel parameters required for use of the ftconv opcode.