Use Non-Frames Version Previous Page Next Page
Appendix: DirectCsound

GEN22

  f # time size -22 filcod skiptime format channel

Description

Transfer data from a soundfile into a function table, using 16-bit integers for storing it in RAM.

Initialization

size - number of points in the table. Ordinarily a power of 2 or a power-of-2 plus 1 (see f Statement); the maximum tablesize is 16777216 (224) points. If the source soundfile is of type AIFF, 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 loscil2 unit. An AIFF source 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. See also soundin.

skiptime - begin reading at skiptime seconds into the file.

channel - channel number to read in. 0 denotes read all channels.

format - specifies the audio data-file format:

  1 - 8-bit signed character    4 - 16-bit short integers 
  2 - 8-bit A-law bytes         5 - 32-bit long integers 
  3 - 8-bit U-law bytes         6 - 32-bit floats

If format = 0 the sample format is taken from the soundfile header, or by default from the Csound -o command flag.

Notes

This subroutine is almost identical to GEN01. The only difference is GEN22 can only read 16 bit integer samples in mono or stereo and stores them in RAM keeping 16-bit integer format This halves RAM need. Very useful for long samples.

For now GEN22 can operate only with loscil2, lposcint and fof3 opcodes . You must always suppress normalization by using a negative GEN number, otherwise you will obtain a meaningless sequence of 1 , -1 and 0 integer values!

WARNING! The only opcodes which can use GEN22-generated functions are loscil2, lposcint and fof3. You must rescale the output of loscil2 and fof3 opcodes, when upgrading instruments written with the older opcodes (i.e. loscil and fof2) otherwise they could surpass the range limit of output.

Don't attempt to use GEN22 with any other opcode (for now).


Use Non-Frames Version Previous Page Next Page
Appendix: DirectCsound