Generate a table with values on the tanh function.
Syntax
f#timesize"tanh"startendrescale
Initialization
size -- number of points in the table. Must be a power of 2 or power-of-2 plus 1 (see f statement).
start, end -- first and last value to be stored; the GEN draws a curve that goes from start to end: tanh(start) .... tanh(end). The points stored are uniformly spaced between these to the table size
rescale -- if not zero the table is not rescaled
Examples
Here is a simple example of the GENtanh routine. It uses the file gentanh.csd.
<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 gentanh.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1instr1aswplinseg0.01,p3*.5,.49,p3*.5,0.01;index sweep functionaindexposcilaswp,110,1;sound to waveshapeatabletableiaindex,p4,1,.5;waveshape indexaenvlinen0.8,.01,p3,.02;amplitude envelopeasig=(atable*aenv)*p5;impose envelope and scaleasigdcblock2asig;get rid of DCoutsasig,asigendin</CsInstruments><CsScore>f108192101;sine wavef208192"tanh"-1001000;symmetrical transfer fuctionf308192"tanh"-10100;symmetricalf408192"tanh"0100;not symmetricali10321i1+331i1+342e</CsScore></CsoundSynthesizer>
These are the diagrams of the waveforms of the GENtanh routines, as used in the example:
f 2 0 8192 "tanh" -100 100 0 - lots of distortion f 3 0 8192 "tanh" -10 10 0 - less distortion than f2 f 4 0 8192 "tanh" -10 15 0